Patchwork [16,of,16] clfilter: add impactable filter

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 2, 2013, 1:09 a.m.
Message ID <98bc5a269d5e792d63dc.1357088978@yamac.lan>
Download mbox | patch
Permalink /patch/361/
State Superseded, archived
Commit 58ca19edc043056248ce896e81f414566500f320
Headers show

Comments

Pierre-Yves David - Jan. 2, 2013, 1:09 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1357088561 -3600
# Node ID 98bc5a269d5e792d63dcf74af4efec25d104c343
# Parent  bc5205911d9df872bccea16fad14e4c86a6ba220
clfilter: add impactable filter

The `mutable` filter still have some chance to get invalidated. This will happen
when:

- you garbage collect hidden changeset,
- public phase is moved backward,
- something is changed in the filtering (this could be fixed)

So we introduce an even more stable filtering set: everything with a revision
number egal or higher than the first mutable changeset is filtered.

The only official use of this filter is for branchcache.

Patch

diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -28,21 +28,46 @@  def computemutable(repo):
     # fast check to avoid revset call on huge repo
     if util.any(repo._phasecache.phaseroots[1:]):
         return frozenset(repo.revs('draft() + secret()'))
     return frozenset()
 
+def computeimpactable(repo):
+    """Everything impactable by mutable revision
+
+    The mutable filter still have some chance to get invalidated. This will
+    happen when:
+
+    - you garbage collect hidden changeset,
+    - public phase is moved backward,
+    - something is changed in the filtering (this could be fixed)
+
+    This filter out any mutable changeset and any public changeset that may be
+    impacted by something happening to a mutable revision.
+
+    This is achieved by filtered everything with a revision number egal or
+    higher than the first mutable changeset is filtered."""
+    assert not repo.changelog.filteredrevs
+    cl = repo.changelog
+    firstmutable = len(cl)
+    for roots in repo._phasecache.phaseroots[1:]:
+        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,
-               'mutable':  computemutable}
+               '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',
-               'unserved': 'mutable'}
+               'unserved': 'mutable',
+               'mutable': 'impactable'}
 
 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-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-mutable
+  00660 ../push/.hg/cache/branchheads-impactable
   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-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-mutable ===
+  === .hg/cache/branchheads-impactable ===
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 default
 
 Pushing everything:
 
   $ hg push -qf ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-mutable ===
+  === .hg/cache/branchheads-impactable ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
   1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo
   c21617b13b220988e7a2e26290fbe4325ffa7139 bar