changeset 12581:19dabc8a3236

transplant: add the transplanted revset predicate This adds support to identify a particular transplanted changeset or set of changesets. The argument is optional. Examples: hg log -r 'transplanted(1234 or 2345)' hg log -r 'transplanted()'
author Juan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
date Tue, 28 Sep 2010 19:36:05 +0200
parents 0ae639c75b8c
children 18c79cef795c
files hgext/transplant.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/transplant.py	Tue Sep 28 03:01:35 2010 +0200
+++ b/hgext/transplant.py	Tue Sep 28 19:36:05 2010 +0200
@@ -17,6 +17,7 @@
 import os, tempfile
 from mercurial import bundlerepo, changegroup, cmdutil, hg, merge, match
 from mercurial import patch, revlog, util, error, discovery
+from mercurial import revset, help
 
 class transplantentry(object):
     def __init__(self, lnode, rnode):
@@ -603,6 +604,30 @@
             source.close()
             os.unlink(bundle)
 
+def revsettransplanted(repo, subset, x):
+    if x:
+      s = revset.getset(repo, subset, x)
+    else:
+      s = subset
+    cs = set()
+    for r in xrange(0, len(repo)):
+      if repo[r].extra().get('transplant_source'):
+        cs.add(r)
+    return [r for r in s if r in cs]
+
+def revsetdoc():
+    doc = help.loaddoc('revsets')()
+    doc += _('\nAdded by the transplant extension:\n\n'
+           '``transplanted(set)``\n'
+           '  Transplanted changesets in set.\n')
+    return doc
+
+def uisetup(ui):
+    'Add the transplanted revset predicate'
+    for i in (i for i, x in enumerate(help.helptable) if x[0] == ['revsets']):
+        help.helptable[i] = (['revsets'], _("Specifying Revision Sets"), revsetdoc)
+    revset.symbols['transplanted'] = revsettransplanted
+
 cmdtable = {
     "transplant":
         (transplant,