changeset 18245:aff706b3a21c

clfilter: add mutable filtering It filters all mutable changesets, leaving only public changeset unfiltered. This filtering set is expected to be much more stable that the previous one as public changeset are unlikely to disapear. The only official use of this filter is for branchcache.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 02 Jan 2013 01:57:46 +0100
parents 5a3c71b0e042
children 58ca19edc043
files mercurial/repoview.py tests/test-acl.t tests/test-inherit-mode.t tests/test-keyword.t tests/test-newbranch.t
diffstat 5 files changed, 30 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/repoview.py	Mon Jan 07 02:14:41 2013 +0100
+++ b/mercurial/repoview.py	Wed Jan 02 01:57:46 2013 +0100
@@ -8,6 +8,7 @@
 
 import copy
 import phases
+import util
 
 
 def computehidden(repo):
@@ -29,9 +30,20 @@
         return frozenset(repo.revs('hidden() + secret()'))
     return frozenset()
 
+def computemutable(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
+    # fast check to avoid revset call on huge repo
+    if util.any(repo._phasecache.phaseroots[1:]):
+        return frozenset(repo.revs('draft() + secret()'))
+    return frozenset()
+
 # function to compute filtered set
 filtertable = {'hidden': computehidden,
-               'unserved': computeunserved}
+               'unserved': computeunserved,
+               'mutable':  computemutable}
 ### Nearest subset relation
 # Nearest subset of filter X is a filter Y so that:
 # * Y is included in X,
@@ -39,7 +51,8 @@
 # This create and ordering used for branchmap purpose.
 # the ordering may be partial
 subsettable = {None: 'hidden',
-               'hidden': 'unserved'}
+               'hidden': 'unserved',
+               'unserved': 'mutable'}
 
 def filteredrevs(repo, filtername):
     """returns set of filtered revision for this filter name"""
--- a/tests/test-acl.t	Mon Jan 07 02:14:41 2013 +0100
+++ b/tests/test-acl.t	Wed Jan 02 01:57:46 2013 +0100
@@ -341,6 +341,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -412,6 +413,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -480,6 +482,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -553,6 +556,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -623,6 +627,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -695,6 +700,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -853,6 +859,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -927,6 +934,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1012,6 +1020,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1243,6 +1252,7 @@
   query 1; heads
   searching for changes
   all remote heads known locally
+  invalid branchheads cache (unserved): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
--- a/tests/test-inherit-mode.t	Mon Jan 07 02:14:41 2013 +0100
+++ b/tests/test-inherit-mode.t	Wed Jan 02 01:57:46 2013 +0100
@@ -111,7 +111,7 @@
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
   00770 ../push/.hg/cache/
-  00660 ../push/.hg/cache/branchheads-unserved
+  00660 ../push/.hg/cache/branchheads-mutable
   00660 ../push/.hg/requires
   00770 ../push/.hg/store/
   00660 ../push/.hg/store/00changelog.i
--- a/tests/test-keyword.t	Mon Jan 07 02:14:41 2013 +0100
+++ b/tests/test-keyword.t	Wed Jan 02 01:57:46 2013 +0100
@@ -748,8 +748,10 @@
 
   $ hg --debug commit -l log -d '2 0' -u 'User Name <user@example.com>'
   invalid branchheads cache: tip differs
+  invalid branchheads cache (unserved): tip differs
   a
   invalid branchheads cache: tip differs
+  invalid branchheads cache (unserved): tip differs
   overwriting a expanding keywords
   committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
   $ rm log
--- a/tests/test-newbranch.t	Mon Jan 07 02:14:41 2013 +0100
+++ b/tests/test-newbranch.t	Wed Jan 02 01:57:46 2013 +0100
@@ -176,7 +176,7 @@
   $ hg push -qr 0 ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-unserved ===
+  === .hg/cache/branchheads-mutable ===
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 default
 
@@ -185,7 +185,7 @@
   $ hg push -qf ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-unserved ===
+  === .hg/cache/branchheads-mutable ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
   1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo