[PATCH 1 of 2] revset: add hidden() revset, undocumented

Patrick Mezard patrick at mezard.eu
Tue Feb 28 14:10:41 UTC 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1330436212 -3600
# Node ID a1a5c8b889ca2cf447bd80af8eb19f4101646dce
# Parent  262114146ffde3a9ef153e7ee37a61f7998210ee
revset: add hidden() revset, undocumented

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -587,6 +587,12 @@
     ps = set(parents(repo, subset, x))
     return [r for r in s if r not in ps]
 
+def hidden(repo, subset, x):
+    # ``hidden()``
+    # Changeset is hidden.
+    getargs(x, 0, 0, _("hidden takes no arguments"))
+    return [r for r in subset if r in repo.changelog.hiddenrevs]
+
 def keyword(repo, subset, x):
     """``keyword(string)``
     Search commit message, user name, and names of changed files for
@@ -997,6 +1003,7 @@
     "grep": grep,
     "head": head,
     "heads": heads,
+    "hidden": hidden,
     "id": node,
     "keyword": keyword,
     "last": last,
@@ -1103,7 +1110,7 @@
         f = getstring(x[1], _("not a symbol"))
         wa, ta = optimize(x[2], small)
         if f in ("author branch closed date desc file grep keyword "
-                 "outgoing user"):
+                 "outgoing user hidden"):
             w = 10 # slow
         elif f in "modifies adds removes":
             w = 30 # slower
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1166,15 +1166,8 @@
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     a
   
-  $ cat > $HGTMP/testhidden.py << EOF
-  > def reposetup(ui, repo):
-  >     for line in repo.opener('hidden'):
-  >         ctx = repo[line.strip()]
-  >         repo.changelog.hiddenrevs.add(ctx.rev())
-  > EOF
   $ echo '[extensions]' >> $HGRCPATH
-  $ echo "hidden=$HGTMP/testhidden.py" >> $HGRCPATH
-  $ touch .hg/hidden
+  $ echo "hidden=$TESTDIR/testhidden.py" >> $HGRCPATH
   $ hg log --template='{rev}:{node}\n'
   1:a765632148dc55d38c35c4f247c618701886cb2f
   0:9f758d63dcde62d547ebfb08e1e7ee96535f2b05
diff --git a/tests/test-revset.t b/tests/test-revset.t
--- a/tests/test-revset.t
+++ b/tests/test-revset.t
@@ -2,6 +2,8 @@
 
   $ HGENCODING=utf-8
   $ export HGENCODING
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo "hidden=$TESTDIR/testhidden.py" >> $HGRCPATH
 
   $ try() {
   >   hg debugrevspec --debug "$@"
@@ -509,6 +511,16 @@
   3
   2
 
+test hidden revisions
+
+  $ hg id --debug -i -r . > .hg/hidden
+  $ try 'hidden()'
+  ('func', ('symbol', 'hidden'), None)
+  9
+  $ rm .hg/hidden
+  $ try 'hidden()'
+  ('func', ('symbol', 'hidden'), None)
+
 issue2549 - correct optimizations
 
   $ log 'limit(1 or 2 or 3, 2) and not 2'
diff --git a/tests/testhidden.py b/tests/testhidden.py
new file mode 100644
--- /dev/null
+++ b/tests/testhidden.py
@@ -0,0 +1,12 @@
+import os, errno
+
+def reposetup(ui, repo):
+    try:
+        hiddenfp = repo.opener('hidden')
+    except IOError, e:
+        if e.errno != errno.ENOENT:
+            raise
+        return
+    for line in hiddenfp:
+        ctx = repo[line.strip()]
+        repo.changelog.hiddenrevs.add(ctx.rev())



More information about the Mercurial-devel mailing list