Mercurial > public > mercurial-scm > hg-stable
diff mercurial/revset.py @ 25706:b7f53c474e2c
revset: port extra() to support keyword arguments
This is an example to show how keyword arguments are processed.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 28 Jun 2015 22:57:33 +0900 |
parents | 48919d246a47 |
children | d50677c3bf44 |
line wrap: on
line diff
--- a/mercurial/revset.py Sat Jun 27 17:25:01 2015 +0900 +++ b/mercurial/revset.py Sun Jun 28 22:57:33 2015 +0900 @@ -840,16 +840,19 @@ a regular expression. To match a value that actually starts with `re:`, use the prefix `literal:`. """ - - # i18n: "extra" is a keyword - l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments')) + args = getkwargs(x, 'extra', 'label value') + if 'label' not in args: + # i18n: "extra" is a keyword + raise error.ParseError(_('extra takes at least 1 argument')) # i18n: "extra" is a keyword - label = getstring(l[0], _('first argument to extra must be a string')) + label = getstring(args['label'], _('first argument to extra must be ' + 'a string')) value = None - if len(l) > 1: + if 'value' in args: # i18n: "extra" is a keyword - value = getstring(l[1], _('second argument to extra must be a string')) + value = getstring(args['value'], _('second argument to extra must be ' + 'a string')) kind, value, matcher = _stringmatcher(value) def _matchvalue(r):