hg branches issue?
Josef "Jeff" Sipek
jeffpc at josefsipek.net
Sat Nov 4 21:50:51 UTC 2006
I noticed that hg branches can do seemingly odd thing when two commits (one
of them being a head and the other not) on two different branches with the
same branch name (basically one of the branches was renamed at some point in
time) the one that is not head may be associated with the branch name.
This probably explains it a bit better...
jeffpc at batlh:/tmp/hg$ hg init a
jeffpc at batlh:/tmp/hg$ cd a/
jeffpc at batlh:/tmp/hg/a$ hg branch master
jeffpc at batlh:/tmp/hg/a$ echo abc > file1
jeffpc at batlh:/tmp/hg/a$ hg commit -A -m "initial"
adding file1
jeffpc at batlh:/tmp/hg/a$ cd ..
jeffpc at batlh:/tmp/hg$ hg clone a/ b
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
jeffpc at batlh:/tmp/hg$ cd b/
jeffpc at batlh:/tmp/hg/b$ echo abcdef > file2
jeffpc at batlh:/tmp/hg/b$ hg commit -A -m "some stuff on test branch"
adding file2
jeffpc at batlh:/tmp/hg/b$ # this looks promissing..
jeffpc at batlh:/tmp/hg/b$ hg branch devel # rename the branch
jeffpc at batlh:/tmp/hg/b$ echo def > file3
jeffpc at batlh:/tmp/hg/b$ hg commit -A -m "some more stuff on test branch"
adding file3
jeffpc at batlh:/tmp/hg/b$ cd ../a/
jeffpc at batlh:/tmp/hg/a$ # meanwhile on the master..
jeffpc at batlh:/tmp/hg/a$ echo qwerty > file4
jeffpc at batlh:/tmp/hg/a$ hg commit -A -m "fix some badness"
adding file4
jeffpc at batlh:/tmp/hg/a$ # we should have both master and devel in one tree!
jeffpc at batlh:/tmp/hg/a$ hg pull -r devel ../b
pulling from ../b
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)
jeffpc at batlh:/tmp/hg/a$ hg update -C
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
jeffpc at batlh:/tmp/hg/a$ hg branches
devel 3:38f3320fb04f
master 2:b86cb8497c25
jeffpc at batlh:/tmp/hg/a$ hg heads
changeset: 3:38f3320fb04f
branch: devel
tag: tip
user: Josef "Jeff" Sipek <jeffpc at josefsipek.net>
date: Sat Nov 04 15:57:17 2006 -0500
summary: some more stuff on test branch
changeset: 1:d909dbd326d7
branch: master
user: Josef "Jeff" Sipek <jeffpc at josefsipek.net>
date: Sat Nov 04 15:57:59 2006 -0500
summary: fix some badness
# Note that the head for master is rev=1, while hg branches says 2!
# and here's full log just for fun
jeffpc at batlh:/tmp/hg/a$ hg log
changeset: 3:38f3320fb04f
branch: devel
tag: tip
user: Josef "Jeff" Sipek <jeffpc at josefsipek.net>
date: Sat Nov 04 15:57:17 2006 -0500
summary: some more stuff on test branch
changeset: 2:b86cb8497c25
branch: master
parent: 0:c071854c3fb1
user: Josef "Jeff" Sipek <jeffpc at josefsipek.net>
date: Sat Nov 04 15:50:31 2006 -0500
summary: some stuff on test branch
changeset: 1:d909dbd326d7
branch: master
user: Josef "Jeff" Sipek <jeffpc at josefsipek.net>
date: Sat Nov 04 15:57:59 2006 -0500
summary: fix some badness
changeset: 0:c071854c3fb1
branch: master
user: Josef "Jeff" Sipek <jeffpc at josefsipek.net>
date: Sat Nov 04 15:50:06 2006 -0500
summary: initial
I mentioned this on IRC, and tonfa made this patch to fix this issue (if you
consider it an issue - I do.)
diff -r 1d2fdea875bc mercurial/localrepo.py
--- a/mercurial/localrepo.py Thu Nov 02 19:23:55 2006 +0100
+++ b/mercurial/localrepo.py Sat Nov 04 22:32:47 2006 +0100
@@ -348,10 +348,13 @@ class localrepository(repo.repository):
pass
def _updatebranchcache(self, partial, start, end):
+ heads = dict.fromkeys(self.heads())
for r in xrange(start, end):
c = self.changectx(r)
b = c.branch()
if b:
+ if partial.get(b) in heads and c.node() not in heads:
+ continue # old node was a head and new node isn't
partial[b] = c.node()
def lookup(self, key):
Josef "Jeff" Sipek.
--
Failure is not an option,
It comes bundled with your Microsoft product.
More information about the Mercurial-devel
mailing list