[PATCH 2 of 3 topic-ext] rebase: teach rebase how to copy topics

Matt Mackall mpm at selenic.com
Mon Jun 15 15:21:56 CDT 2015


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1434145270 18000
#      Fri Jun 12 16:41:10 2015 -0500
# Node ID 97d0a52e26d801ba163e324e16aedb616a18a387
# Parent  eae26502e44f3bce3da89647c03f6db62f0e69b7
rebase: teach rebase how to copy topics

diff -r eae26502e44f -r 97d0a52e26d8 src/topic/__init__.py
--- a/src/topic/__init__.py	Fri Jun 12 16:39:39 2015 -0500
+++ b/src/topic/__init__.py	Fri Jun 12 16:41:10 2015 -0500
@@ -163,6 +163,24 @@
     finally:
         wlock.release()
 
+def _fixrebase(loaded):
+    if not loaded:
+        return
+
+    def savetopic(ctx, extra):
+        e = ctx.extra()
+        if constants.extrakey in e:
+            print "copying topic"
+            extra[constants.extrakey] = e[constants.extrakey]
+
+    def newmakeextrafn(orig, copiers):
+        return orig(copiers + [savetopic])
+
+    rebase = extensions.find("rebase")
+    extensions.wrapfunction(rebase, '_makeextrafn', newmakeextrafn)
+
+extensions.afterloaded('rebase', _fixrebase)
+
 entry = extensions.wrapcommand(commands.table, 'commit', commitwrap)
 entry[1].append(('t', 'topic', '',
                  _("use specified topic"), _('TOPIC')))


More information about the Mercurial-devel mailing list