[PATCH 3 of 5] graphlog: paths arguments must be or'ed

Patrick Mezard patrick at mezard.eu
Thu Feb 23 17:10:29 UTC 2012


# HG changeset patch
# User Patrick Mezard <patrick at mezard.eu>
# Date 1330016082 -3600
# Node ID ec33539b61f674130dd85656f1e2ae0dd065f2eb
# Parent  e04cc21b01b280e8e93e4566026d37ba0955a19f
graphlog: paths arguments must be or'ed

diff --git a/hgext/graphlog.py b/hgext/graphlog.py
--- a/hgext/graphlog.py
+++ b/hgext/graphlog.py
@@ -257,17 +257,19 @@
         'branch':      ('branch(%(val)r)', ' or '),
         'exclude':     ('not file(%(val)r)', ' and '),
         'include':     ('file(%(val)r)', ' and '),
+        '_pats':       ('file(%(val)r)', ' or '),
         'keyword':     ('keyword(%(val)r)', ' or '),
         'prune':       ('not (%(val)r or ancestors(%(val)r))', ' and '),
         'user':        ('user(%(val)r)', ' or '),
         'rev':         ('%(val)s', ' or '),
         }
 
+    opts = dict(opts)
     # branch and only_branch are really aliases and must be handled at
     # the same time
     if 'branch' in opts and 'only_branch' in opts:
-        opts = dict(opts)
         opts['branch'] = opts['branch'] + opts.pop('only_branch')
+    opts['_pats'] = list(pats)
 
     revset = []
     for op, val in opts.iteritems():
@@ -285,9 +287,6 @@
                 expr = '(' + andor.join((revop % {'val': v}) for v in val) + ')'
             revset.append(expr)
 
-    for path in pats:
-        revset.append('file(%r)' % path)
-
     if revset:
         revset = '(' + ' and '.join(revset) + ')'
     else:
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -1486,3 +1486,38 @@
   $ hg log -G --follow a
   abort: -G/--graph option is incompatible with --follow with file argument
   [255]
+
+
+Dedicated repo for --follow and paths filtering
+
+  $ cd ..
+  $ hg init follow
+  $ cd follow
+  $ echo a > a
+  $ hg ci -Am "add a"
+  adding a
+  $ hg cp a b
+  $ hg ci -m "copy a b"
+  $ mkdir dir
+  $ hg mv b dir
+  $ hg ci -m "mv b dir/b"
+  $ hg mv a b
+  $ echo a > d
+  $ hg add d
+  $ hg ci -m "mv a b; add d"
+  $ hg mv dir/b e
+  $ hg ci -m "mv dir/b e"
+  $ hg glog --template '({rev}) {desc|firstline}\n'
+  @  (4) mv dir/b e
+  |
+  o  (3) mv a b; add d
+  |
+  o  (2) mv b dir/b
+  |
+  o  (1) copy a b
+  |
+  o  (0) add a
+  
+
+  $ testlog a c
+  ('group', ('group', ('or', ('func', ('symbol', 'file'), ('string', 'a')), ('func', ('symbol', 'file'), ('string', 'c')))))



More information about the Mercurial-devel mailing list