【发布时间】:2011-01-21 16:54:56
【问题描述】:
我有几个分支需要合并,但我不知道合并工具中显示的某些更改来自哪里。 local 和 other 的变更集是显而易见的,但是我怎样才能找出 base 文件来自哪个变更集呢?我在一个有几十个分支的存储库中工作,所以查看图表并跟踪它并不是很好。
【问题讨论】:
我有几个分支需要合并,但我不知道合并工具中显示的某些更改来自哪里。 local 和 other 的变更集是显而易见的,但是我怎样才能找出 base 文件来自哪个变更集呢?我在一个有几十个分支的存储库中工作,所以查看图表并跟踪它并不是很好。
【问题讨论】:
使用revsets(Mercurial 1.6 及更高版本),您可以获得两个变更集的共同祖先:
hg log -r ancestor(rev1,rev2)
【讨论】:
试试hg grep 命令:
hg grep [OPTION]... PATTERN [FILE]...
search for a pattern in specified files and revisions
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.
options:
-0 --print0 end fields with NUL
--all print all revisions that match
-f --follow follow changeset history, or file history across
copies and renames
-i --ignore-case ignore case when matching
-l --files-with-matches print only filenames and revisions that match
-n --line-number print matching line numbers
-r --rev REV [+] only search files changed within revision range
-u --user list the author (long with -v)
-d --date list the date (short with -q)
-I --include PATTERN [+] include names matching the given patterns
-X --exclude PATTERN [+] exclude names matching the given patterns
--mq operate on patch repository
[+] marked option can be specified multiple times
use "hg -v help grep" to show global options
你可以像这样使用它:
hg grep "a string"
它会告诉你它是在哪个版本中首次添加的。
如果您正在寻找更少搜索和更多概览的内容,您可以使用 hg log -v 查看每个变更集中哪些文件发生了更改,并使用 hg log -p 查看每个变更的实际差异。
【讨论】: