[PATCH RFC] filtering: rename filters to their antonyms

Kevin Bullock kbullock+mercurial at ringworld.org
Sun Jan 13 13:48:53 CST 2013


# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1358062756 21600
# Node ID 2e93234688c3921031981b1107d0769e15c81406
# Parent  948f495fb2302a6241787a2d5924ef328f2f4967
filtering: rename filters to their antonyms

Now that changelog filtering is in place, it's become evident that
naming the filters according to the set of revs _not_ included in the
filtered changelog is confusing. This is especially evident in the
collaborative branch cache scheme.

This changes the names of the filters to reflect the revs that _are_
included:

  hidden -> visible
  unserved -> served
  mutable -> immutable
  impactable -> nonvolatile

repoview.filteredrevs is renamed to filterrevs, so that callers read a
bit more sensibly, e.g.:

  filterrevs('visible') # filter revs according to what's visible

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -212,7 +212,7 @@ class changectx(object):
     def mutable(self):
         return self.phase() > phases.public
     def hidden(self):
-        return self._rev in repoview.filteredrevs(self._repo, 'hidden')
+        return self._rev in repoview.filterrevs(self._repo, 'visible')
 
     def parents(self):
         """return contexts for each parent changeset"""
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -115,7 +115,7 @@ def findcommonoutgoing(repo, other, only
         og.missingheads = onlyheads or repo.heads()
     elif onlyheads is None:
         # use visible heads as it should be cached
-        og.missingheads = repo.filtered("unserved").heads()
+        og.missingheads = repo.filtered("served").heads()
         og.excluded = [ctx.node() for ctx in repo.set('secret() or extinct()')]
     else:
         # compute common, missing and exclude secret stuff
diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -113,7 +113,7 @@ def repository(ui, path='', create=False
     if not repo:
         raise util.Abort(_("repository '%s' is not local") %
                          (path or peer.url()))
-    return repo.filtered('hidden')
+    return repo.filtered('visible')
 
 def peer(uiorrepo, opts, path, create=False):
     '''return a repository peer for the specified path'''
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -66,7 +66,7 @@ class localpeer(peer.peerrepository):
 
     def __init__(self, repo, caps=MODERNCAPS):
         peer.peerrepository.__init__(self)
-        self._repo = repo.filtered('unserved')
+        self._repo = repo.filtered('served')
         self.ui = repo.ui
         self._caps = repo._restrictcapabilities(caps)
         self.requirements = repo.requirements
diff --git a/mercurial/repoview.py b/mercurial/repoview.py
--- a/mercurial/repoview.py
+++ b/mercurial/repoview.py
@@ -44,7 +44,7 @@ def computeunserved(repo):
     Secret and hidden changeset should not pretend to be here."""
     assert not repo.changelog.filteredrevs
     # fast path in simple case to avoid impact of non optimised code
-    hiddens = filteredrevs(repo, 'hidden')
+    hiddens = filterrevs(repo, 'visible')
     if phases.hassecret(repo):
         cl = repo.changelog
         secret = phases.secret
@@ -65,7 +65,7 @@ def computemutable(repo):
     # fast check to avoid revset call on huge repo
     if util.any(repo._phasecache.phaseroots[1:]):
         getphase = repo._phasecache.phase
-        maymutable = filteredrevs(repo, 'impactable')
+        maymutable = filterrevs(repo, 'nonvolatile')
         return frozenset(r for r in maymutable if getphase(repo, r))
     return frozenset()
 
@@ -93,22 +93,22 @@ def computeimpactable(repo):
     return frozenset(xrange(firstmutable, len(cl)))
 
 # function to compute filtered set
-filtertable = {'hidden': computehidden,
-               'unserved': computeunserved,
-               'mutable':  computemutable,
-               'impactable':  computeimpactable}
+filtertable = {'visible': computehidden,
+               'served': computeunserved,
+               'immutable':  computemutable,
+               'nonvolatile':  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: 'hidden',
-               'hidden': 'unserved',
-               'unserved': 'mutable',
-               'mutable': 'impactable'}
+subsettable = {None: 'visible',
+               'visible': 'served',
+               'served': 'immutable',
+               'immutable': 'nonvolatile'}
 
-def filteredrevs(repo, filtername):
+def filterrevs(repo, filtername):
     """returns set of filtered revision for this filter name"""
     if filtername not in repo.filteredrevcache:
         func = filtertable[filtername]
@@ -162,7 +162,7 @@ class repoview(object):
         this changelog must not be used for writing"""
         # some cache may be implemented later
         cl = copy.copy(self._unfilteredrepo.changelog)
-        cl.filteredrevs = filteredrevs(self._unfilteredrepo, self.filtername)
+        cl.filteredrevs = filterrevs(self._unfilteredrepo, self.filtername)
         return cl
 
     def unfiltered(self):
diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -893,7 +893,7 @@ def hidden(repo, subset, x):
     """
     # i18n: "hidden" is a keyword
     getargs(x, 0, 0, _("hidden takes no arguments"))
-    hiddenrevs = repoview.filteredrevs(repo, 'hidden')
+    hiddenrevs = repoview.filterrevs(repo, 'visible')
     return [r for r in subset if r in hiddenrevs]
 
 def keyword(repo, subset, x):
diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -345,7 +345,7 @@ class ooberror(object):
         self.message = message
 
 def dispatch(repo, proto, command):
-    repo = repo.filtered("unserved")
+    repo = repo.filtered("served")
     func, spec = commands[command]
     args = proto.getargs(spec)
     return func(repo, proto, *args)
@@ -362,7 +362,7 @@ def options(cmd, keys, others):
     return opts
 
 def batch(repo, proto, cmds, others):
-    repo = repo.filtered("unserved")
+    repo = repo.filtered("served")
     res = []
     for pair in cmds.split(';'):
         op, args = pair.split(' ', 1)
diff --git a/tests/test-acl.t b/tests/test-acl.t
--- a/tests/test-acl.t
+++ b/tests/test-acl.t
@@ -140,7 +140,7 @@ Extension disabled for lack of acl.sourc
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -202,7 +202,7 @@ No [acl.allow]/[acl.deny]
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -274,7 +274,7 @@ Empty [acl.allow]
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -341,7 +341,7 @@ fred is allowed inside foo/
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -413,7 +413,7 @@ Empty [acl.deny]
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -482,7 +482,7 @@ fred is allowed inside foo/, but not foo
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -556,7 +556,7 @@ fred is allowed inside foo/, but not foo
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -627,7 +627,7 @@ fred is allowed inside foo/, but not foo
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -700,7 +700,7 @@ barney is allowed everywhere
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -779,7 +779,7 @@ wilma can change files with a .txt exten
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -859,7 +859,7 @@ file specified by acl.config does not ex
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -934,7 +934,7 @@ betty is allowed inside foo/ by a acl.co
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1020,7 +1020,7 @@ acl.config can set only [acl.allow]/[acl
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1100,7 +1100,7 @@ fred is always allowed
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1176,7 +1176,7 @@ no one is allowed inside foo/Bar/
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1252,7 +1252,7 @@ OS-level groups
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1329,7 +1329,7 @@ OS-level groups
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   3 changesets found
   list of changesets:
@@ -1527,7 +1527,7 @@ Branch acl deny test
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
@@ -1839,7 +1839,7 @@ push foobar into the remote
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
@@ -1927,7 +1927,7 @@ Branch acl conflicting deny
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
@@ -2083,7 +2083,7 @@ Non-astro users must be denied
   query 1; heads
   searching for changes
   all remote heads known locally
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   listing keys for "bookmarks"
   4 changesets found
   list of changesets:
diff --git a/tests/test-fncache.t b/tests/test-fncache.t
--- a/tests/test-fncache.t
+++ b/tests/test-fncache.t
@@ -70,7 +70,7 @@ Non store repo:
   .hg/00changelog.i
   .hg/00manifest.i
   .hg/cache
-  .hg/cache/branchheads-unserved
+  .hg/cache/branchheads-served
   .hg/data
   .hg/data/tst.d.hg
   .hg/data/tst.d.hg/foo.i
@@ -98,7 +98,7 @@ Non fncache repo:
   .hg
   .hg/00changelog.i
   .hg/cache
-  .hg/cache/branchheads-unserved
+  .hg/cache/branchheads-served
   .hg/dirstate
   .hg/last-message.txt
   .hg/requires
diff --git a/tests/test-hardlinks.t b/tests/test-hardlinks.t
--- a/tests/test-hardlinks.t
+++ b/tests/test-hardlinks.t
@@ -196,7 +196,7 @@ r4 has hardlinks in the working dir (not
   $ nlinksdir r4
   2 r4/.hg/00changelog.i
   2 r4/.hg/branch
-  2 r4/.hg/cache/branchheads-unserved
+  2 r4/.hg/cache/branchheads-served
   2 r4/.hg/dirstate
   2 r4/.hg/hgrc
   2 r4/.hg/last-message.txt
@@ -226,7 +226,7 @@ Update back to revision 11 in r4 should 
   $ nlinksdir r4
   2 r4/.hg/00changelog.i
   1 r4/.hg/branch
-  2 r4/.hg/cache/branchheads-unserved
+  2 r4/.hg/cache/branchheads-served
   1 r4/.hg/dirstate
   2 r4/.hg/hgrc
   2 r4/.hg/last-message.txt
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
@@ -66,7 +66,7 @@ new directories are setgid
   00700 ./.hg/
   00600 ./.hg/00changelog.i
   00770 ./.hg/cache/
-  00660 ./.hg/cache/branchheads-unserved
+  00660 ./.hg/cache/branchheads-served
   00660 ./.hg/dirstate
   00660 ./.hg/last-message.txt
   00600 ./.hg/requires
@@ -111,7 +111,7 @@ group can still write everything
   00770 ../push/.hg/
   00660 ../push/.hg/00changelog.i
   00770 ../push/.hg/cache/
-  00660 ../push/.hg/cache/branchheads-impactable
+  00660 ../push/.hg/cache/branchheads-nonvolatile
   00660 ../push/.hg/requires
   00770 ../push/.hg/store/
   00660 ../push/.hg/store/00changelog.i
diff --git a/tests/test-keyword.t b/tests/test-keyword.t
--- a/tests/test-keyword.t
+++ b/tests/test-keyword.t
@@ -576,7 +576,7 @@ Copy and show added kwfiles
 Commit and show expansion in original and copy
 
   $ hg --debug commit -ma2c -d '1 0' -u 'User Name <user at example.com>'
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   c
    c: copy a:0045e12f6c5791aac80ca6cbfd97709a88307292
   overwriting c expanding keywords
@@ -760,10 +760,10 @@ Commit with multi-line message and custo
 | invalid here.
 
   $ hg --debug commit -l log -d '2 0' -u 'User Name <user at example.com>'
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   a
   invalid branchheads cache: tip differs
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   overwriting a expanding keywords
   committed changeset 2:bb948857c743469b22bbf51f7ec8112279ca5d83
   $ rm log
diff --git a/tests/test-newbranch.t b/tests/test-newbranch.t
--- a/tests/test-newbranch.t
+++ b/tests/test-newbranch.t
@@ -122,7 +122,7 @@ Test for invalid branch cache:
   repository tip rolled back to revision 4 (undo commit)
   working directory now based on revisions 4 and 3
 
-  $ cp ${branchcache}-unserved .hg/bc-invalid
+  $ cp ${branchcache}-served .hg/bc-invalid
 
   $ hg log -r foo
   changeset:   4:adf1a74a7f7b
@@ -160,7 +160,7 @@ Test for invalid branch cache:
   $ listbranchcaches
   === .hg/cache/branchheads ===
   corrupted
-  === .hg/cache/branchheads-unserved ===
+  === .hg/cache/branchheads-served ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
   1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo
@@ -175,7 +175,7 @@ Pushing just rev 0:
   $ hg push -qr 0 ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-impactable ===
+  === .hg/cache/branchheads-nonvolatile ===
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 0
   db01e8ea3388fd3c7c94e1436ea2bd6a53d581c5 default
 
@@ -184,7 +184,7 @@ Pushing everything:
   $ hg push -qf ../target
 
   $ (cd ../target/; listbranchcaches)
-  === .hg/cache/branchheads-impactable ===
+  === .hg/cache/branchheads-nonvolatile ===
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 4
   1c28f494dae69a2f8fc815059d257eccf3fcfe75 default
   adf1a74a7f7b4cd193d12992f5d0d6a004ed21d6 foo
diff --git a/tests/test-obsolete-divergent.t b/tests/test-obsolete-divergent.t
--- a/tests/test-obsolete-divergent.t
+++ b/tests/test-obsolete-divergent.t
@@ -62,7 +62,7 @@ A_1 have two direct and divergent succes
   $ newcase direct
   $ hg debugobsolete `getid A_0` `getid A_1`
   $ hg debugobsolete `getid A_0` `getid A_2`
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   $ hg log -G --hidden
   o  3:392fd25390da A_2
   |
@@ -104,7 +104,7 @@ indirect divergence with known changeset
   $ newcase indirect_known
   $ hg debugobsolete `getid A_0` `getid A_1`
   $ hg debugobsolete `getid A_0` `getid A_2`
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   $ mkcommit A_3
   created new head
   $ hg debugobsolete `getid A_2` `getid A_3`
@@ -143,7 +143,7 @@ indirect divergence with known changeset
   $ newcase indirect_unknown
   $ hg debugobsolete `getid A_0` aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
   $ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa `getid A_1`
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   $ hg debugobsolete `getid A_0` `getid A_2`
   $ hg log -G --hidden
   o  3:392fd25390da A_2
@@ -175,7 +175,7 @@ do not take unknown node in account if t
   $ newcase final-unknown
   $ hg debugobsolete `getid A_0` `getid A_1`
   $ hg debugobsolete `getid A_1` `getid A_2`
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   $ hg debugobsolete `getid A_0` bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
   $ hg debugobsolete bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb cccccccccccccccccccccccccccccccccccccccc
   $ hg debugobsolete `getid A_1` dddddddddddddddddddddddddddddddddddddddd
@@ -192,7 +192,7 @@ divergence that converge again is not di
   $ newcase converged_divergence
   $ hg debugobsolete `getid A_0` `getid A_1`
   $ hg debugobsolete `getid A_0` `getid A_2`
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   $ mkcommit A_3
   created new head
   $ hg debugobsolete `getid A_1` `getid A_3`
@@ -439,7 +439,7 @@ successors-set. (report [A,B] not [A] + 
   $ newcase subset
   $ hg debugobsolete `getid A_0` `getid A_2`
   $ hg debugobsolete `getid A_0` `getid A_1` `getid A_2`
-  invalid branchheads cache (unserved): tip differs
+  invalid branchheads cache (served): tip differs
   $ hg debugsuccessorssets --hidden 'desc('A_0')'
   007dc284c1f8
       82623d38b9ba 392fd25390da
diff --git a/tests/test-phases.t b/tests/test-phases.t
--- a/tests/test-phases.t
+++ b/tests/test-phases.t
@@ -176,14 +176,14 @@ visible shared between the initial repo 
 check that branch cache with "unserved" filter are properly computed and stored
 
   $ ls ../push-dest/.hg/cache/branchheads*
-  ../push-dest/.hg/cache/branchheads-hidden
-  ../push-dest/.hg/cache/branchheads-unserved
-  $ cat ../push-dest/.hg/cache/branchheads-hidden
+  ../push-dest/.hg/cache/branchheads-served
+  ../push-dest/.hg/cache/branchheads-visible
+  $ cat ../push-dest/.hg/cache/branchheads-visible
   6d6770faffce199f1fddd1cf87f6f026138cf061 6
   b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
   2713879da13d6eea1ff22b442a5a87cb31a7ce6a default
   6d6770faffce199f1fddd1cf87f6f026138cf061 default
-  $ cat ../push-dest/.hg/cache/branchheads-unserved
+  $ cat ../push-dest/.hg/cache/branchheads-served
   cf9fe039dfd67e829edf6522a45de057b5c86519 4
   b3325c91a4d916bcc4cdc83ea3fe4ece46a42f6e default
   cf9fe039dfd67e829edf6522a45de057b5c86519 default
diff --git a/tests/test-rebase-collapse.t b/tests/test-rebase-collapse.t
--- a/tests/test-rebase-collapse.t
+++ b/tests/test-rebase-collapse.t
@@ -274,7 +274,7 @@ also, the parent of a node that is a chi
   7:c65502d4178782309ce0574c5ae6ee9485a9bafa default
   6:c772a8b2dc17629cec88a19d09c926c4814b12c7 default
 
-  $ cat $TESTTMP/b2/.hg/cache/branchheads-unserved
+  $ cat $TESTTMP/b2/.hg/cache/branchheads-served
   c65502d4178782309ce0574c5ae6ee9485a9bafa 7
   c772a8b2dc17629cec88a19d09c926c4814b12c7 default
   c65502d4178782309ce0574c5ae6ee9485a9bafa default


More information about the Mercurial-devel mailing list