question on "hg head" and the head(), heads([set]) predicates

Giovanni Gherdovich g.gherdovich at gmail.com
Thu Jun 25 20:57:16 UTC 2015


Thanks Matt, it all makes sense.

Giovanni

On Thu, Jun 25, 2015 at 10:22 PM, Matt Mackall <mpm at selenic.com> wrote:

> On Thu, 2015-06-25 at 17:49 +0200, Giovanni Gherdovich wrote:
> > 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
>
> Here, rev is expecting a single revision. So it turns "branch(default)"
> into 5 (the highest numbered element of the set). Done.
>
> > -------------------------------------------
> >
> > 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
>
>     "head()"
>       Changeset is a named branch head.
>
> 1 is not a head of default because it has a descendant on default.
>
> > -------------------------------------------
> >
> > And I also believed that the two revset expressions
> >
> > "head() and branch(default)"
> > "heads(branch(default))"
>
>     "heads(set)"
>       Members of set with no children in set.
>
> This predicate is purely about DAG topology and is unaware of named
> branches.
>
> --
> Mathematics is the supreme nostalgia of our time.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial/attachments/20150625/fa70b3ee/attachment-0002.html>


More information about the Mercurial mailing list