[PATCH] branch heads: fix regression introduced in e67e5b60e55f (issue1726)

Henrik Stuart hg at hstuart.dk
Thu Jul 9 14:16:39 CDT 2009


# HG changeset patch
# User Henrik Stuart <hg at hstuart.dk>
# Date 1247165342 -7200
# Node ID 0b2b269ba3d03fc155363b101ca2295bbd79d64a
# Parent  8ec39725d966a4f2dc0bf308d582c26264d85819
branch heads: fix regression introduced in e67e5b60e55f (issue1726)

For merge nodes it is not adequate to only check a single possible
branch head for whether it is an ancestor of the latest head, but it
needs to be done for each possible branch head.

diff -r 8ec39725d966 -r 0b2b269ba3d0 mercurial/localrepo.py
--- a/mercurial/localrepo.py	Thu Jul 09 11:59:18 2009 +0200
+++ b/mercurial/localrepo.py	Thu Jul 09 20:49:02 2009 +0200
@@ -473,7 +473,9 @@
                 latest = newnodes.pop()
                 if latest not in bheads:
                     continue
-                reachable = self.changelog.reachable(latest, bheads[0])
+                reachable = set()
+                for bh in bheads:
+                    reachable |= self.changelog.reachable(latest, bh)
                 bheads = [b for b in bheads if b not in reachable]
                 newbheads.insert(0, latest)
             bheads.extend(newbheads)
diff -r 8ec39725d966 -r 0b2b269ba3d0 tests/test-fetch
--- a/tests/test-fetch	Thu Jul 09 11:59:18 2009 +0200
+++ b/tests/test-fetch	Thu Jul 09 20:49:02 2009 +0200
@@ -185,6 +185,18 @@
 hg --cwd ib2 fetch ../ib1
 rm -fr ib1 ib2
 
+echo % test issue1726
+hg init i1726r1
+echo a > i1726r1/a
+hg --cwd i1726r1 ci -Am base
+hg clone i1726r1 i1726r2
+echo b > i1726r1/a
+hg --cwd i1726r1 ci -m second
+echo c > i1726r2/a
+hg --cwd i1726r2 ci -m third
+HGMERGE=true hg --cwd i1726r2 fetch ../i1726r1 | sed 's/new changeset 3:[0-9a-zA-Z]\+/new changeset 3/'
+hg --cwd i1726r2 heads default --template '{rev}\n'
+
 "$TESTDIR/killdaemons.py"
 
 true
diff -r 8ec39725d966 -r 0b2b269ba3d0 tests/test-fetch.out
--- a/tests/test-fetch.out	Thu Jul 09 11:59:18 2009 +0200
+++ b/tests/test-fetch.out	Thu Jul 09 20:49:02 2009 +0200
@@ -190,3 +190,20 @@
 pulling from ../ib1
 searching for changes
 no changes found
+% test issue1726
+adding a
+updating working directory
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+pulling from ../i1726r1
+searching for changes
+adding changesets
+adding manifests
+adding file changes
+added 1 changesets with 1 changes to 1 files (+1 heads)
+updating to 2:7837755a2789
+1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+merging with 1:d1f0c6c48ebd
+merging a
+0 files updated, 1 files merged, 0 files removed, 0 files unresolved
+new changeset 3 merges remote changes with local
+3


More information about the Mercurial-devel mailing list