[PATCH] transplant: use hex directly

timeless timeless at mozdev.org
Tue Mar 1 00:30:39 EST 2016


# HG changeset patch
# User timeless <timeless at mozdev.org>
# Date 1456808023 0
#      Tue Mar 01 04:53:43 2016 +0000
# Node ID 7e6c4a1aefec8ef0047c58a76e8775b8a14768ff
# Parent  c7f89ad87baef87f00c507545dfd4cc824bc3131
transplant: use hex directly

diff --git a/hgext/transplant.py b/hgext/transplant.py
--- a/hgext/transplant.py
+++ b/hgext/transplant.py
@@ -20,6 +20,9 @@
 from mercurial import bundlerepo, hg, merge, match
 from mercurial import patch, revlog, scmutil, util, error, cmdutil
 from mercurial import revset, templatekw, exchange
+from mercurial.node import (
+    hex,
+)
 
 class TransplantError(error.Abort):
     pass
@@ -64,7 +67,7 @@
             fp = self.opener(self.transplantfile, 'w')
             for list in self.transplants.itervalues():
                 for t in list:
-                    l, r = map(revlog.hex, (t.lnode, t.rnode))
+                    l, r = map(hex, (t.lnode, t.rnode))
                     fp.write(l + ':' + r + '\n')
             fp.close()
         self.dirty = False
@@ -241,7 +244,7 @@
             self.ui.system('%s %s %s' % (filter, util.shellquote(headerfile),
                                          util.shellquote(patchfile)),
                            environ={'HGUSER': changelog[1],
-                                    'HGREVISION': revlog.hex(node),
+                                    'HGREVISION': hex(node),
                                     },
                            onerr=error.Abort, errprefix=_('filter failed'))
             user, date, msg = self.parselog(file(headerfile))[1:4]
@@ -261,7 +264,7 @@
 
         if log:
             # we don't translate messages inserted into commits
-            message += '\n(transplanted from %s)' % revlog.hex(node)
+            message += '\n(transplanted from %s)' % hex(node)
 
         self.ui.status(_('applying %s\n') % short(node))
         self.ui.note('%s %s\n%s\n' % (user, date, message))
@@ -350,7 +353,7 @@
             p1, p2 = repo.dirstate.parents()
             if p1 != parent:
                 raise error.Abort(_('working directory not at transplant '
-                                   'parent %s') % revlog.hex(parent))
+                                   'parent %s') % hex(parent))
             if merge:
                 repo.setparents(p1, parents[1])
             modified, added, removed, deleted = repo.status()[:4]
@@ -391,11 +394,11 @@
             os.mkdir(self.path)
         series = self.opener('series', 'w')
         for rev in sorted(revmap):
-            series.write(revlog.hex(revmap[rev]) + '\n')
+            series.write(hex(revmap[rev]) + '\n')
         if merges:
             series.write('# Merges\n')
             for m in merges:
-                series.write(revlog.hex(m) + '\n')
+                series.write(hex(m) + '\n')
         series.close()
 
     def parselog(self, fp):
@@ -431,10 +434,10 @@
         fp = self.opener('journal', 'w')
         fp.write('# User %s\n' % user)
         fp.write('# Date %s\n' % date)
-        fp.write('# Node ID %s\n' % revlog.hex(p2))
-        fp.write('# Parent ' + revlog.hex(p1) + '\n')
+        fp.write('# Node ID %s\n' % hex(p2))
+        fp.write('# Parent ' + hex(p1) + '\n')
         if merge:
-            fp.write('# Parent ' + revlog.hex(p2) + '\n')
+            fp.write('# Parent ' + hex(p2) + '\n')
         fp.write(message.rstrip() + '\n')
         fp.close()
 
@@ -711,7 +714,7 @@
     """:transplanted: String. The node identifier of the transplanted
     changeset if any."""
     n = ctx.extra().get('transplant_source')
-    return n and revlog.hex(n) or ''
+    return n and hex(n) or ''
 
 def extsetup(ui):
     revsetpredicate.setup()


More information about the Mercurial-devel mailing list