##// 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 "or": (4, None, ("or", 4)),
133 "or": (4, None, ("or", 4)),
134 "|": (4, None, ("or", 4)),
134 "|": (4, None, ("or", 4)),
135 "+": (4, None, ("or", 4)),
135 "+": (4, None, ("or", 4)),
136 "=": (3, None, ("keyvalue", 3)),
136 ",": (2, None, ("list", 2)),
137 ",": (2, None, ("list", 2)),
137 ")": (0, None, None),
138 ")": (0, None, None),
138 "symbol": (0, ("symbol",), None),
139 "symbol": (0, ("symbol",), None),
@@ -190,7 +191,7 b' def tokenize(program, lookup=None, symin'
190 elif c == '#' and program[pos:pos + 2] == '##': # look ahead carefully
191 elif c == '#' and program[pos:pos + 2] == '##': # look ahead carefully
191 yield ('##', None, pos)
192 yield ('##', None, pos)
192 pos += 1 # skip ahead
193 pos += 1 # skip ahead
193 elif c in "():,-|&+!~^%": # handle simple operators
194 elif c in "():=,-|&+!~^%": # handle simple operators
194 yield (c, None, pos)
195 yield (c, None, pos)
195 elif (c in '"\'' or c == 'r' and
196 elif (c in '"\'' or c == 'r' and
196 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
197 program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
@@ -388,6 +389,9 b' def notset(repo, subset, x):'
388 def listset(repo, subset, a, b):
389 def listset(repo, subset, a, b):
389 raise error.ParseError(_("can't use a list in this context"))
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 def func(repo, subset, a, b):
395 def func(repo, subset, a, b):
392 if a[0] == 'symbol' and a[1] in symbols:
396 if a[0] == 'symbol' and a[1] in symbols:
393 return symbols[a[1]](repo, subset, b)
397 return symbols[a[1]](repo, subset, b)
@@ -2180,6 +2184,7 b' methods = {'
2180 "or": orset,
2184 "or": orset,
2181 "not": notset,
2185 "not": notset,
2182 "list": listset,
2186 "list": listset,
2187 "keyvalue": keyvaluepair,
2183 "func": func,
2188 "func": func,
2184 "ancestor": ancestorspec,
2189 "ancestor": ancestorspec,
2185 "parent": parentspec,
2190 "parent": parentspec,
@@ -322,6 +322,17 b' quoting needed'
322 4
322 4
323 $ hg book -d date
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 Test that symbols only get parsed as functions if there's an opening
336 Test that symbols only get parsed as functions if there's an opening
326 parenthesis.
337 parenthesis.
327
338
General Comments 0
You need to be logged in to leave comments. Login now