Mercurial > public > mercurial-scm > hg
comparison mercurial/revset.py @ 16661:de4b42daf396
revset: add function for matching extra data (issue2767)
author | Henrik Stuart <hg@hstuart.dk> |
---|---|
date | Sat, 12 May 2012 10:20:57 +0200 |
parents | b6081c2c4647 |
children | 525fdb738975 |
comparison
equal
deleted
inserted
replaced
16660:2a71cc53f244 | 16661:de4b42daf396 |
---|---|
464 Changeset in draft phase.""" | 464 Changeset in draft phase.""" |
465 getargs(x, 0, 0, _("draft takes no arguments")) | 465 getargs(x, 0, 0, _("draft takes no arguments")) |
466 pc = repo._phasecache | 466 pc = repo._phasecache |
467 return [r for r in subset if pc.phase(repo, r) == phases.draft] | 467 return [r for r in subset if pc.phase(repo, r) == phases.draft] |
468 | 468 |
469 def extra(repo, subset, x): | |
470 """``extra(label, [value])`` | |
471 Changesets with the given label in the extra metadata, with the given | |
472 optional value.""" | |
473 | |
474 l = getargs(x, 1, 2, _('extra takes at least 1 and at most 2 arguments')) | |
475 label = getstring(l[0], _('first argument to extra must be a string')) | |
476 value = None | |
477 | |
478 if len(l) > 1: | |
479 value = getstring(l[1], _('second argument to extra must be a string')) | |
480 | |
481 def _matchvalue(r): | |
482 extra = repo[r].extra() | |
483 return label in extra and (value is None or value == extra[label]) | |
484 | |
485 return [r for r in subset if _matchvalue(r)] | |
486 | |
469 def filelog(repo, subset, x): | 487 def filelog(repo, subset, x): |
470 """``filelog(pattern)`` | 488 """``filelog(pattern)`` |
471 Changesets connected to the specified filelog. | 489 Changesets connected to the specified filelog. |
472 """ | 490 """ |
473 | 491 |
1145 "date": date, | 1163 "date": date, |
1146 "desc": desc, | 1164 "desc": desc, |
1147 "descendants": descendants, | 1165 "descendants": descendants, |
1148 "_firstdescendants": _firstdescendants, | 1166 "_firstdescendants": _firstdescendants, |
1149 "draft": draft, | 1167 "draft": draft, |
1168 "extra": extra, | |
1150 "file": hasfile, | 1169 "file": hasfile, |
1151 "filelog": filelog, | 1170 "filelog": filelog, |
1152 "first": first, | 1171 "first": first, |
1153 "follow": follow, | 1172 "follow": follow, |
1154 "_followfirst": _followfirst, | 1173 "_followfirst": _followfirst, |