Patchwork [08,of,16] exchangeutil: Move push parameter as pulloperation attributes

login
register
mail settings
Submitter Pierre-Yves David
Date April 17, 2013, 3:58 p.m.
Message ID <2aa3dc70d3130eeb31e7.1366214323@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/1393/
State Deferred, archived
Headers show

Comments

Pierre-Yves David - April 17, 2013, 3:58 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1366206748 -7200
#      Wed Apr 17 15:52:28 2013 +0200
# Node ID 2aa3dc70d3130eeb31e756e60c9956e756e0e03c
# Parent  e98361603d55211f03b4a2a6aa8af2f92d9661b5
exchangeutil: Move push parameter as pulloperation attributes

This permits future slicing of the god function in multiple smaller one.

Patch

diff --git a/mercurial/exchangeutil.py b/mercurial/exchangeutil.py
--- a/mercurial/exchangeutil.py
+++ b/mercurial/exchangeutil.py
@@ -236,19 +236,28 @@  class pushoperation(object):
                                            ' failed!\n') % k)
 
 
 class pulloperation(object):
 
-    def perform(self, repo, remote, heads=None, force=False):
+    def __init__(self, repo, remote, heads=None, force=False):
+        self.repo = repo
+        self.remote = remote
+        self.heads = heads
+        self.force = force
+
+    def perform(self):
+        repo = self.repo
+        remote = self.remote
+        heads = self.heads
         # don't open transaction for nothing or you break future useful
         # rollback call
         tr = None
         trname = 'pull\n' + util.hidepassword(remote.url())
         lock = repo.lock()
         try:
             tmp = discovery.findcommonincoming(repo, remote, heads=heads,
-                                               force=force)
+                                               force=self.force)
             common, fetch, rheads = tmp
             if not fetch:
                 repo.ui.status(_("no changes found\n"))
                 added = []
                 result = 0
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1650,12 +1650,12 @@  class localrepository(object):
             r.append(l)
 
         return r
 
     def pull(self, remote, heads=None, force=False):
-        pull = exchangeutil.pulloperation()
-        return pull.perform(self, remote, heads, force)
+        pull = exchangeutil.pulloperation(self, remote, heads, force)
+        return pull.perform()
 
     def checkpush(self, force, revs):
         """Extensions can override this function if additional checks have
         to be performed before pushing, or call it if they override push
         command.