diff hgext3rd/topic/flow.py @ 3204:a342c454ccf3 stable

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.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 24 Nov 2017 22:36:57 +0100
parents 90515d0bfb08
children 5dfe4e5cf9e4
line wrap: on
line diff
--- 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