[PATCH 2 of 2] graphlog: support --hidden

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


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1330438089 -3600
# Node ID 7262672c92a87ddaf3e611e0ad1c5f5acb071018
# Parent  a1a5c8b889ca2cf447bd80af8eb19f4101646dce
graphlog: support --hidden

At this point "hg log --graph" should support all "hg log" options.

I am not fond of the way --hidden is "polluting" all generated expressions,
even more given it is a currently useless option. At least it shows what kind
of impact implementing --hidden for other commands might have, and what kind of
support we might want at revset API or elsewhere.

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -283,6 +283,7 @@
         'no_merges':        ('not merge()', None),
         'only_merges':      ('merge()', None),
         'date':             ('date(%(val)r)', None),
+        '_nothidden':       ('not hidden()', None),
         'branch':           ('branch(%(val)r)', ' or '),
         '_patslog':         ('filelog(%(val)r)', ' or '),
         '_patsfollow':      ('follow(%(val)r)', ' or '),
@@ -299,6 +300,9 @@
     if 'branch' in opts and 'only_branch' in opts:
         opts['branch'] = opts['branch'] + opts.pop('only_branch')
 
+    if 'hidden' in opts:
+        opts['_nothidden'] = not opts.pop('hidden')
+
     follow = opts.get('follow') or opts.get('follow_first')
     followfirst = opts.get('follow_first')
     if 'follow' in opts:
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -103,6 +103,7 @@
   $ echo "[extensions]" >> $HGRCPATH
   $ echo "graphlog=" >> $HGRCPATH
   $ echo "printrevset=`pwd`/printrevset.py" >> $HGRCPATH
+  $ echo "hidden=$TESTDIR/testhidden.py" >> $HGRCPATH
 
   $ hg init repo
   $ cd repo
@@ -1430,7 +1431,7 @@
 glog always reorders nodes which explains the difference with log
 
   $ testlog -r 27 -r 25 -r 21 -r 34 -r 32 -r 31
-  ('group', ('group', ('or', ('or', ('or', ('or', ('or', ('symbol', '27'), ('symbol', '25')), ('symbol', '21')), ('symbol', '34')), ('symbol', '32')), ('symbol', '31'))))
+  ('group', ('and', ('group', ('or', ('or', ('or', ('or', ('or', ('symbol', '27'), ('symbol', '25')), ('symbol', '21')), ('symbol', '34')), ('symbol', '32')), ('symbol', '31'))), ('not', ('func', ('symbol', 'hidden'), None))))
   --- log.nodes	* (glob)
   +++ glog.nodes	* (glob)
   @@ -1,6 +1,6 @@
@@ -1445,26 +1446,39 @@
   +nodetag 21
   [1]
   $ testlog -u test -u not-a-user
-  ('group', ('group', ('or', ('func', ('symbol', 'user'), ('string', 'test')), ('func', ('symbol', 'user'), ('string', 'not-a-user')))))
+  ('group', ('and', ('group', ('or', ('func', ('symbol', 'user'), ('string', 'test')), ('func', ('symbol', 'user'), ('string', 'not-a-user')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog -b not-a-branch
-  ('group', ('group', ('func', ('symbol', 'branch'), ('string', 'not-a-branch'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'branch'), ('string', 'not-a-branch'))), ('not', ('func', ('symbol', 'hidden'), None))))
   abort: unknown revision 'not-a-branch'!
   abort: unknown revision 'not-a-branch'!
   $ testlog -b default -b branch --only-branch branch
-  ('group', ('group', ('or', ('or', ('func', ('symbol', 'branch'), ('string', 'default')), ('func', ('symbol', 'branch'), ('string', 'branch'))), ('func', ('symbol', 'branch'), ('string', 'branch')))))
+  ('group', ('and', ('group', ('or', ('or', ('func', ('symbol', 'branch'), ('string', 'default')), ('func', ('symbol', 'branch'), ('string', 'branch'))), ('func', ('symbol', 'branch'), ('string', 'branch')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog -k expand -k merge
-  ('group', ('group', ('or', ('func', ('symbol', 'keyword'), ('string', 'expand')), ('func', ('symbol', 'keyword'), ('string', 'merge')))))
+  ('group', ('and', ('group', ('or', ('func', ('symbol', 'keyword'), ('string', 'expand')), ('func', ('symbol', 'keyword'), ('string', 'merge')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog --only-merges
-  ('group', ('func', ('symbol', 'merge'), None))
+  ('group', ('and', ('func', ('symbol', 'merge'), None), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog --no-merges
-  ('group', ('not', ('func', ('symbol', 'merge'), None)))
+  ('group', ('and', ('not', ('func', ('symbol', 'merge'), None)), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog --date '2 0 to 4 0'
-  ('group', ('func', ('symbol', 'date'), ('string', '2 0 to 4 0')))
+  ('group', ('and', ('func', ('symbol', 'date'), ('string', '2 0 to 4 0')), ('not', ('func', ('symbol', 'hidden'), None))))
   $ hg log -G -d 'brace ) in a date'
   abort: invalid date: 'brace ) in a date'
   [255]
   $ testlog --prune 31 --prune 32
-  ('group', ('group', ('and', ('not', ('group', ('or', ('string', '31'), ('func', ('symbol', 'ancestors'), ('string', '31'))))), ('not', ('group', ('or', ('string', '32'), ('func', ('symbol', 'ancestors'), ('string', '32'))))))))
+  ('group', ('and', ('group', ('and', ('not', ('group', ('or', ('string', '31'), ('func', ('symbol', 'ancestors'), ('string', '31'))))), ('not', ('group', ('or', ('string', '32'), ('func', ('symbol', 'ancestors'), ('string', '32'))))))), ('not', ('func', ('symbol', 'hidden'), None))))
+
+Test --hidden
+
+  $ hg id --debug -i -r . > .hg/hidden
+  $ testlog
+  ('group', ('not', ('func', ('symbol', 'hidden'), None)))
+  $ wc -l < log.nodes
+  \s*36 (re)
+  $ testlog --hidden
+  ('func', ('symbol', 'all'), None)
+  $ wc -l < log.nodes
+  \s*37 (re)
+  $ rm .hg/hidden
 
 Dedicated repo for --follow and paths filtering. The g is crafted to
 have 2 filelog topological heads in a linear changeset graph.
@@ -1507,19 +1521,19 @@
   
 
   $ testlog a
-  ('group', ('group', ('func', ('symbol', 'filelog'), ('string', 'a'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'filelog'), ('string', 'a'))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog a b
-  ('group', ('group', ('or', ('func', ('symbol', 'filelog'), ('string', 'a')), ('func', ('symbol', 'filelog'), ('string', 'b')))))
+  ('group', ('and', ('group', ('or', ('func', ('symbol', 'filelog'), ('string', 'a')), ('func', ('symbol', 'filelog'), ('string', 'b')))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test falling back to slow path for non-existing files
 
   $ testlog a c
-  ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:c')))))
+  ('group', ('and', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:c')))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test multiple --include/--exclude/paths
 
   $ testlog --include a --include e --exclude b --exclude e a e
-  ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('list', ('list', ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:e')), ('string', 'i:a')), ('string', 'i:e')), ('string', 'x:b')), ('string', 'x:e')))))
+  ('group', ('and', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('list', ('list', ('list', ('list', ('list', ('string', 'r:'), ('string', 'p:a')), ('string', 'p:e')), ('string', 'i:a')), ('string', 'i:e')), ('string', 'x:b')), ('string', 'x:e')))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test glob expansion of pats
 
@@ -1530,7 +1544,7 @@
   > else
   >    testlog a*;
   > fi;
-  ('group', ('group', ('func', ('symbol', 'filelog'), ('string', 'aa'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'filelog'), ('string', 'aa'))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test --follow on a directory
 
@@ -1557,26 +1571,26 @@
 
   $ hg up -q 2
   $ testlog -f a
-  ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'a'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'follow'), ('string', 'a'))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test --follow and multiple renames
 
   $ hg up -q tip
   $ testlog -f e
-  ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'e'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'follow'), ('string', 'e'))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test --follow and multiple filelog heads
 
   $ hg up -q 2
   $ testlog -f g
-  ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'g'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'follow'), ('string', 'g'))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ cat log.nodes
   nodetag 2
   nodetag 1
   nodetag 0
   $ hg up -q tip
   $ testlog -f g
-  ('group', ('group', ('func', ('symbol', 'follow'), ('string', 'g'))))
+  ('group', ('and', ('group', ('func', ('symbol', 'follow'), ('string', 'g'))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ cat log.nodes
   nodetag 3
   nodetag 2
@@ -1585,7 +1599,7 @@
 Test --follow and multiple files
 
   $ testlog -f g e
-  ('group', ('group', ('or', ('func', ('symbol', 'follow'), ('string', 'g')), ('func', ('symbol', 'follow'), ('string', 'e')))))
+  ('group', ('and', ('group', ('or', ('func', ('symbol', 'follow'), ('string', 'g')), ('func', ('symbol', 'follow'), ('string', 'e')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ cat log.nodes
   nodetag 4
   nodetag 3
@@ -1605,12 +1619,12 @@
   $ echo merge > e
   $ hg ci -m "merge 5 and 4"
   $ testlog --follow-first
-  ('group', ('func', ('symbol', '_followfirst'), None))
+  ('group', ('and', ('func', ('symbol', '_followfirst'), None), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Cannot compare with log --follow-first FILE as it never worked
 
   $ hg log -G --print-revset --follow-first e
-  ('group', ('group', ('func', ('symbol', '_followfirst'), ('string', 'e'))))
+  ('group', ('and', ('group', ('func', ('symbol', '_followfirst'), ('string', 'e'))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ hg log -G --follow-first e --template '{rev} {desc|firstline}\n'
   @    6 merge 5 and 4
   |\
@@ -1639,18 +1653,18 @@
 
   $ hg up -q 4
   $ testlog "set:copied()"
-  ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'p:set:copied()')))))
+  ('group', ('and', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'p:set:copied()')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog --include "set:copied()"
-  ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'i:set:copied()')))))
+  ('group', ('and', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'i:set:copied()')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog -r "sort(file('set:copied()'), -rev)"
-  ('group', ('group', ('func', ('symbol', 'sort'), ('list', ('func', ('symbol', 'file'), ('string', 'set:copied()')), ('negate', ('symbol', 'rev'))))))
+  ('group', ('and', ('group', ('func', ('symbol', 'sort'), ('list', ('func', ('symbol', 'file'), ('string', 'set:copied()')), ('negate', ('symbol', 'rev'))))), ('not', ('func', ('symbol', 'hidden'), None))))
 
 Test --removed
 
   $ testlog --removed
-  ('func', ('symbol', 'all'), None)
+  ('group', ('not', ('func', ('symbol', 'hidden'), None)))
   $ testlog --removed a
-  ('group', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'p:a')))))
+  ('group', ('and', ('group', ('func', ('symbol', '_matchfiles'), ('list', ('string', 'r:'), ('string', 'p:a')))), ('not', ('func', ('symbol', 'hidden'), None))))
   $ testlog --removed --follow a
   abort: can only follow copies/renames for explicit filenames
   abort: can only follow copies/renames for explicit filenames



More information about the Mercurial-devel mailing list