diff --git a/hgext/graphlog.py b/hgext/graphlog.py --- a/hgext/graphlog.py +++ b/hgext/graphlog.py @@ -340,7 +340,7 @@ def _makelogrevset(repo, pats, opts, rev # "a" and "b" while "file(a) and not file(b)" does # not. Besides, filesets are evaluated against the working # directory. - matchargs = ['r:'] + matchargs = ['r:', 'd:relpath'] for p in pats: matchargs.append('p:' + p) for p in opts.get('include', []): diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -559,13 +559,14 @@ def _matchfiles(repo, subset, x): # patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass # a revision identifier, or the empty string to reference the # working directory, from which the match object is - # initialized. At most one 'r:' argument can be passed. + # initialized. Use 'd:' to set the default matching mode, default + # to 'glob'. At most one 'r:' and 'd:' argument can be passed. # i18n: "_matchfiles" is a keyword l = getargs(x, 1, -1, _("_matchfiles requires at least one argument")) pats, inc, exc = [], [], [] hasset = False - rev = None + rev, default = None, None for arg in l: s = getstring(arg, _("_matchfiles requires string arguments")) prefix, value = s[:2], s[2:] @@ -580,10 +581,17 @@ def _matchfiles(repo, subset, x): raise error.ParseError(_('_matchfiles expected at most one ' 'revision')) rev = value + elif prefix == 'd:': + if default is not None: + raise error.ParseError(_('_matchfiles expected at most one ' + 'default mode')) + default = value else: raise error.ParseError(_('invalid _matchfiles prefix: %s') % prefix) if not hasset and matchmod.patkind(value) == 'set': hasset = True + if not default: + default = 'glob' m = None s = [] for r in subset: @@ -593,7 +601,7 @@ def _matchfiles(repo, subset, x): if rev is not None: ctx = repo[rev or None] m = matchmod.match(repo.root, repo.getcwd(), pats, include=inc, - exclude=exc, ctx=ctx) + exclude=exc, ctx=ctx, default=default) for f in c.files(): if m(f): s.append(r) diff --git a/tests/test-glog.t b/tests/test-glog.t --- a/tests/test-glog.t +++ b/tests/test-glog.t @@ -1600,7 +1600,9 @@ Test falling back to slow path for non-e ('symbol', '_matchfiles') (list (list - ('string', 'r:') + (list + ('string', 'r:') + ('string', 'd:relpath')) ('string', 'p:a')) ('string', 'p:c')))) @@ -1617,7 +1619,9 @@ Test multiple --include/--exclude/paths (list (list (list - ('string', 'r:') + (list + ('string', 'r:') + ('string', 'd:relpath')) ('string', 'p:a')) ('string', 'p:e')) ('string', 'i:a')) @@ -1791,7 +1795,9 @@ Test "set:..." and parent revision (func ('symbol', '_matchfiles') (list - ('string', 'r:') + (list + ('string', 'r:') + ('string', 'd:relpath')) ('string', 'p:set:copied()')))) $ testlog --include "set:copied()" [] @@ -1799,7 +1805,9 @@ Test "set:..." and parent revision (func ('symbol', '_matchfiles') (list - ('string', 'r:') + (list + ('string', 'r:') + ('string', 'd:relpath')) ('string', 'i:set:copied()')))) $ testlog -r "sort(file('set:copied()'), -rev)" ["sort(file('set:copied()'), -rev)"] @@ -1816,7 +1824,9 @@ Test --removed (func ('symbol', '_matchfiles') (list - ('string', 'r:') + (list + ('string', 'r:') + ('string', 'd:relpath')) ('string', 'p:a')))) $ testlog --removed --follow a abort: can only follow copies/renames for explicit filenames @@ -2001,3 +2011,18 @@ Test --follow-first and backward --rev (func ('symbol', '_firstancestors') ('symbol', '6'))) + +Test subdir + + $ hg up -q 3 + $ cd dir + $ testlog . + [] + (group + (func + ('symbol', '_matchfiles') + (list + (list + ('string', 'r:') + ('string', 'd:relpath')) + ('string', 'p:.')))) diff --git a/tests/test-revset.t b/tests/test-revset.t --- a/tests/test-revset.t +++ b/tests/test-revset.t @@ -246,7 +246,7 @@ quoting needed 7 8 9 - $ log 'file(b)' + $ log 'file("b*")' 1 4 $ log 'follow()'