开发者

How to find all changsets where a reference to a function was modified?

开发者 https://www.devze.com 2023-02-25 03:09 出处:网络
I need to find all recent changes to our code that are related to the Save() method. I need a mercurial command to find every changeset/files in which a line that refers to the string \"Save();\" was

I need to find all recent changes to our code that are related to the Save() method. I need a mercurial command to find every changeset/files in which a line that refers to the string "Save();" was added 开发者_JAVA技巧or modified.

I need more that just the changesets, I need to review the files where the changes where made.


It seems like you're looking for something like

hg grep --all 'Save();'

That 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 that you get all of the references, as by default hg stops looking at a file after it finds the first reference (searching backwards through the revision list). Also note that you'll almost certainly want to limit the revision range you search on, as this takes quite a bit of time on a largish repo.

If you're on a unix system, you should be able to pipe the output of the grep command into a file (it takes awhile to run, you probably want to cache it in case you don't get the later stuff right the first time)

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

That should give you the list of files and revisions that you want to look at.


You are looking for hg grep. It takes a Perl/Python regex and returns a result for the first revision of a 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消