transplant: add the transplanted revset predicate
authorJuan Pablo Aroztegi <juanpablo.aroztegi@openbravo.com>
Tue, 28 Sep 2010 19:36:05 +0200
changeset 12581 19dabc8a3236
parent 12580 0ae639c75b8c
child 12582 18c79cef795c
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()'
hgext/transplant.py
--- 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,