diff --git a/hgext/graphlog.py b/hgext/graphlog.py --- a/hgext/graphlog.py +++ b/hgext/graphlog.py @@ -257,17 +257,19 @@ def revset(pats, opts): '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 @@ def revset(pats, opts): 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 @@ Test log -G options $ 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')))))