diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -490,6 +490,27 @@ def contains(repo, subset, x): 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 @@ symbols = { "children": children, "closed": closed, "contains": contains, + "converted": converted, "date": date, "desc": desc, "descendants": descendants, diff --git a/tests/test-convert.t b/tests/test-convert.t --- a/tests/test-convert.t +++ b/tests/test-convert.t @@ -396,3 +396,52 @@ test bogus URL $ 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 +