Patchwork [17,of,18,V2] clfilter: add mutable filtering

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 4, 2013, 1:04 a.m.
Message ID <be32139cf62483cdf890.1357261460@yamac.lan>
Download mbox | patch
Permalink /patch/386/
State Superseded, archived
Commit aff706b3a21c2cdadb8dba221755fc9aecd2dbee
Headers show

Comments

Pierre-Yves David - Jan. 4, 2013, 1:04 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357088266 -3600
# Node ID be32139cf62483cdf890309c2e7b0439f312dec2
# Parent  1469aa3af5ce05b94f02382f8d04fd43a26e193a
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.
Kevin Bullock - Jan. 7, 2013, 4 p.m.
On Jan 3, 2013, at 7:04 PM, Pierre-Yves David wrote:

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

If this is the more stable set, wouldn't it make sense to start the collaboration with this first? I.e. I'd prefer to see this change (and the necessary prerequisite) before #15, and add 'unserved' into the ordering afterwards.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock
Pierre-Yves David - Jan. 7, 2013, 4:40 p.m.
On Mon, Jan 07, 2013 at 10:00:23AM -0600, Kevin Bullock wrote:
> On Jan 3, 2013, at 7:04 PM, Pierre-Yves David wrote:
> 
> > # HG changeset patch
> > # User Pierre-Yves David <pierre-yves.david at logilab.fr>
> > # Date 1357088266 -3600
> > # Node ID be32139cf62483cdf890309c2e7b0439f312dec2
> > # Parent  1469aa3af5ce05b94f02382f8d04fd43a26e193a
> > 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 disappear.
> 
> If this is the more stable set, wouldn't it make sense to start the collaboration with this first? I.e. I'd prefer to see this change (and the necessary prerequisite) before #15, and add 'unserved' into the ordering afterwards.

After discussion on IRC the current order appears to be the right one.
Kevin Bullock - Jan. 7, 2013, 4:43 p.m.
On Jan 7, 2013, at 10:40 AM, Pierre-Yves David wrote:

> On Mon, Jan 07, 2013 at 10:00:23AM -0600, Kevin Bullock wrote:
>> On Jan 3, 2013, at 7:04 PM, Pierre-Yves David wrote:
>> 
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david at logilab.fr>
>>> # Date 1357088266 -3600
>>> # Node ID be32139cf62483cdf890309c2e7b0439f312dec2
>>> # Parent  1469aa3af5ce05b94f02382f8d04fd43a26e193a
>>> 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 disappear.
>> 
>> If this is the more stable set, wouldn't it make sense to start the collaboration with this first? I.e. I'd prefer to see this change (and the necessary prerequisite) before #15, and add 'unserved' into the ordering afterwards.
> 
> After discussion on IRC the current order appears to be the right one.

Yes, because it restores the situation prior to 47f00b0de337, where the filtered branchcache will fall back to using the unfiltered if the sets are equal.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock

Patch

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