[PATCH 02 of 11 (19 more to go)] push: move obsolescence marker exchange in the exchange module

pierre-yves.david at ens-lyon.org pierre-yves.david at ens-lyon.org
Mon Feb 10 18:01:30 CST 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at logilab.fr>
# Date 1391133287 28800
#      Thu Jan 30 17:54:47 2014 -0800
# Node ID 34c68d39d14886e07b7e4a924a8b5c63dd9f7acf
# Parent  b1956c52aad84168bbb1baa1c3285c5e313e1bc4
push: 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 `pushoperation` 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 `pushoperation` object will come later.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -245,21 +245,37 @@ def push(repo, remote, force=False, revs
                                               str(phases.public))
                     if not r:
                         pushop.ui.warn(_('updating %s to public failed!\n')
                                        % newremotehead)
             pushop.ui.debug('try to push obsolete markers to remote\n')
-            obsolete.syncpush(pushop.repo, pushop.remote)
+            _pushobsolete(pushop.repo, pushop.remote)
         finally:
             if lock is not None:
                 lock.release()
     finally:
         if locallock is not None:
             locallock.release()
 
     _pushbookmark(pushop)
     return ret
 
+def _pushobsolete(repo, remote):
+    """utility function to push obsolete markers to a remote
+
+    Exist mostly to allow overriding for experimentation purpose"""
+    if (obsolete._enabled and repo.obsstore and
+        'obsolete' in remote.listkeys('namespaces')):
+        rslts = []
+        remotedata = repo.listkeys('obsolete')
+        for key in sorted(remotedata, reverse=True):
+            # reverse sort to ensure we end with dump0
+            data = remotedata[key]
+            rslts.append(remote.pushkey('obsolete', key, '', data))
+        if [r for r in rslts if not r]:
+            msg = _('failed to push some obsolete markers!\n')
+            repo.ui.warn(msg)
+
 def _pushbookmark(pushop):
     """Update bookmark position on remote"""
     ui = pushop.ui
     repo = pushop.repo.unfiltered()
     remote = pushop.remote
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -382,26 +382,10 @@ def pushmarker(repo, key, old, new):
         finally:
             tr.release()
     finally:
         lock.release()
 
-def syncpush(repo, remote):
-    """utility function to push obsolete markers to a remote
-
-    Exist mostly to allow overriding for experimentation purpose"""
-    if (_enabled and repo.obsstore and
-        'obsolete' in remote.listkeys('namespaces')):
-        rslts = []
-        remotedata = repo.listkeys('obsolete')
-        for key in sorted(remotedata, reverse=True):
-            # reverse sort to ensure we end with dump0
-            data = remotedata[key]
-            rslts.append(remote.pushkey('obsolete', key, '', data))
-        if [r for r in rslts if not r]:
-            msg = _('failed to push some obsolete markers!\n')
-            repo.ui.warn(msg)
-
 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


More information about the Mercurial-devel mailing list