[PATCH 4 of 6 v8] discovery: convert legacy part of checkheads to revs from nodes

Joshua Redstone joshua.redstone at fb.com
Tue Jun 19 15:21:17 CDT 2012


# HG changeset patch
# User Joshua Redstone <joshua.redstone at fb.com>
# Date 1339190611 25200
# Node ID 5404ca79c3b310e3f2ee79960676e7a8c610e7d7
# Parent  360c7136e67a6843f2cc53b6a2eba33ac8d84fa2
discovery: convert legacy part of checkheads to revs from nodes

After a recent switch from revlog.reachable to revlog.ancestors,
clean up this old call site, switching it from nodes to revs.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -207,19 +207,18 @@
         # 1-4b. old servers: Check for new topological heads.
         # Construct {old,new}map with branch = None (topological branch).
         # (code based on _updatebranchcache)
-        oldheads = set(h for h in remoteheads if h in cl.nodemap)
-        newheads = oldheads.union(outgoing.missing)
-        if len(newheads) > 1:
-            for latest in reversed(outgoing.missing):
-                if latest not in newheads:
+        oldheadrevs = set(cl.rev(h) for h in remoteheads if h in cl.nodemap)
+        missingrevs = [cl.rev(node) for node in outgoing.missing]
+        newheadrevs = oldheadrevs.union(missingrevs)
+        if len(newheadrevs) > 1:
+            for latest in sorted(missingrevs, reverse=True):
+                if latest not in newheadrevs:
                     continue
-                minhrev = min(cl.rev(h) for h in newheads)
-                reachable = [cl.node(rev) for rev in
-                             cl.ancestors([cl.rev(latest)], minhrev)]
-                newheads.difference_update(reachable)
+                reachable = cl.ancestors([latest], min(newheadrevs))
+                newheadrevs.difference_update(reachable)
         branches = set([None])
-        newmap = {None: newheads}
-        oldmap = {None: oldheads}
+        newmap = {None: [cl.node(rev) for rev in newheadrevs]}
+        oldmap = {None: [cl.node(rev) for rev in oldheadrevs]}
         unsynced = inc and branches or set()
 
     # 5. Check for new heads.
diff --git a/tests/test-treediscovery-legacy.t b/tests/test-treediscovery-legacy.t
--- a/tests/test-treediscovery-legacy.t
+++ b/tests/test-treediscovery-legacy.t
@@ -15,6 +15,13 @@
   $ cp $HGRCPATH $HGRCPATH-nocap
   $ cp $HGRCPATH-withcap $HGRCPATH
 
+Prep for test server without branchmap support
+
+  $ CAP="branchmap"
+  $ . "$TESTDIR/notcapable"
+  $ cp $HGRCPATH $HGRCPATH-nocap-branchmap
+  $ cp $HGRCPATH-withcap $HGRCPATH
+
 Setup HTTP server control:
 
   $ remote=http://localhost:$HGPORT/
@@ -314,3 +321,51 @@
 
   $ tstop
 
+Exercise pushing to server without branchmap capability
+
+  $ cp $HGRCPATH-nocap-branchmap $HGRCPATH-nocap
+  $ hg init rlocal
+  $ cd rlocal
+  $ echo A > A
+  $ hg ci -Am A
+  adding A
+  $ cd ..
+  $ hg clone rlocal rremote  
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd rlocal
+  $ echo B > B
+  $ hg ci -Am B
+  adding B
+  $ cd ..
+  $ tstart rremote
+
+  $ cd rlocal
+  $ hg incoming $remote 
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  [1]
+  $ hg outgoing $remote
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  1 27547f69f254: B 
+  $ hg pull $remote
+  pulling from http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  $ hg push $remote
+  pushing to http://localhost:$HGPORT/
+  searching for changes
+  remote: adding changesets
+  remote: adding manifests
+  remote: adding file changes
+  remote: added 1 changesets with 1 changes to 1 files
+  $ hg outgoing $remote
+  comparing with http://localhost:$HGPORT/
+  searching for changes
+  no changes found
+  [1]
+  $ cd ..
+
+  $ tstop


More information about the Mercurial-devel mailing list