Patchwork [13,of,16] push: turn return value into a attribute

login
register
mail settings
Submitter Pierre-Yves David
Date April 17, 2013, 3:58 p.m.
Message ID <99eb16416b76967917af.1366214328@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/1395/
State Deferred, archived
Headers show

Comments

Pierre-Yves David - April 17, 2013, 3:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1366211199 -7200
#      Wed Apr 17 17:06:39 2013 +0200
# Node ID 99eb16416b76967917af430896db6628431951e0
# Parent  9b8ee7a0d0f9c3c047f0fb14ca90d2796dd5deb1
push: turn return value into a attribute

This return value hold valuable information about what was actually pushed. It
is likely to be useful for other method.

Patch

diff --git a/mercurial/exchangeutil.py b/mercurial/exchangeutil.py
--- a/mercurial/exchangeutil.py
+++ b/mercurial/exchangeutil.py
@@ -24,10 +24,12 @@  class pushoperation(object):
         self.newbranch = newbranch
 
         self._outgoing = None    # discovery.outgoing object
         self._remoteheads = None # know remote head before the push
 
+        self._ret = None # push operation return
+
     def perform(self):
         '''Push outgoing changesets (limited by revs) from the current
         repository to remote. Return an integer:
           - None means nothing to push
           - 0 means HTTP error
@@ -59,15 +61,14 @@  class pushoperation(object):
 
                 if not self._outgoing.missing:
                     # nothing to push
                     scmutil.nochangesfound(unfi.ui, unfi,
                                            self._outgoing.excluded)
-                    ret = None
                 else:
-                    ret = self._pushbundle()
+                    self._ret = self._pushbundle()
 
-                if ret:
+                if self._ret:
                     # push succeed, synchronize target of the push
                     cheads = self._outgoing.missingheads
                 elif self.revs is None:
                     # All out push fails. synchronize all common
                     cheads = self._outgoing.commonheads
@@ -96,11 +97,11 @@  class pushoperation(object):
                     cheads.extend(c.node() for c in revset)
                 # even when we don't push, exchanging phase data is useful
                 remotephases = remote.listkeys('phases')
                 if (repo.ui.configbool('ui', '_usedassubrepo', False)
                     and remotephases    # server supports phases
-                    and ret is None # nothing was pushed
+                    and self._ret is None # nothing was pushed
                     and remotephases.get('publishing', False)):
                     # When:
                     # - this is a subrepo push
                     # - and remote support phase
                     # - and no changeset was pushed
@@ -142,11 +143,11 @@  class pushoperation(object):
                 if lock is not None:
                     lock.release()
         finally:
             locallock.release()
         self._pushbookmarks()
-        return ret
+        return self._ret
 
     def _processoutgoing(self):
         """call discovery to find outgoing changeset and validate it content
         """
         unfi = self.repo.unfiltered()