##// END OF EJS Templates
revset: add parsing rule for key=value pair...
Yuya Nishihara -
r25704:70a2082f default
parent child Browse files
Show More
@@ -133,6 +133,7 b' elements = {'
133 133 "or": (4, None, ("or", 4)),
134 134 "|": (4, None, ("or", 4)),
135 135 "+": (4, None, ("or", 4)),
136 "=": (3, None, ("keyvalue", 3)),
136 137 ",": (2, None, ("list", 2)),
137 138 ")": (0, None, None),
138 139 "symbol": (0, ("symbol",), None),
@@ -190,7 +191,7 b' def tokenize(program, lookup=None, symin'
190 191 elif c == '#' and program[pos:pos + 2] == '##': # look ahead carefully
191 192 yield ('##', None, pos)
192 193 pos += 1 # skip ahead
193 elif c in "():,-|&+!~^%": # handle simple operators
194 elif c in "():=,-|&+!~^%": # handle simple operators
194 195 yield (c, None, pos)
195 196 elif (c in '"\'' or c == 'r' and
196 197 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
@@ -388,6 +389,9 b' def notset(repo, subset, x):'
388 389 def listset(repo, subset, a, b):
389 390 raise error.ParseError(_("can't use a list in this context"))
390 391
392 def keyvaluepair(repo, subset, k, v):
393 raise error.ParseError(_("can't use a key-value pair in this context"))
394
391 395 def func(repo, subset, a, b):
392 396 if a[0] == 'symbol' and a[1] in symbols:
393 397 return symbols[a[1]](repo, subset, b)
@@ -2180,6 +2184,7 b' methods = {'
2180 2184 "or": orset,
2181 2185 "not": notset,
2182 2186 "list": listset,
2187 "keyvalue": keyvaluepair,
2183 2188 "func": func,
2184 2189 "ancestor": ancestorspec,
2185 2190 "parent": parentspec,
@@ -322,6 +322,17 b' quoting needed'
322 322 4
323 323 $ hg book -d date
324 324
325 keyword arguments
326
327 $ try 'foo=bar|baz'
328 (keyvalue
329 ('symbol', 'foo')
330 (or
331 ('symbol', 'bar')
332 ('symbol', 'baz')))
333 hg: parse error: can't use a key-value pair in this context
334 [255]
335
325 336 Test that symbols only get parsed as functions if there's an opening
326 337 parenthesis.
327 338
General Comments 0
You need to be logged in to leave comments. Login now