graphlog: paths arguments must be or'ed
authorPatrick Mezard <patrick@mezard.eu>
Thu, 23 Feb 2012 17:54:42 +0100
changeset 16159 ec33539b61f6
parent 16158 e04cc21b01b2
child 16160 1bfc7ba8b404
graphlog: paths arguments must be or'ed
hgext/graphlog.py
tests/test-glog.t
--- a/hgext/graphlog.py	Thu Feb 23 11:21:30 2012 +0100
+++ b/hgext/graphlog.py	Thu Feb 23 17:54:42 2012 +0100
@@ -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:
--- a/tests/test-glog.t	Thu Feb 23 11:21:30 2012 +0100
+++ b/tests/test-glog.t	Thu Feb 23 17:54:42 2012 +0100
@@ -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')))))