Reputation: 1601
In Mercurial 2.4
a template keyword {p2rev}
was added that can be used to determine if a changeset is a merge.
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.
But most devs here still are on Mercurial 2.1.1
. Using {p2rev}
on their machines always returns [blank].
I tried in 2.1.1:
hg log -r42 --template {parents}
and this gives a bit weird output:
What is the best way to determine if a changeset is a merge in Mercurial pre-2.4, say 2.1.1
?
Upvotes: 0
Views: 136
Reputation: 228
The hg parents
command might do what you want:
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.
Upvotes: 1
Reputation: 1601
If
hg log -r"42 & merge()" --template x
returns a non-empty string, Then changeset 42 is a merge.
The template returns the letter x if there is a result.
Upvotes: 0
Reputation: 5110
I am using Mercurial 2.2.2 (Ubuntu 12.10) and it seems that this is working (using the Revision Sets query language):
$ 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'
Upvotes: 0