rebase: teach rebase how to copy topics
authorMatt Mackall <mpm@selenic.com>
Fri, 12 Jun 2015 16:41:10 -0500
changeset 1854 67950fcf1c69
parent 1853 8db7828751b7
child 1855 f241a00e93a7
rebase: teach rebase how to copy topics
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')))