changeset 20476:1180c6ec5695

pull: move obsolescence marker exchange in the exchange module The obsolescence marker exchange code was already extracted during a previous cycle. We are moving the extracted functio in this module. This function will read and write data in the `pulloperation` object and I prefer to have all core function collaborating through this object in the same place. This changeset is pure code movement only. Code change for direct consumption of the `pulloperation` object will come later.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 30 Jan 2014 17:38:41 -0800
parents b79b405583af
children 2607a21bb40b
files mercurial/exchange.py mercurial/obsolete.py
diffstat 2 files changed, 25 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/exchange.py	Sat Feb 01 03:49:29 2014 -0800
+++ b/mercurial/exchange.py	Thu Jan 30 17:38:41 2014 -0800
@@ -8,7 +8,7 @@
 from i18n import _
 from node import hex, nullid
 import errno
-import util, scmutil, changegroup
+import util, scmutil, changegroup, base85
 import discovery, phases, obsolete, bookmarks
 
 
@@ -393,7 +393,7 @@
         self.force = force
 
 def pull(repo, remote, heads=None, force=False):
-    pullop = pulloperation(repo, remote, heads)
+    pullop = pulloperation(repo, remote, heads, force)
     if pullop.remote.local():
         missing = set(pullop.remote.requirements) - pullop.repo.supported
         if missing:
@@ -470,7 +470,7 @@
                 return pullop.repo.transaction(trname)
             return tr
 
-        obstr = obsolete.syncpull(pullop.repo, pullop.remote, gettransaction)
+        obstr = _pullobsolete(pullop.repo, pullop.remote, gettransaction)
         if obstr is not None:
             tr = obstr
 
@@ -482,3 +482,25 @@
         lock.release()
 
     return result
+
+def _pullobsolete(repo, remote, gettransaction):
+    """utility function to pull obsolete markers from a remote
+
+    The `gettransaction` is function that return the pull transaction, creating
+    one if necessary. We return the transaction to inform the calling code that
+    a new transaction have been created (when applicable).
+
+    Exists mostly to allow overriding for experimentation purpose"""
+    tr = None
+    if obsolete._enabled:
+        repo.ui.debug('fetching remote obsolete markers\n')
+        remoteobs = remote.listkeys('obsolete')
+        if 'dump0' in remoteobs:
+            tr = gettransaction()
+            for key in sorted(remoteobs, reverse=True):
+                if key.startswith('dump'):
+                    data = base85.b85decode(remoteobs[key])
+                    repo.obsstore.mergemarkers(tr, data)
+            repo.invalidatevolatilesets()
+    return tr
+
--- a/mercurial/obsolete.py	Sat Feb 01 03:49:29 2014 -0800
+++ b/mercurial/obsolete.py	Thu Jan 30 17:38:41 2014 -0800
@@ -384,27 +384,6 @@
     finally:
         lock.release()
 
-def syncpull(repo, remote, gettransaction):
-    """utility function to pull obsolete markers from a remote
-
-    The `gettransaction` is function that return the pull transaction, creating
-    one if necessary. We return the transaction to inform the calling code that
-    a new transaction have been created (when applicable).
-
-    Exists mostly to allow overriding for experimentation purpose"""
-    tr = None
-    if _enabled:
-        repo.ui.debug('fetching remote obsolete markers\n')
-        remoteobs = remote.listkeys('obsolete')
-        if 'dump0' in remoteobs:
-            tr = gettransaction()
-            for key in sorted(remoteobs, reverse=True):
-                if key.startswith('dump'):
-                    data = base85.b85decode(remoteobs[key])
-                    repo.obsstore.mergemarkers(tr, data)
-            repo.invalidatevolatilesets()
-    return tr
-
 def allmarkers(repo):
     """all obsolete markers known in a repository"""
     for markerdata in repo.obsstore: