[PATCH 3 of 6] push: use `exchange.push` in `commands.push`

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Sep 25 13:46:44 CDT 2014

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1411634379 25200
#      Thu Sep 25 01:39:39 2014 -0700
# Node ID df847d3fe4044027e189a290aab75643d99cff0d
# Parent  e91c1379d9de4abb6d4b44eda75386f857c77ca6
push: use `exchange.push` in `commands.push`

To gain access all results from the push, we need to have access to the
`pushoperation` object. We call `exchange.push` to do so.

It is impossible to just change the `localrepo.push` signature because the
chance may be too subtle to be caugh by external extension wrapping

This mean we'll have to kill `localrepo.push` because just using
`exchange.push` in `commands.py`, would silently disable all wrapping around
`localrepo.push` by third party extension. So we'll remove it in later
changeset to get such extension to fail noisily.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -4972,14 +4972,14 @@ def push(ui, repo, dest=None, **opts):
             result = c.sub(s).push(opts)
             if result == 0:
                 return not result
         del repo._subtoppath
-    result = repo.push(other, opts.get('force'), revs=revs,
-                       newbranch=opts.get('new_branch'))
-    result = not result
+    pushop = exchange.push(repo, other, opts.get('force'), revs=revs,
+                           newbranch=opts.get('new_branch'))
+    result = not pushop.cgresult
     if opts.get('bookmark'):
         bresult = bookmarks.pushtoremote(ui, repo, other, opts['bookmark'])
         if bresult == 2:
             return 2

More information about the Mercurial-devel mailing list