# HG changeset patch # User Yuya Nishihara # Date 2017-04-01 08:18:31 # Node ID 8f1a7adb3225cc4a6893129da04f860ed277fad2 # Parent aaeba70d5cbec2a791d2b936b746960414868a41 revsetlang: catch invalid format character with %l prefix listexp() could call argtype() with an invalid format character, but that wasn't checked before. diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py --- a/mercurial/revsetlang.py +++ b/mercurial/revsetlang.py @@ -600,6 +600,7 @@ def formatspec(expr, *args): return _quote(node.hex(arg)) elif c == 'b': return _quote(arg.branch()) + raise error.ParseError(_('unexpected revspec format character %s') % c) def listexp(s, t): l = len(s) @@ -633,16 +634,13 @@ def formatspec(expr, *args): d = expr[pos] if d == '%': ret.append(d) - elif d in 'dsnbr': - ret.append(argtype(d, next(argiter))) elif d == 'l': # a list of some type pos += 1 d = expr[pos] ret.append(listexp(list(next(argiter)), d)) else: - raise error.ParseError(_('unexpected revspec format character %s') - % d) + ret.append(argtype(d, next(argiter))) pos += 1 return ''.join(ret) diff --git a/tests/test-command-template.t b/tests/test-command-template.t --- a/tests/test-command-template.t +++ b/tests/test-command-template.t @@ -4085,6 +4085,9 @@ Invalid arguments passed to revset() $ hg log -T '{revset("%whatever", 0)}\n' hg: parse error: unexpected revspec format character w [255] + $ hg log -T '{revset("%lwhatever", files)}\n' + hg: parse error: unexpected revspec format character w + [255] Test files function