Numerical branch name interpreted as a cset number

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Numerical branch name interpreted as a cset number

Tom Fox
My company interchangeably uses Mercurial and Git.  It became policy to use branches in Git that are numbers like "111".  This policy has shifted to Mercurial as well.  Unfortunately, in Mercurial these branch names will be interpreted as a cset number if such a cset number exists (e.g. hg heads -r 111).  Is there a way to force a revision reference to look for a matching branch before it looks for an existing cset number?  Or better yet, is there a way to say this IS a branch reference?

Thanks,
Tom
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Matt Mackall
On Fri, 2011-12-09 at 15:00 -0800, Tom Fox wrote:
> My company interchangeably uses Mercurial and Git.  It became policy to use
> branches in Git that are numbers like "111".  This policy has shifted to
> Mercurial as well.  Unfortunately, in Mercurial these branch names will be
> interpreted as a cset number if such a cset number exists (e.g. hg heads -r
> 111).  Is there a way to force a revision reference to look for a matching
> branch before it looks for an existing cset number?  Or better yet, is there
> a way to say this IS a branch reference?

$ hg branch 111
marked working directory as branch 111
(branches are permanent and global, did you want a bookmark?)
$ hg ci -msilly
$ hg log -r "branch(111)"
changeset:   15632:9125c4e5b3d9
branch:      111
tag:         tip
user:        Matt Mackall <[hidden email]>
date:        Fri Dec 09 17:17:56 2011 -0600
summary:     silly

--
Mathematics is the supreme nostalgia of our time.


_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Tom Fox
Matt Mackall wrote
On Fri, 2011-12-09 at 15:00 -0800, Tom Fox wrote:
> My company interchangeably uses Mercurial and Git.  It became policy to use
> branches in Git that are numbers like "111".  This policy has shifted to
> Mercurial as well.  Unfortunately, in Mercurial these branch names will be
> interpreted as a cset number if such a cset number exists (e.g. hg heads -r
> 111).  Is there a way to force a revision reference to look for a matching
> branch before it looks for an existing cset number?  Or better yet, is there
> a way to say this IS a branch reference?

$ hg branch 111
marked working directory as branch 111
(branches are permanent and global, did you want a bookmark?)
$ hg ci -msilly
$ hg log -r "branch(111)"
changeset:   15632:9125c4e5b3d9
branch:      111
tag:         tip
user:        Matt Mackall <[hidden email]>
date:        Fri Dec 09 17:17:56 2011 -0600
summary:     silly
We're using an old version of Mercurial, 1.4.3.  When was the branch() functionality added, as it doesn't seem to work for me?

-Tom
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Olle Lundberg
On Sat, Dec 10, 2011 at 00:32, Tom Fox <[hidden email]> wrote:

>
> Matt Mackall wrote
>>
>> On Fri, 2011-12-09 at 15:00 -0800, Tom Fox wrote:
>>> My company interchangeably uses Mercurial and Git.  It became policy to
>>> use
>>> branches in Git that are numbers like "111".  This policy has shifted to
>>> Mercurial as well.  Unfortunately, in Mercurial these branch names will
>>> be
>>> interpreted as a cset number if such a cset number exists (e.g. hg heads
>>> -r
>>> 111).  Is there a way to force a revision reference to look for a
>>> matching
>>> branch before it looks for an existing cset number?  Or better yet, is
>>> there
>>> a way to say this IS a branch reference?
>>
>> $ hg branch 111
>> marked working directory as branch 111
>> (branches are permanent and global, did you want a bookmark?)
>> $ hg ci -msilly
>> $ hg log -r "branch(111)"
>> changeset:   15632:9125c4e5b3d9
>> branch:      111
>> tag:         tip
>> user:        Matt Mackall &lt;mpm@&gt;
>> date:        Fri Dec 09 17:17:56 2011 -0600
>> summary:     silly
>>
>
> We're using an old version of Mercurial, 1.4.3.  When was the branch()
> functionality added, as it doesn't seem to work for me?
>
> -Tom
>
Revsets where introduced in 1.6. For more info:
http://www.selenic.com/mercurial/hg.1.html#revsets

> --
> View this message in context: http://mercurial.808500.n3.nabble.com/Numerical-branch-name-interpreted-as-a-cset-number-tp3574350p3574415.html
> Sent from the General mailing list archive at Nabble.com.
> _______________________________________________
> Mercurial mailing list
> [hidden email]
> http://selenic.com/mailman/listinfo/mercurial



--
Olle
_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Tom Fox
In reply to this post by Matt Mackall
Matt Mackall wrote
$ hg log -r "branch(111)"
changeset:   15632:9125c4e5b3d9
branch:      111
tag:         tip
user:        Matt Mackall <[hidden email]>
date:        Fri Dec 09 17:17:56 2011 -0600
summary:     silly
Furthermore, when I attempt to use our most recently installed Mercurial (1.7.5), the branch(nnn) syntax works with log, but not with heads.  In fact, the hg log output shows no changesets on the 111 branch.

-Tom
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Matt Mackall
On Fri, 2011-12-09 at 15:47 -0800, Tom Fox wrote:

> Matt Mackall wrote
> >
> > $ hg log -r "branch(111)"
> > changeset:   15632:9125c4e5b3d9
> > branch:      111
> > tag:         tip
> > user:        Matt Mackall &lt;mpm@&gt;
> > date:        Fri Dec 09 17:17:56 2011 -0600
> > summary:     silly
> >
>
> Furthermore, when I attempt to use our most recently installed Mercurial
> (1.7.5), the branch(nnn) syntax works with log, but not with heads.  In
> fact, the hg log output shows no changesets on the 111 branch.

Yep. It took a bit for the revset facility to be supported everywhere.
In fact, it seems we missed 'hg heads <X>' (though the slightly
different 'hg heads -r <X>' does work).

But revsets are extremely powerful and render most of log's other
options redundant (along with all the other commands that show
changesets). So for instance, you can do:

hg log -r 'heads(branch(111))'

..though it'd obviously Just Work if you used a less ambiguous branch
naming scheme.

--
Mathematics is the supreme nostalgia of our time.


_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Tom Fox
Matt Mackall wrote
Yep. It took a bit for the revset facility to be supported everywhere.
In fact, it seems we missed 'hg heads <X>' (though the slightly
different 'hg heads -r <X>' does work).

But revsets are extremely powerful and render most of log's other
options redundant (along with all the other commands that show
changesets). So for instance, you can do:

hg log -r 'heads(branch(111))'

..though it'd obviously Just Work if you used a less ambiguous branch
naming scheme.
This must have been done after 1.7.5.  In 1.7.5, "hg log -r 'head(branch(111))'" does not work.  "hg log -r 'branch(111) and head()'" does work, but it gives me the wrong branch.  Again, it would seem to be using cset 111.  What does seem to work is "hg log -b 111 -r "head()".  I guess it might be time to upgrade.  :-)
Reply | Threaded
Open this post in threaded view
|

Re: Numerical branch name interpreted as a cset number

Matt Mackall
On Fri, 2011-12-09 at 19:08 -0800, Tom Fox wrote:

> Matt Mackall wrote
> >
> > Yep. It took a bit for the revset facility to be supported everywhere.
> > In fact, it seems we missed 'hg heads <X>' (though the slightly
> > different 'hg heads -r <X>' does work).
> >
> > But revsets are extremely powerful and render most of log's other
> > options redundant (along with all the other commands that show
> > changesets). So for instance, you can do:
> >
> > hg log -r 'heads(branch(111))'
> >
> > ..though it'd obviously Just Work if you used a less ambiguous branch
> > naming scheme.
> >
>
> This must have been done after 1.7.5.  In 1.7.5, "hg log -r
> 'head(branch(111))'" does not work.  "hg log -r 'branch(111) and head()'"

heads
    ^

    "head()"
      Changeset is a named branch head.

    "heads(set)"
      Members of set with no children in set.

But you're right, that doesn't work in 1.7.5, and has since been fixed.

--
Mathematics is the supreme nostalgia of our time.


_______________________________________________
Mercurial mailing list
[hidden email]
http://selenic.com/mailman/listinfo/mercurial