Patchwork [2,of,4] pull: move the cgresult logic in _pullchangeset

login
register
mail settings
Submitter Pierre-Yves David
Date April 2, 2014, 8:21 p.m.
Message ID <5666cf55a987cd4df991.1396470105@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/4201/
State Accepted
Commit d62319f91cb7a751f0d2eebe4a404f9ac7efab89
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 1396398501 25200
#      Tue Apr 01 17:28:21 2014 -0700
# Node ID 5666cf55a987cd4df9919ced3f48ed16e1381590
# Parent  ba28a84234c1bfbe6a926c4b69507f5a65864eb3
pull: move the cgresult logic in _pullchangeset

Logical follow up of the previous changeset. The `_pullchangeset` is now
responsible of setting the `pullop.cgresult`.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -448,16 +448,11 @@  def pull(repo, remote, heads=None, force
         tmp = discovery.findcommonincoming(pullop.repo.unfiltered(),
                                            pullop.remote,
                                            heads=pullop.heads,
                                            force=force)
         pullop.common, pullop.fetch, pullop.rheads = tmp
-        if not pullop.fetch:
-            pullop.repo.ui.status(_("no changes found\n"))
-            pullop.cgresult = 0
-        else:
-            pullop.cgresult = _pullchangeset(pullop)
-
+        _pullchangeset(pullop)
         _pullphase(pullop)
         _pullobsolete(pullop)
         pullop.closetransaction()
     finally:
         pullop.releasetransaction()
@@ -468,10 +463,14 @@  def pull(repo, remote, heads=None, force
 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
     # rollback call
+    if not pullop.fetch:
+            pullop.repo.ui.status(_("no changes found\n"))
+            pullop.cgresult = 0
+            return
     pullop.gettransaction()
     if pullop.heads is None and list(pullop.common) == [nullid]:
         pullop.repo.ui.status(_("requesting all changes\n"))
     elif pullop.heads is None and pullop.remote.capable('changegroupsubset'):
         # issue1320, avoid a race if remote changed after discovery
@@ -487,11 +486,12 @@  def _pullchangeset(pullop):
         raise util.Abort(_("partial pull cannot be done because "
                                    "other repository doesn't support "
                                    "changegroupsubset."))
     else:
         cg = pullop.remote.changegroupsubset(pullop.fetch, pullop.heads, 'pull')
-    return pullop.repo.addchangegroup(cg, 'pull', pullop.remote.url())
+    pullop.cgresult = pullop.repo.addchangegroup(cg, 'pull',
+                                                 pullop.remote.url())
 
 def _pullphase(pullop):
     # Get remote phases data from remote
     remotephases = pullop.remote.listkeys('phases')
     publishing = bool(remotephases.get('publishing', False))