Mercurial > hg
changeset 17002: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 |
parents | 88f650208c32 |
children | 42c472877825 |
files | mercurial/revset.py tests/test-convert.t |
diffstat | 2 files changed, 71 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/revset.py Wed Jun 20 12:30:16 2012 -0500 +++ b/mercurial/revset.py Sun May 13 01:12:26 2012 -0400 @@ -490,6 +490,27 @@ break return s +def converted(repo, subset, x): + """``converted([id])`` + Changesets converted from the given identifier in the old repository if + present, or all converted changesets if no identifier is specified. + """ + + # There is exactly no chance of resolving the revision, so do a simple + # string compare and hope for the best + + # i18n: "converted" is a keyword + rev = None + l = getargs(x, 0, 1, _('converted takes one or no arguments')) + if l: + rev = getstring(l[0], _('converted requires a revision')) + + def _matchvalue(r): + source = repo[r].extra().get('convert_revision', None) + return source is not None and (rev is None or source.startswith(rev)) + + return [r for r in subset if _matchvalue(r)] + def date(repo, subset, x): """``date(interval)`` Changesets within the interval, see :hg:`help dates`. @@ -1302,6 +1323,7 @@ "children": children, "closed": closed, "contains": contains, + "converted": converted, "date": date, "desc": desc, "descendants": descendants,
--- a/tests/test-convert.t Wed Jun 20 12:30:16 2012 -0500 +++ b/tests/test-convert.t Sun May 13 01:12:26 2012 -0400 @@ -396,3 +396,52 @@ $ hg convert -q bzr+ssh://foobar@selenic.com/baz baz abort: bzr+ssh://foobar@selenic.com/baz: missing or unsupported repository [255] + +test revset converted() lookup + + $ hg --config convert.hg.saverev=True convert a c + initializing destination c repository + scanning source... + sorting... + converting... + 4 a + 3 b + 2 c + 1 d + 0 e + $ echo f > c/f + $ hg -R c ci -d'0 0' -Amf + adding f + created new head + $ hg -R c log -r "converted(09d945a62ce6)" + changeset: 1:98c3dd46a874 + user: test + date: Thu Jan 01 00:00:01 1970 +0000 + summary: b + + $ hg -R c log -r "converted()" + changeset: 0:31ed57b2037c + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: a + + changeset: 1:98c3dd46a874 + user: test + date: Thu Jan 01 00:00:01 1970 +0000 + summary: b + + changeset: 2:3b9ca06ef716 + user: test + date: Thu Jan 01 00:00:02 1970 +0000 + summary: c + + changeset: 3:4e0debd37cf2 + user: test + date: Thu Jan 01 00:00:03 1970 +0000 + summary: d + + changeset: 4:9de3bc9349c5 + user: test + date: Thu Jan 01 00:00:04 1970 +0000 + summary: e +