在mercurial中是否有办法通过在编辑中提供模式(更改的代码)来查找更改,而不是日志消息或文件名?
我在“hg help revsets”中看得非常透彻,我认为没有一个好方法可以做到这一点。这是我提出的最好的黑客,但我希望我错过了一个能力,或者有人可以做得更好。
hg log -M -u goldberg -p | grep '(^changeset:\|
<pattern>
)' | grep -C 1 '<pattern>
'
(然后手动选择修订版号以便以后使用这些修订版)
答案 0 :(得分:31)
你应该看看hg grep
。
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.
您可以输入hg grep --help
以获取更多信息。