rebase: update the rebase wrapping to works with hg 4.6
authorBoris Feld <boris.feld@octobus.net>
Thu, 29 Mar 2018 14:13:13 +0200
changeset 3612 33b718191bc9
parent 3610 145dab8c60c9
child 3613 bf583a8dc637
rebase: update the rebase wrapping to works with hg 4.6 Mercurial core commit bd0086bd3af4 removed _makeextrafn hence breaking our wrapping. Update the code to wrap rebaseruntime directly in a way that's compatible with hg 4.1+.
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Fri Mar 23 12:44:06 2018 +0530
+++ b/hgext3rd/topic/__init__.py	Thu Mar 29 14:13:13 2018 +0200
@@ -1178,17 +1178,22 @@
         if ctx.topic():
             extra[constants.extrakey] = ctx.topic()
 
-    def newmakeextrafn(orig, copiers):
-        return orig(copiers + [savetopic])
-
     def setrebaseconfig(orig, ui, repo, **opts):
         repo.ui.setconfig('experimental', 'topicrebase', 'yes',
                           source='topic-extension')
         return orig(ui, repo, **opts)
 
+    def new_init(orig, *args, **kwargs):
+        runtime = orig(*args, **kwargs)
+
+        if util.safehasattr(runtime, 'extrafns'):
+            runtime.extrafns.append(savetopic)
+
+        return runtime
+
     try:
         rebase = extensions.find("rebase")
-        extensions.wrapfunction(rebase, '_makeextrafn', newmakeextrafn)
+        extensions.wrapfunction(rebase.rebaseruntime, '__init__', new_init)
         # This exists to store in the config that rebase is running so that we can
         # update the topic according to rebase. This is a hack and should be removed
         # when we have better options.