##// END OF EJS Templates
revset: add pattern matching to 'extra' revset expression
Simon King -
r16824:f3b8c82a default
parent child Browse files
Show More
@@ -502,7 +502,12 def draft(repo, subset, x):
502 def extra(repo, subset, x):
502 def extra(repo, subset, x):
503 """``extra(label, [value])``
503 """``extra(label, [value])``
504 Changesets with the given label in the extra metadata, with the given
504 Changesets with the given label in the extra metadata, with the given
505 optional value."""
505 optional value.
506
507 If `value` starts with `re:`, the remainder of the value is treated as
508 a regular expression. To match a value that actually starts with `re:`,
509 use the prefix `literal:`.
510 """
506
511
507 l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments'))
512 l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments'))
508 label = getstring(l[0], _('first argument to extra must be a string'))
513 label = getstring(l[0], _('first argument to extra must be a string'))
@@ -510,10 +515,11 def extra(repo, subset, x):
510
515
511 if len(l) > 1:
516 if len(l) > 1:
512 value = getstring(l[1], _('second argument to extra must be a string'))
517 value = getstring(l[1], _('second argument to extra must be a string'))
518 kind, value, matcher = _stringmatcher(value)
513
519
514 def _matchvalue(r):
520 def _matchvalue(r):
515 extra = repo[r].extra()
521 extra = repo[r].extra()
516 return label in extra and (value is None or value == extra[label])
522 return label in extra and (value is None or matcher(extra[label]))
517
523
518 return [r for r in subset if _matchvalue(r)]
524 return [r for r in subset if _matchvalue(r)]
519
525
@@ -38,6 +38,9
38 0
38 0
39 1
39 1
40 2
40 2
41 $ hg log -r "extra('branch', 're:a')" --template '{rev} {branch}\n'
42 0 a
43 2 a-b-c-
41
44
42 $ hg co 1
45 $ hg co 1
43 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
46 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now