Mercurial > hg
changeset 15266:8bea39ca9acb
revset: add %r for embedded revset support to formatspec
This allows folding external revsets or lists of revsets into a revset
expression. Revsets are pre-parsed for validity so that syntax errors
don't escape.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 15 Oct 2011 10:20:08 -0500 |
parents | 460135339d74 |
children | 3bfdfefea2fc |
files | mercurial/revset.py |
diffstat | 1 files changed, 7 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Sat Oct 15 01:06:52 2011 +0200 +++ b/mercurial/revset.py Sat Oct 15 10:20:08 2011 -0500 @@ -1055,14 +1055,17 @@ Supported arguments: + %r = revset expression, parenthesized %d = int(arg), no quoting %s = string(arg), escaped and single-quoted %b = arg.branch(), escaped and single-quoted %n = hex(arg), single-quoted %% = a literal '%' - Prefixing the type with 'l' specifies a list of that type. + Prefixing the type with 'l' specifies a parenthesized list of that type. + >>> formatspec('%d:: and %lr', 10, ("this()", "that()")) + '10:: and ((this()) or (that()))' >>> formatspec('%d:: and not %d::', 10, 20) '10:: and not 20::' >>> formatspec('keyword(%s)', 'foo\\xe9') @@ -1083,6 +1086,9 @@ return str(int(arg)) elif c == 's': return quote(arg) + elif c == 'r': + parse(arg) # make sure syntax errors are confined + return '(%s)' % arg elif c == 'n': return quote(node.hex(arg)) elif c == 'b':