topic: make in-memory rebase preserve topic draft
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 26 Dec 2019 10:21:31 -0800
changeset 5229 d8ea3c829477
parent 5022 95af630d913a
topic: make in-memory rebase preserve topic The override code thought that `__init__` would return the runtime instance, but it's actually the first argument to the function (the `self` argument), so the code had no effect at all before this patch. I think the bug only affected in-memory rebase because the in-working-copy rebase used the current topic, which was set correctly since 5156a67f66a6 (topics: update current topic to the topic of newly rebased commit (issue5551), 2017-06-29).
hgext3rd/topic/__init__.py
--- a/hgext3rd/topic/__init__.py	Thu Dec 19 21:36:59 2019 -0800
+++ b/hgext3rd/topic/__init__.py	Thu Dec 26 10:21:31 2019 -0800
@@ -1282,13 +1282,11 @@
                           source=b'topic-extension')
         return orig(ui, repo, **opts)
 
-    def new_init(orig, *args, **kwargs):
-        runtime = orig(*args, **kwargs)
+    def new_init(orig, self, *args, **kwargs):
+        orig(self, *args, **kwargs)
 
-        if util.safehasattr(runtime, 'extrafns'):
-            runtime.extrafns.append(savetopic)
-
-        return runtime
+        if util.safehasattr(self, 'extrafns'):
+            self.extrafns.append(savetopic)
 
     try:
         rebase = extensions.find(b"rebase")