changeset 1854:67950fcf1c69

rebase: teach rebase how to copy topics
author Matt Mackall <mpm@selenic.com>
date Fri, 12 Jun 2015 16:41:10 -0500
parents 8db7828751b7
children f241a00e93a7
files src/topic/__init__.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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')))