Patchwork [12,of,13] pull: move `fetch` subset into the object

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 12, 2014, 1:34 a.m.
Message ID <bcf91cad6594c122f297.1392168866@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3611/
State Accepted
Commit 76e66654f74ebfde66ba87d007ecc61b1549e193
Headers show

Comments

Pierre-Yves David - Feb. 12, 2014, 1:34 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1392159098 28800
#      Tue Feb 11 14:51:38 2014 -0800
# Node ID bcf91cad6594c122f297dcc025b7cb51182babc8
# Parent  04223fff05d98b5da574c70dec2505009b422c50
pull: move `fetch` subset into the object

Tree discovey use a `fetch` variable to know what is being pulled. We move this
information in the `pulloperation` object. This make it possible to extract the
changeset pulling logic into its own function.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -338,10 +338,12 @@  class pulloperation(object):
         self._tr = None
         # set of common changeset between local and remote before pull
         self.common = None
         # set of pulled head
         self.rheads = None
+        # list of missing changeset to fetch remotly
+        self.fetch = None
 
     @util.propertycache
     def pulledsubset(self):
         """heads of the set of changeset target by the pull"""
         # compute target subset
@@ -384,12 +386,12 @@  def pull(repo, remote, heads=None, force
     try:
         tmp = discovery.findcommonincoming(pullop.repo.unfiltered(),
                                            pullop.remote,
                                            heads=pullop.heads,
                                            force=pullop.force)
-        pullop.common, fetch, pullop.rheads = tmp
-        if not fetch:
+        pullop.common, pullop.fetch, pullop.rheads = tmp
+        if not pullop.fetch:
             pullop.repo.ui.status(_("no changes found\n"))
             result = 0
         else:
             # We delay the open of the transaction as late as possible so we
             # don't open transaction for nothing or you break future useful
@@ -407,17 +409,18 @@  def pull(repo, remote, heads=None, force
                 cg = pullop.remote.getbundle('pull',
                                              common=pullop.common,
                                              heads=(pullop.heads
                                                    or pullop.rheads))
             elif pullop.heads is None:
-                cg = pullop.remote.changegroup(fetch, 'pull')
+                cg = pullop.remote.changegroup(pullop.fetch, 'pull')
             elif not pullop.remote.capable('changegroupsubset'):
                 raise util.Abort(_("partial pull cannot be done because "
                                        "other repository doesn't support "
                                        "changegroupsubset."))
             else:
-                cg = pullop.remote.changegroupsubset(fetch, pullop.heads,
+                cg = pullop.remote.changegroupsubset(pullop.fetch,
+                                                     pullop.heads,
                                                      'pull')
             result = pullop.repo.addchangegroup(cg, 'pull',
                                                 pullop.remote.url())
 
         _pullphase(pullop)