pull: move the cgresult logic in _pullchangeset
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 01 Apr 2014 17:28:21 -0700
changeset 20899 d62319f91cb7
parent 20898 f295b2ac3579
child 20900 cb37fb91bc5a
pull: move the cgresult logic in _pullchangeset Logical follow up of the previous changeset. The `_pullchangeset` is now responsible of setting the `pullop.cgresult`.
mercurial/exchange.py
--- a/mercurial/exchange.py	Tue Apr 01 17:21:52 2014 -0700
+++ b/mercurial/exchange.py	Tue Apr 01 17:28:21 2014 -0700
@@ -455,12 +455,7 @@
                                            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()
@@ -475,6 +470,10 @@
     # 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"))
@@ -494,7 +493,8 @@
                                    "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