[PATCH 06 of 13] pull: move obsolescence marker exchange in the exchange module

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Tue Feb 11 19:34:20 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1391132321 28800
#      Thu Jan 30 17:38:41 2014 -0800
# Node ID fa738c733ab74929eb898d46fc27fc62a4806024
# Parent  39706924a2fdfba6e7f4475598800f7b66e8815c
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.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -6,11 +6,11 @@
 # GNU General Public License version 2 or any later version.
 
 from i18n import _
 from node import hex, nullid
 import errno
-import util, scmutil, changegroup
+import util, scmutil, changegroup, base85
 import discovery, phases, obsolete, bookmarks
 
 
 class pushoperation(object):
     """A object that represent a single push operation
@@ -332,11 +332,11 @@ class pulloperation(object):
         self.heads = heads
         # do we force pull?
         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:
             msg = _("required features are not"
                     " supported in the destination:"
@@ -409,11 +409,11 @@ def pull(repo, remote, heads=None, force
         def gettransaction():
             if tr is None:
                 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
 
         if tr is not None:
             tr.close()
@@ -421,5 +421,27 @@ def pull(repo, remote, heads=None, force
         if tr is not None:
             tr.release()
         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
+
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -382,31 +382,10 @@ def pushmarker(repo, key, old, new):
         finally:
             tr.release()
     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:
         yield marker(repo, markerdata)
 


More information about the Mercurial-devel mailing list