[Python-Dev] of branches and heads

Adrian Buehlmann adrian at cadifra.com
Sun Feb 27 11:42:21 CET 2011


On 2011-02-26 23:26, Greg Ewing wrote:
> From: Antoine Pitrou
>> - a "branch" usually means a "named branch": a set of changesets
>>   bearing the same label (e.g. "default"); that label is freely chosen
>>   by the committer at any point, and enforces no topological
>>   characteristic
> 
> There are *some* topological restrictions, because hg won't
> let you assign a branch name that's been used before to a node
> unless one of its parents has that name. So you can't create
> two disconnected subgraphs whose nodes have the same branch
> name.

That's not completely correct. You *can* do that.

Mercurial by default assumes you're probably in error if you are
trying to create such disconnected branch name subgraphs, but you
can convince it that it's really what you want by doing:

  hg branch --force <existing branch name>

Example (glog command requires the graphlog extension enabled [1]):

  $ hg init a
  $ cd a
  $ echo foo > bla
  $ hg ci -Am1
  adding bla
  $ hg branch b1
  marked working directory as branch b1
  $ hg ci -m2
  $ hg branch default
  abort: a branch of the same name already exists (use 'hg update' to switch to it)
  $ hg branch --force default
  marked working directory as branch default
  $ hg ci -m3
  created new head
  $ hg glog --template "{rev}, {branch}\n"
  @  2, default
  |
  o  1, b1
  |
  o  0, default

[1] http://mercurial.selenic.com/wiki/GraphlogExtension


More information about the Python-Dev mailing list