Is there a way to search for a diff set for a specific line for a file?

I would like to find diffs of a single file (ideally a set of files) for a specific set of revisions (or all). I am looking for a difference report that can be found in text mode. I have it:

hg diff -r 0:47131 .\TheFile.cs | grep 'theSearch' -Context 50

OK, this works pretty well, but deciding how much context to include is a problem, as well as finding the first and last revision. I can automate this better, but it looks like it will work a little.

I am wondering if there is a tool there that will do it better. Maybe the leak report web page for the hg server?

+6
source share
2 answers

You can use hg grep to search the entire repo history.

For instance:

 hg grep --all --include .\TheFile.cs 'theSearch' 

will find all instances of 'theSearch' in each repo revision. Without the --all flag, it stops in the first revision containing the string.

+10
source

I have the feeling that hg grep is looking for the contents of the entire file for each corresponding revision. If you want to search for diff only, try something like this:

hg log --template "{ifcontains('TODO', diff(), '{node} {desc}\n', '')}"

This list will list versions containing "TODO". Please note that this will also remove the search strings as well as the diff context (+/- 3 strings), so it is not ideal.

You can limit the further use of args for diff () - see hg help template - and using revsets ( -r ... ).

It might be better than using your hg diff | grep hg diff | grep , because it distinguishes each set of changes one by one, instead of distinguishing all repos on two sets of changes and allows you to use, for example, revsets to filter merge versions.

+1
source

Source: https://habr.com/ru/post/919790/


All Articles