# HG changeset patch # User Matt Harbison # Date 2012-06-06 00:35:34 # Node ID 42c472877825575a109cc0ef54e311194b827335 # Parent 0eb522625eb2cbefe9340a136d12b0ad66602c55 revset: add a utility for obtaining the source of a given rev graft, transplant and rebase all embed a different type of source marker in extra, and each with a different name. The current implementation of each is such that there will never be more than one of these markers on a node. Note that the rebase marker can only be resolved if the source is still present, which excludes the typical rebase usage (without --keep) from consideration (unless the resulting bundle in strip-backup is overlayed). There probably isn't any reason to use rebase --keep as a substitute for transplant or graft at this point, but maybe there was at one point and there are even a few rebases in the hg repo, so it may be of historical interest. diff --git a/mercurial/revset.py b/mercurial/revset.py --- a/mercurial/revset.py +++ b/mercurial/revset.py @@ -186,6 +186,16 @@ def getset(repo, subset, x): raise error.ParseError(_("missing argument")) return methods[x[0]](repo, subset, *x[1:]) +def _getrevsource(repo, r): + extra = repo[r].extra() + for label in ('source', 'transplant_source', 'rebase_source'): + if label in extra: + try: + return repo[extra[label]].rev() + except error.RepoLookupError: + pass + return None + # operator methods def stringset(repo, subset, x):