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.
--- a/mercurial/discovery.py Fri Jun 08 14:21:32 2012 -0700
+++ b/mercurial/discovery.py Fri Jun 08 14:23:31 2012 -0700
@@ -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.
--- a/tests/test-treediscovery-legacy.t Fri Jun 08 14:21:32 2012 -0700
+++ b/tests/test-treediscovery-legacy.t Fri Jun 08 14:23:31 2012 -0700
@@ -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