Patchwork [1,of,4] pull: move return code in the pull operation object

login
register
mail settings
Submitter Pierre-Yves David
Date April 2, 2014, 8:21 p.m.
Message ID <ba28a84234c1bfbe6a92.1396470104@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4202/
State Accepted
Commit f295b2ac357906c6c45c7abdc2f2f5b6159a804a
Headers show

Comments

Pierre-Yves David - April 2, 2014, 8:21 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1396398112 25200
#      Tue Apr 01 17:21:52 2014 -0700
# Node ID ba28a84234c1bfbe6a926c4b69507f5a65864eb3
# Parent  1f109f7d1f7714581582bd3cd3f427861df784ef
pull: move return code in the pull operation object

With bundle2 we'll have multiple code path susceptible to be responsible for
adding changeset during the pull. We move it to the pull operation to simplify
this the coming logic. The one doing the adding the changegroup will set the
value.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -399,10 +399,12 @@  class pulloperation(object):
         self.common = None
         # set of pulled head
         self.rheads = None
         # list of missing changeset to fetch remotly
         self.fetch = None
+        # result of changegroup pulling (used as returng code by pull)
+        self.cgresult = None
 
     @util.propertycache
     def pulledsubset(self):
         """heads of the set of changeset target by the pull"""
         # compute target subset
@@ -448,22 +450,22 @@  def pull(repo, remote, heads=None, force
                                            heads=pullop.heads,
                                            force=force)
         pullop.common, pullop.fetch, pullop.rheads = tmp
         if not pullop.fetch:
             pullop.repo.ui.status(_("no changes found\n"))
-            result = 0
+            pullop.cgresult = 0
         else:
-            result = _pullchangeset(pullop)
+            pullop.cgresult = _pullchangeset(pullop)
 
         _pullphase(pullop)
         _pullobsolete(pullop)
         pullop.closetransaction()
     finally:
         pullop.releasetransaction()
         lock.release()
 
-    return result
+    return pullop.cgresult
 
 def _pullchangeset(pullop):
     """pull changeset from unbundle into the local repo"""
     # We delay the open of the transaction as late as possible so we
     # don't open transaction for nothing or you break future useful