# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 2012-07-16 23:04:45
# Node ID 4feb55e6931f634e9b910514b8e64ca66193e69b
# Parent  0cb55b5c19a347a0d6154cd30b9f4d416b432ffe

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 @@ def checkheads(repo, remote, outgoing, r
         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 @@ class localpeer(peer.peerrepository):
         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 @@ def findcommonheads(ui, local, remote,
     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()