Patchwork [1,of,7,Series-A] clfilter: introduces a hidden filter

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 7, 2013, 6:30 p.m.
Message ID <8487569146e69cad68ec.1357583433@crater2.logilab.fr>
Download mbox | patch
Permalink /patch/489/
State Accepted
Commit e4687edec014cbc0cff47c178bb41560886f70b0
Headers show

Comments

Pierre-Yves David - Jan. 7, 2013, 6:30 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357583046 -3600
# Node ID 8487569146e69cad68ec11e8d8a6f677424fb26f
# Parent  ad7cda74337100d933cb7e7902c59117f990c270
clfilter: introduces a hidden filter

This filter exclude all hidden revision. We plan to use this filter to hide
revision instead of manually checking contents of the hidden revisions set.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -8,10 +8,20 @@ 
 
 import copy
 import phases
 import util
 
+
+def computehidden(repo):
+    """compute the set of hidden revision to filter
+
+    During most operation hidden should be filtered."""
+    assert not repo.changelog.filteredrevs
+    if repo.obsstore:
+        return frozenset(repo.revs('hidden()'))
+    return frozenset()
+
 def computeunserved(repo):
     """compute the set of revision that should be filtered when used a server
 
     Secret and hidden changeset should not pretend to be here."""
     assert not repo.changelog.filteredrevs
@@ -52,20 +62,22 @@  def computeimpactable(repo):
         if roots:
             firstmutable = min(firstmutable, min(cl.rev(r) for r in roots))
     return frozenset(xrange(firstmutable, len(cl)))
 
 # function to compute filtered set
-filtertable = {'unserved': computeunserved,
+filtertable = {'hidden': computehidden,
+               'unserved': computeunserved,
                'mutable':  computemutable,
                'impactable':  computeimpactable}
 ### Nearest subset relation
 # Nearest subset of filter X is a filter Y so that:
 # * Y is included in X,
 # * X - Y is as small as possible.
 # This create and ordering used for branchmap purpose.
 # the ordering may be partial
-subsettable = {None: 'unserved',
+subsettable = {None: 'hidden',
+               'hidden': 'unserved',
                'unserved': 'mutable',
                'mutable': 'impactable'}
 
 def filteredrevs(repo, filtername):
     """returns set of filtered revision for this filter name"""
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -174,13 +174,13 @@  visible shared between the initial repo 
 :note: The "(+1 heads)" is wrong as we do not had any visible head
 
 check that branch cache with "unserved" filter are properly computed and stored
 
   $ ls ../push-dest/.hg/cache/branchheads*
-  ../push-dest/.hg/cache/branchheads
+  ../push-dest/.hg/cache/branchheads-hidden
   ../push-dest/.hg/cache/branchheads-unserved
-  $ cat ../push-dest/.hg/cache/branchheads
+  $ cat ../push-dest/.hg/cache/branchheads-hidden
   6d6770faffce199f1fddd1cf87f6f026138cf061 6
   b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
   2713879da13d6eea1ff22b442a5a87cb31a7ce6a default
   6d6770faffce199f1fddd1cf87f6f026138cf061 default
   $ cat ../push-dest/.hg/cache/branchheads-unserved