[PATCH 15 of 16] clfilter: add mutable filtering

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Jan 1 19:09:37 CST 2013


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357088266 -3600
# Node ID bc5205911d9df872bccea16fad14e4c86a6ba220
# Parent  e9e434fedd7a880122a0b09975ff9d0735a21b35
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.

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -6,10 +6,11 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
 import copy
 import phases
+import util
 
 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."""
@@ -17,19 +18,31 @@ def computeunserved(repo):
     # fast path in simple case to avoid impact of non optimised code
     if phases.hassecret(repo) or repo.obsstore:
         return frozenset(repo.revs('hidden() + secret()'))
     return frozenset()
 
-# Function to compute filtered set
-filtertable = {'unserved': computeunserved}
+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 = {'unserved': computeunserved,
+               'mutable':  computemutable}
 ### 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: 'unserved',
+               'unserved': 'mutable'}
 
 def filteredrevs(repo, filtername):
     """returns set of filtered revision for this filter name"""
     if filtername not in repo.filteredrevcache:
         func = filtertable[filtername]
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -339,10 +339,11 @@ fred is allowed inside foo/
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -410,10 +411,11 @@ Empty [acl.deny]
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -478,10 +480,11 @@ fred is allowed inside foo/, but not foo
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -551,10 +554,11 @@ fred is allowed inside foo/, but not foo
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -621,10 +625,11 @@ fred is allowed inside foo/, but not foo
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -693,10 +698,11 @@ barney is allowed everywhere
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -851,10 +857,11 @@ file specified by acl.config does not ex
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -890,11 +897,11 @@ file specified by acl.config does not ex
   calling hook pretxnchangegroup.acl: hgext.acl.hook
   acl: checking access for user "barney"
   error: pretxnchangegroup.acl hook raised an exception: [Errno *] *: '../acl.config' (glob)
   transaction abort!
   rollback completed
-  abort: *: ../acl.config (glob)
+  abort: No such file or directory: ../acl.config
   no rollback information available
   0:6675d58eff77
   
 
 betty is allowed inside foo/ by a acl.config file
@@ -925,10 +932,11 @@ betty is allowed inside foo/ by a acl.co
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1010,10 +1018,11 @@ acl.config can set only [acl.allow]/[acl
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
@@ -1241,10 +1250,11 @@ OS-level groups
   """
   pushing to ../b
   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:
   ef1ea85a6374b77d6da9dcda9541f498f2d17df7
   f9cafe1212c8c6fa1120d14a556e18cc44ff8bdd
diff --git a/tests/test-inherit-mode.t b/tests/test-inherit-mode.t
--- a/tests/test-inherit-mode.t
+++ b/tests/test-inherit-mode.t
@@ -109,11 +109,11 @@ group can still write everything
 
   $ python ../printmodes.py ../push
   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
   00660 ../push/.hg/store/00manifest.i
   00770 ../push/.hg/store/data/
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -746,12 +746,14 @@ Interrupted commit should not change sta
 
 Commit with multi-line message and custom expansion
 
   $ hg --debug commit -l log -d '2 0' -u 'User Name <user at 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
 
 Stat, verify and show custom expansion (firstline)
diff --git a/tests/test-newbranch.t b/tests/test-newbranch.t
--- a/tests/test-newbranch.t
+++ b/tests/test-newbranch.t
@@ -174,20 +174,20 @@ Push should update the branch cache:
 Pushing just rev 0:
 
   $ hg push -qr 0 ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-unserved ===
+  === .hg/cache/branchheads-mutable ===
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 default
 
 Pushing everything:
 
   $ hg push -qf ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-unserved ===
+  === .hg/cache/branchheads-mutable ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
   1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo
   c21617b13b220988e7a2e26290fbe4325ffa7139 bar
 


More information about the Mercurial-devel mailing list