Finding changesets in mercurial by grepping the patch

旧巷老猫 提交于 2019-12-20 17:31:20

问题


Is there a way in mercurial to find a change by giving a pattern in the edit (the changed code), as opposed to the log message or filename?

I've looked pretty thoroughly in "hg help revsets" and I think there's not a good way to do this. Here's the best hack I came up with, but I'm hoping I missed a capability, or that someone can do a little better.

hg log -M -u goldberg -p | grep '(^changeset:\|<pattern>)' | grep -C 1 '<pattern>'

(and then manually selecting the revision number for later work with those revisions)


回答1:


You should take a look at 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.

You can type hg grep --help for more informations.



来源:https://stackoverflow.com/questions/5330782/finding-changesets-in-mercurial-by-grepping-the-patch

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!