How to find all changes in which the link to the function has been changed?

I need to find all the latest changes to our code related to the Save () method. I need a mercurial command to search for each set of changes / files in which a line that refers to the line "Save ();" has been added or modified.

I need more than just changes, I need to look at the files in which the changes are made.

+4
source share
2 answers

It seems that you are looking for something like

hg grep --all 'Save();' 

This should give you every file change in the format

 <file path>:<revision>:+ or -:<line of code changed> 

The --all flag is useful to make sure you get all the links, since by default hg stops looking at the file after it finds the first link (search back through the revision list). Also note that you will almost certainly want to limit the scope of the revision you are searching for, as it takes quite a lot of time on a fairly large repo.

If you are on a unix system, you should be able to transfer the output of the grep command to a file (it takes some time to start, you may want to cache it if you do not receive later material for the first time)

 cat saved_grep_results | awk 'BEGIN {FS=":"} {print $1" "$2}' | uniq 

This should provide you with a list of files and fixes that you want to view.

+5
source

You are looking for hg grep . It takes a Perl / Python regex and returns the result for the first revision of the file in which it finds a match.

 hg grep [OPTION]... PATTERN [FILE]... Search revisions of files for a regular expression. This command behaves differently than Unix grep. It only accepts Python/Perl regexps. It searches repository history, not the working directory. It always prints the revision number in which a match appears. By default, grep only prints output for the first revision of a file in which it finds a match. To get it to print every revision that contains a change in match status ("-" for a match that becomes a non- match, or "+" for a non-match that becomes a match), use the --all flag. Returns 0 if a match is found, 1 otherwise. 

So, in your case, something like

 hg grep Save 

should at least be a good starting place.

+1
source

All Articles