changeset 15697:21eb048edc19

phases: add a function to compute visible heads This function will be used to hide secret changeset.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Mon, 19 Dec 2011 11:37:44 +0100
parents 0cb45fef99ba
children 1facaad963a8 9c4adcb785ee
files mercurial/phases.py
diffstat 1 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/phases.py	Sun Dec 18 23:16:46 2011 +0100
+++ b/mercurial/phases.py	Mon Dec 19 11:37:44 2011 +0100
@@ -236,6 +236,21 @@
     finally:
         lock.release()
 
+def visibleheads(repo):
+    """return the set of visible head of this repo"""
+    # XXX we want a cache on this
+    sroots = repo._phaseroots[2]
+    if sroots:
+        # XXX very slow revset. storing heads or secret "boundary" would help.
+        revset = repo.set('heads(not (%ln::))', sroots)
+
+        vheads = [ctx.node() for ctx in revset]
+        if not vheads:
+            vheads.append(nullid)
+    else:
+        vheads = repo.heads()
+    return vheads
+
 def analyzeremotephases(repo, subset, roots):
     """Compute phases heads and root in a subset of node from root dict