question on "hg head" and the head(), heads([set]) predicates
Giovanni Gherdovich
g.gherdovich at gmail.com
Thu Jun 25 15:49:48 UTC 2015
Hello,
I encountered a behaviour I don't quite understand.
Consider this toy repository:
-------------------------------------------
$ hg init
$ touch foo ; hg add foo ; hg commit -m foo
$ touch bar ; hg add bar ; hg commit -m bar
$ hg branch quux ; hg commit -m 'branch quux'
$ hg commit -m 'close branch quux' --close-branch
$ hg up 0
$ hg merge quux ; hg commit -m 'merged quux'
$ hg up 0
$ touch baz ; hg add baz ; hg commit -m baz
$ hg log --graph --template '{rev}\t{branch}\t|{desc}\n'
@ 5 default |baz
|
| o 4 default |merged quux
|/|
| _ 3 quux |close branch quux
| |
| o 2 quux |branch quux
| |
| o 1 default |bar
|/
o 0 default |foo
-------------------------------------------
Now, in this repo the branch default has 3 heads (1, 4, 5)
two of which are topological heads (4, 5).
I expected this command to give me csets 4 and 5,
but it only says "5". Expected?
-------------------------------------------
$ hg heads --topo --rev "branch(default)" --template '{rev}\n'
5
-------------------------------------------
More over, I expected this revset expression
to give me all heads of default, namely 1, 4, 5,
but it only says "4, 5". Expected?
-------------------------------------------
$ hg log --rev "head() and branch(default)" --template '{rev}\n'
4
5
-------------------------------------------
And I also believed that the two revset expressions
"head() and branch(default)"
"heads(branch(default))"
to be equivalent, but apparently they aren't: the latter gives
-------------------------------------------
$ hg log --rev "heads(branch(default))" --template '{rev}\n'
1
4
5
-------------------------------------------
Can somebody clarify?
This is all hg 3.4.
On a side note, my workflow (I manage the repository of a team of ~75 devs)
relies heavily on this open-branch/close-branch trick
to do the accounting of pull requests that have been merged in our
central repository.
In the example above, the developer's pull request would have been the
changeset 1 (bar).
When the pullrequest is processed by our build/test machinery,
the automatic bot creates (and immediately closes)
the dummy branch "quux" (which keeps, like, the pull request identifier or
something).
In this way I can have all developers working on their "default",
and nonetheless have the necessary markers in place that let
me query the repo history via revset to know what pullrequest
are merged, what's their graph, in which release they appeared etc.
(I add this context just in case somebody can spot a pitfall in it,
which was the reason I had to do that query above in the first place).
Cheers,
Giovanni
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial/attachments/20150625/621adfd6/attachment.html>
More information about the Mercurial
mailing list