[PATCH 2 of 5] graphlog: rewrite --rev like all other options

Patrick Mezard patrick at mezard.eu
Thu Feb 23 11:10:28 CST 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1329992490 -3600
# Node ID e04cc21b01b280e8e93e4566026d37ba0955a19f
# Parent  4a828d3bc04a42bdba153dea03233121475418c4
graphlog: rewrite --rev like all other options

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -253,13 +253,14 @@
         'no_merges':   ('not merge()', None),
         'only_merges': ('merge()', None),
         'removed':     ('removes("*")', None),
-        'date':        ('date($)', None),
-        'branch':      ('branch($)', ' or '),
-        'exclude':     ('not file($)', ' and '),
-        'include':     ('file($)', ' and '),
-        'keyword':     ('keyword($)', ' or '),
-        'prune':       ('not ($ or ancestors($))', ' and '),
-        'user':        ('user($)', ' or '),
+        'date':        ('date(%(val)r)', None),
+        'branch':      ('branch(%(val)r)', ' or '),
+        'exclude':     ('not file(%(val)r)', ' and '),
+        'include':     ('file(%(val)r)', ' and '),
+        'keyword':     ('keyword(%(val)r)', ' or '),
+        'prune':       ('not (%(val)r or ancestors(%(val)r))', ' and '),
+        'user':        ('user(%(val)r)', ' or '),
+        'rev':         ('%(val)s', ' or '),
         }
 
     # branch and only_branch are really aliases and must be handled at
@@ -268,36 +269,27 @@
         opts = dict(opts)
         opts['branch'] = opts['branch'] + opts.pop('only_branch')
 
-    optrevset = []
     revset = []
     for op, val in opts.iteritems():
         if not val:
             continue
-        if op == 'rev':
-            # Already a revset
-            revset.extend(val)
         if op not in opt2revset:
             continue
         revop, andor = opt2revset[op]
-        if '$' not in revop:
-            optrevset.append(revop)
+        if '%(val)' not in revop:
+            revset.append(revop)
         else:
-            revop = revop.replace('$', '%(val)r')
             if not isinstance(val, list):
                 expr = revop % {'val': val}
             else:
                 expr = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
-            optrevset.append(expr)
+            revset.append(expr)
 
     for path in pats:
-        optrevset.append('file(%r)' % path)
+        revset.append('file(%r)' % path)
 
-    if revset or optrevset:
-        if revset:
-            revset = ['(' + ' or '.join(revset) + ')']
-        if optrevset:
-            revset.append('(' + ' and '.join(optrevset) + ')')
-        revset = ' and '.join(revset)
+    if revset:
+        revset = '(' + ' and '.join(revset) + ')'
     else:
         revset = 'all()'
     return revset
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1486,19 +1486,3 @@
   $ hg log -G --follow a
   abort: -G/--graph option is incompatible with --follow with file argument
   [255]
-
-Test multiple revision specifications are correctly handled
-
-  $ hg log -G -r 27 -r 25 -r 21 -r 34 -r 32 -r 31 --template '{rev}\n'
-  o  34
-  |
-  o    32
-  |\
-  | o    31
-  | |\
-  o | |  27
-  |/ /
-  | o  25
-  |/
-  o    21
-  |\


More information about the Mercurial-devel mailing list