[PATCH 01 of 11 full-series] localpeer: return only visible heads and branchmap

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Jul 17 22:15:48 CDT 2012


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1342479885 -7200
# Node ID 6cdeff8f1b48a731d7ea1d71487c4be70f9dd731
# Parent  afd75476939e0a229816e6683607fbe5ab222c11
localpeer: return only visible heads and branchmap

Now that we have localpeer, we can apply filtering on heads and branchmap the
same way it's done for wireprotocol peer.

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -168,10 +168,7 @@
         branches = set(repo[n].branch() for n in outgoing.missing)
 
         # 2. Check for new branches on the remote.
-        if remote.local():
-            remotemap = phases.visiblebranchmap(remote.local())
-        else:
-            remotemap = remote.branchmap()
+        remotemap = remote.branchmap()
         newbranches = branches - set(remotemap)
         if newbranches and not newbranch: # new branch requires --new-branch
             branchnames = ', '.join(sorted(newbranches))
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -56,10 +56,10 @@
         return self._repo.lookup(key)
 
     def branchmap(self):
-        return self._repo.branchmap()
+        return phases.visiblebranchmap(self._repo)
 
     def heads(self):
-        return self._repo.heads()
+        return phases.visibleheads(self._repo)
 
     def known(self, nodes):
         return self._repo.known(nodes)
diff --git a/mercurial/setdiscovery.py b/mercurial/setdiscovery.py
--- a/mercurial/setdiscovery.py
+++ b/mercurial/setdiscovery.py
@@ -9,7 +9,6 @@
 from node import nullid
 from i18n import _
 import random, util, dagutil
-import phases
 
 def _updatesample(dag, nodes, sample, always, quicksamplesize=0):
     # if nodes is empty we scan the entire graph
@@ -100,7 +99,7 @@
     sample = ownheads
     if remote.local():
         # stopgap until we have a proper localpeer that supports batch()
-        srvheadhashes = phases.visibleheads(remote.local())
+        srvheadhashes = remote.heads()
         yesno = remote.known(dag.externalizeall(sample))
     elif remote.capable('batch'):
         batch = remote.batch()


More information about the Mercurial-devel mailing list