comparison mercurial/revset.py @ 17016:0eb522625eb2

revset: add a predicate for finding converted changesets This selects changesets added because of repo conversions. For example hg log -r "converted()" # all csets created by a convertion hg log -r "converted(rev)" # the cset converted from rev in the src repo The converted(rev) form is analogous to remote(id), where the remote repo is the source of the conversion. This can be useful for cross referencing an old repository into the current one. The source revision may be the short changeset hash or the full hash from the source repository. The local identifier isn't useful. An interesting ramification of this is if a short revision is specified, it may cause more than one changeset to be selected. (e.g. converted(6) matches changesets with a convert_revision field of 6e..e and 67..0) The convert.hg.saverev option must have been specified when converting the hg source repository for this to work. The other sources automatically embed the converted marker.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 13 May 2012 01:12:26 -0400 (2012-05-13)
parents b6efeb27e733
children 42c472877825
comparison
equal deleted inserted replaced
17001:88f650208c32 17016:0eb522625eb2
488 if m(f): 488 if m(f):
489 s.append(r) 489 s.append(r)
490 break 490 break
491 return s 491 return s
492 492
493 def converted(repo, subset, x):
494 """``converted([id])``
495 Changesets converted from the given identifier in the old repository if
496 present, or all converted changesets if no identifier is specified.
497 """
498
499 # There is exactly no chance of resolving the revision, so do a simple
500 # string compare and hope for the best
501
502 # i18n: "converted" is a keyword
503 rev = None
504 l = getargs(x, 0, 1, _('converted takes one or no arguments'))
505 if l:
506 rev = getstring(l[0], _('converted requires a revision'))
507
508 def _matchvalue(r):
509 source = repo[r].extra().get('convert_revision', None)
510 return source is not None and (rev is None or source.startswith(rev))
511
512 return [r for r in subset if _matchvalue(r)]
513
493 def date(repo, subset, x): 514 def date(repo, subset, x):
494 """``date(interval)`` 515 """``date(interval)``
495 Changesets within the interval, see :hg:`help dates`. 516 Changesets within the interval, see :hg:`help dates`.
496 """ 517 """
497 # i18n: "date" is a keyword 518 # i18n: "date" is a keyword
1300 "bookmark": bookmark, 1321 "bookmark": bookmark,
1301 "branch": branch, 1322 "branch": branch,
1302 "children": children, 1323 "children": children,
1303 "closed": closed, 1324 "closed": closed,
1304 "contains": contains, 1325 "contains": contains,
1326 "converted": converted,
1305 "date": date, 1327 "date": date,
1306 "desc": desc, 1328 "desc": desc,
1307 "descendants": descendants, 1329 "descendants": descendants,
1308 "_firstdescendants": _firstdescendants, 1330 "_firstdescendants": _firstdescendants,
1309 "draft": draft, 1331 "draft": draft,