Patchwork [4,of,7,V4] clfilter: use filtering in `visiblebranchmap`

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 20, 2012, 4:23 p.m.
Message ID <f04dd8c07b2429876569.1356020623@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/216/
State Accepted
Commit 83cb1a1a705d54f00d051faffea9c9969f48546c
Headers show

Comments

Pierre-Yves David - Dec. 20, 2012, 4:23 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1355762554 -3600
# Node ID f04dd8c07b2429876569eab9136160d5c9c98bd2
# Parent  92ce40f2bb8a27653c52d2aa43333b9f0c0b19ea
clfilter: use filtering in `visiblebranchmap`

Here is the first real use of changelog filtering. The change is very small to
allow testing the new filter with a setup close to the original one.

We replace custom post processing on branchmap function by call to the
standard code pass on a filtering repo.

In later coming will have wider usage of filtering that will make the dedicated
function useless.

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -353,25 +353,6 @@  def visibleheads(repo):
     return vheads
 
 
 def visiblebranchmap(repo):
     """return a branchmap for the visible set"""
-    # XXX Recomputing this data on the fly is very slow.  We should build a
-    # XXX cached version while computing the standard branchmap version.
-    sroots = repo._phasecache.phaseroots[phases.secret]
-    if sroots or repo.obsstore:
-        vbranchmap = {}
-        for branch, nodes in  repo.branchmap().iteritems():
-            # search for secret heads.
-            for n in nodes:
-                if repo[n].phase() >= phases.secret:
-                    nodes = None
-                    break
-            # if secret heads were found we must compute them again
-            if nodes is None:
-                s = repo.set('heads(branch(%s) - secret() - extinct())',
-                             branch)
-                nodes = [c.node() for c in s]
-            vbranchmap[branch] = nodes
-    else:
-        vbranchmap = repo.branchmap()
-    return vbranchmap
+    return repo.filtered('unserved').branchmap()