Patchwork [question,with,example] help: branch names primarily denote the tipmost unclosed branch head

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 18, 2013, 10:40 p.m.
Message ID <8d8277b46989bd4784bb.1384814405@localhost.localdomain>
Download mbox | patch
Permalink /patch/3061/
State Superseded
Headers show

Comments

Mads Kiilerich - Nov. 18, 2013, 10:40 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1384814307 18000
#      Mon Nov 18 17:38:27 2013 -0500
# Node ID 8d8277b46989bd4784bb996c139605e1d856ea1f
# Parent  08fffc33af47f3f47647fd5df6d8d76f71d7f38d
help: branch names primarily denote the tipmost unclosed branch head

Was the behavior correct and the description wrong so it should be updated as
in this patch? Or should the code work as the documentation says?

Both ways could make some sense ... but none of them are obvious in all cases.

One place where it currently cause problems is when the current revision has
another branch head that is closer to tip but closed. 'hg rebase' refuses to
rebase to that as it only see the tip-most unclosed branch head which is the
current revision.

/me kind of likes named branches, but no so much how branch closing works ...

Patch

diff --git a/mercurial/help/revisions.txt b/mercurial/help/revisions.txt
--- a/mercurial/help/revisions.txt
+++ b/mercurial/help/revisions.txt
@@ -14,9 +14,9 @@  of exactly one full-length identifier.
 
 Any other string is treated as a bookmark, tag, or branch name. A
 bookmark is a movable pointer to a revision. A tag is a permanent name
-associated with a revision. A branch name denotes the tipmost revision
-of that branch. Bookmark, tag, and branch names must not contain the ":"
-character.
+associated with a revision. A branch name denotes the tipmost open branch head
+of that branch - or the tipmost closed branch head if they are all closed.
+Bookmark, tag, and branch names must not contain the ":" character.
 
 The reserved name "tip" always identifies the most recent revision.
 
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -650,13 +650,14 @@  class localrepository(object):
         return sorted(marks)
 
     def branchmap(self):
-        '''returns a dictionary {branch: [branchheads]}'''
+        '''returns a dictionary {branch: [branchheads]} with branchheads
+        ordered by increasing revision number'''
         branchmap.updatecache(self)
         return self._branchcaches[self.filtername]
 
-
     def _branchtip(self, heads):
-        '''return the tipmost branch head in heads'''
+        '''return the tipmost open branch head in heads, falling back to the
+        tipmost closed branch head'''
         tip = heads[-1]
         for h in reversed(heads):
             if not self[h].closesbranch():