##// END OF EJS Templates
revset: port extra() to support keyword arguments...
Yuya Nishihara -
r25706:b7f53c47 default
parent child Browse files
Show More
@@ -840,16 +840,19 b' def extra(repo, subset, x):'
840 a regular expression. To match a value that actually starts with `re:`,
840 a regular expression. To match a value that actually starts with `re:`,
841 use the prefix `literal:`.
841 use the prefix `literal:`.
842 """
842 """
843
843 args = getkwargs(x, 'extra', 'label value')
844 # i18n: "extra" is a keyword
844 if 'label' not in args:
845 l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments'))
845 # i18n: "extra" is a keyword
846 raise error.ParseError(_('extra takes at least 1 argument'))
846 # i18n: "extra" is a keyword
847 # i18n: "extra" is a keyword
847 label = getstring(l[0], _('first argument to extra must be a string'))
848 label = getstring(args['label'], _('first argument to extra must be '
849 'a string'))
848 value = None
850 value = None
849
851
850 if len(l) > 1:
852 if 'value' in args:
851 # i18n: "extra" is a keyword
853 # i18n: "extra" is a keyword
852 value = getstring(l[1], _('second argument to extra must be a string'))
854 value = getstring(args['value'], _('second argument to extra must be '
855 'a string'))
853 kind, value, matcher = _stringmatcher(value)
856 kind, value, matcher = _stringmatcher(value)
854
857
855 def _matchvalue(r):
858 def _matchvalue(r):
@@ -324,6 +324,25 b' quoting needed'
324
324
325 keyword arguments
325 keyword arguments
326
326
327 $ log 'extra(branch, value=a)'
328 0
329
330 $ log 'extra(branch, a, b)'
331 hg: parse error: extra takes at most 2 arguments
332 [255]
333 $ log 'extra(a, label=b)'
334 hg: parse error: extra got multiple values for keyword argument 'label'
335 [255]
336 $ log 'extra(label=branch, default)'
337 hg: parse error: extra got an invalid argument
338 [255]
339 $ log 'extra(branch, foo+bar=baz)'
340 hg: parse error: extra got an invalid argument
341 [255]
342 $ log 'extra(unknown=branch)'
343 hg: parse error: extra got an unexpected keyword argument 'unknown'
344 [255]
345
327 $ try 'foo=bar|baz'
346 $ try 'foo=bar|baz'
328 (keyvalue
347 (keyvalue
329 ('symbol', 'foo')
348 ('symbol', 'foo')
General Comments 0
You need to be logged in to leave comments. Login now