[PATCH 2 of 3] minifileset: unify handling of symbol and string patterns
Yuya Nishihara
yuya at tcha.org
Thu Jan 18 07:08:37 EST 2018
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1515904436 -32400
# Sun Jan 14 13:33:56 2018 +0900
# Node ID d3fce96625e610085c2335f9446b726c74326108
# Parent 1c00ef820a03c011a06c9172925cdf597cf38ee6
minifileset: unify handling of symbol and string patterns
They must be identical for fileset compatibility.
diff --git a/mercurial/minifileset.py b/mercurial/minifileset.py
--- a/mercurial/minifileset.py
+++ b/mercurial/minifileset.py
@@ -17,7 +17,7 @@ def _compile(tree):
if not tree:
raise error.ParseError(_("missing argument"))
op = tree[0]
- if op == 'symbol':
+ if op in {'symbol', 'string'}:
name = fileset.getstring(tree, _('invalid file pattern'))
if name.startswith('**'): # file extension test, ex. "**.tar.gz"
ext = name[2:]
@@ -25,17 +25,14 @@ def _compile(tree):
if c in '*{}[]?/\\':
raise error.ParseError(_('reserved character: %s') % c)
return lambda n, s: n.endswith(ext)
- raise error.ParseError(_('invalid symbol: %s') % name)
- elif op == 'string':
# TODO: teach fileset about 'path:', so that this can be a symbol and
# not require quoting.
- name = fileset.getstring(tree, _('invalid path literal'))
- if name.startswith('path:'): # directory or full path test
+ elif name.startswith('path:'): # directory or full path test
p = name[5:] # prefix
pl = len(p)
f = lambda n, s: n.startswith(p) and (len(n) == pl or n[pl] == '/')
return f
- raise error.ParseError(_("invalid string"),
+ raise error.ParseError(_("unsupported file pattern"),
hint=_('paths must be prefixed with "path:"'))
elif op == 'or':
func1 = _compile(tree[1])
More information about the Mercurial-devel
mailing list