[PATCH 05 of 13] pull: move `force` argument into pull object

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Wed Feb 12 01:34:19 UTC 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1391255369 28800
#      Sat Feb 01 03:49:29 2014 -0800
# Node ID 39706924a2fdfba6e7f4475598800f7b66e8815c
# Parent  afdcc38e482f72f10c6b64c808a5a10000cc7bf1
pull: move `force` argument into pull object

One more step toward a more modular pulh function.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -321,17 +321,19 @@ class pulloperation(object):
 
     A new should be created at the begining of each push and discarded
     afterward.
     """
 
-    def __init__(self, repo, remote, heads=None):
+    def __init__(self, repo, remote, heads=None, force=False):
         # repo we pull from
         self.repo = repo
         # repo we pull to
         self.remote = remote
         # revision we try to pull (None is "all")
         self.heads = heads
+        # do we force pull?
+        self.force = force
 
 def pull(repo, remote, heads=None, force=False):
     pullop = pulloperation(repo, remote, heads)
     if pullop.remote.local():
         missing = set(pullop.remote.requirements) - pullop.repo.supported
@@ -348,20 +350,21 @@ def pull(repo, remote, heads=None, force
     lock = pullop.repo.lock()
     try:
         tmp = discovery.findcommonincoming(pullop.repo.unfiltered(),
                                            pullop.remote,
                                            heads=pullop.heads,
-                                           force=force)
+                                           force=pullop.force)
         common, fetch, rheads = tmp
         if not fetch:
             pullop.repo.ui.status(_("no changes found\n"))
             result = 0
         else:
             tr = pullop.repo.transaction(trname)
             if pullop.heads is None and list(common) == [nullid]:
                 pullop.repo.ui.status(_("requesting all changes\n"))
-            elif pullop.heads is None and pullop.remote.capable('changegroupsubset'):
+            elif (pullop.heads is None
+                  and pullop.remote.capable('changegroupsubset')):
                 # issue1320, avoid a race if remote changed after discovery
                 pullop.heads = rheads
 
             if pullop.remote.capable('getbundle'):
                 # TODO: get bundlecaps from remote
@@ -372,11 +375,12 @@ def pull(repo, remote, heads=None, force
             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, 'pull')
+                cg = pullop.remote.changegroupsubset(fetch, pullop.heads,
+                                                     'pull')
             result = pullop.repo.addchangegroup(cg, 'pull',
                                                 pullop.remote.url())
 
         # compute target subset
         if pullop.heads is None:



More information about the Mercurial-devel mailing list