3

I've always used the named branches feature of mercurial to work with branches, and I'm quite happy with it. I've read about the bookmarks fature of mercurial, although haven't used it yet. The only reason for using bookmarks that I can see is if one prefers the git-style branching model, which I don't.

So, are there use cases for mixing named branches and bookmarks for the same repository? Does it even make sense?

daniel kullmann
  • 13,653
  • 8
  • 51
  • 67

2 Answers2

2

One possible scenario for a mixed usage is detailed in this thread

when we saw bookmarks improvements (push/pull bookmarks on remote repo and track current behaviour activated by default), we decided to use:

  • named branches for main versions only (less than 10 long term branches) and
  • use bookmarks for our one branch per feature strategy.

However some limitations on bookmark limitations made using bookmarks concurrently awkward/buggy.
Situation might be better in the latest 1.9+/2.x+ Mercurial versions, so tests are in order.
1.9 version did fix a lot of bugs/limitations regarding bookmarks.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

It does make sense. If you think about it--named branches are essentially tags which replicate themselves in every child commit. So you can end up with two different heads (tips) under the same named branch:

@  changeset:   3:fe8f1a13eb95
|  branch:      b1
|  tag:         tip
|  parent:      1:33674427026e
|  user:        ...
|  date:        ...
|  summary:     Third commit on branch b1
|
| o  changeset:   2:0ad872ebd9b9
|/   branch:      b1
|    user:        ...
|    date:        ...
|    summary:     Second commit on branch b1
|
o  changeset:   1:33674427026e
|  branch:      b1
|  user:        ...
|  date:        ...
|  summary:     First commit on branch b1
|
o  changeset:   0:18c33e4b94ed
   user:        ...
   date:        ...
   summary:     First commit

Which seems a little counter-intuitive. On the other hand, bookmarks are like tags which move from parent commit to child commit. They are guaranteed to be on only one head. If you try to reproduce the above commit graph with a bookmark named b1, the changeset # 3 will not get the bookmark name--it will be anonymous:

@  changeset:   3:c4dd0b7f9844
|  tag:         tip
|  parent:      1:0c00681b3cfa
|  user:        ...
|  date:        ...
|  summary:     Third commit (on bookmark b1 or...?)
|
| o  changeset:   2:f4e700efd4a6
|/   bookmark:    b1
|    user:        ...
|    date:        ...
|    summary:     Second commit on bookmark b1
|
o  changeset:   1:0c00681b3cfa
|  user:        ...
|  date:        ...
|  summary:     First commit on bookmark b1
|
o  changeset:   0:f2cc94a68cf0
   user:        ...
   date:        ...
   summary:     First commit

Which meshes a bit more, in my opinion, with what a branch should be--a single line of development.

Now, to answer your question about use cases: given the above, you would want to use bookmarks in a repo where you're already using named branches when ... you have multiple heads in the named branch and want to name those.

Yawar
  • 11,272
  • 4
  • 48
  • 80