pusoperation: wrap pushoperation __init__ directly stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 24 Nov 2017 22:36:57 +0100
branchstable
changeset 3204 a342c454ccf3
parent 3203 34d5c97a3dee
child 3205 0b85da2e8e2a
child 3208 c9e7b8db9900
pusoperation: wrap pushoperation __init__ directly This is how remote names does it. Using the same method should helps with compatibility when mixing the two extensions.
hgext3rd/topic/flow.py
--- a/hgext3rd/topic/flow.py	Thu Nov 23 00:29:52 2017 +0100
+++ b/hgext3rd/topic/flow.py	Fri Nov 24 22:36:57 2017 +0100
@@ -41,11 +41,10 @@
         newargs['opargs']['publish'] = True
     return orig(repo, remote, *args, **newargs)
 
-def extendpushoperation(orig, *args, **kwargs):
+def extendpushoperation(orig, self, *args, **kwargs):
     publish = kwargs.pop('publish', False)
-    op = orig(*args, **kwargs)
-    op.publish = publish
-    return op
+    orig(self, *args, **kwargs)
+    self.publish = publish
 
 def wrapphasediscovery(orig, pushop):
     orig(pushop)
@@ -64,6 +63,7 @@
     entry = extensions.wrapcommand(commands.table, 'push', wrappush)
     entry[1].append(('', 'publish', False,
                     _('push the changeset as public')))
-    extensions.wrapfunction(exchange, 'pushoperation', extendpushoperation)
+    extensions.wrapfunction(exchange.pushoperation, '__init__',
+                            extendpushoperation)
     extensions.wrapfunction(exchange, '_pushdiscoveryphase', wrapphasediscovery)
     exchange.pushdiscoverymapping['phase'] = exchange._pushdiscoveryphase