简体   繁体   English

Mercurial 2.1.1-确定变更集是否为合并

[英]Mercurial 2.1.1 - Determine if a changeset is a merge

In Mercurial 2.4 a template keyword {p2rev} was added that can be used to determine if a changeset is a merge. 在Mercurial 2.4了模板关键字{p2rev} ,可用于确定变更集是否为合并。

hg log -r42 --template {p2rev}

If this returns "-1", there is no second parent, hence the changeset is not a merge, otherwise it is a merge. 如果返回“ -1”,则没有第二个父代,因此变更集不是合并,否则合并。

But most devs here still are on Mercurial 2.1.1 . 但是这里的大多数开发人员仍在使用Mercurial 2.1.1 Using {p2rev} on their machines always returns [blank]. 在他们的计算机上使用{p2rev}总是返回[空白]。

I tried in 2.1.1: 我在2.1.1中尝试过:

hg log -r42 --template {parents}

and this gives a bit weird output: 这给出了一些奇怪的输出:

  • if there is only 1 parent (not a merge): no output 如果只有1个父项(没有合并):无输出
  • if there are 2 parents (merge): the {rev}:{node} of both parents 如果有两个父母(合并): 两个父母的{rev}:{node}

What is the best way to determine if a changeset is a merge in Mercurial pre-2.4 , say 2.1.1 ? 确定变更集是否为Mercurial 2.4之前的版本 (例如2.1.1 )的合并的最佳方法是什么?

The hg parents command might do what you want: hg parents命令可能会执行您想要的操作:

hg parents -r 42 --template "{node|short}\n"

For a merge changeset you will get 2 lines of output, and for a non-merge changeset you'll get 1 line. 对于合并变更集,您将获得2行输出,对于非合并变更集,您将获得1行。

I am using Mercurial 2.2.2 (Ubuntu 12.10) and it seems that this is working (using the Revision Sets query language): 我正在使用Mercurial 2.2.2(Ubuntu 12.10),看来这是可行的(使用修订集查询语言):

$ hg log -r 'merge()'
changeset:   6:f75b34694a73
parent:      4:129b7b24f6b4
parent:      5:85771af34f42
[...]
summary:     Merge branch 'default' of /foo/proto

changeset:   12:04975792d1f3
parent:      10:42c64107845f
parent:      11:226623b54bd2
[...]
summary:     merged branch 'experimental-bar' into 'default'

If 如果

hg log -r"42 & merge()" --template x

returns a non-empty string, Then changeset 42 is a merge. 返回一个非空字符串,然后变更集42是一个合并。
The template returns the letter x if there is a result. 如果有结果,模板将返回字母x。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM