Patchwork [06,of,16] push: extract obsolescence marker pushing in a dedicated method

login
register
mail settings
Submitter Pierre-Yves David
Date April 17, 2013, 3:58 p.m.
Message ID <ebab1a6407d1d19dd84a.1366214321@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/1391/
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 1366213378 -7200
#      Wed Apr 17 17:42:58 2013 +0200
# Node ID ebab1a6407d1d19dd84a4ad7721c5dbfcad31b68
# Parent  e8228b2e83a7aa25d3a6be434e728a51d0613cef
push: extract obsolescence marker pushing in a dedicated method

Having a dedicated function will allows us to experiment with other exchange
strategy in extension. We currently have not solid clues about how to do it
right. Being able to experiment is vital.

Patch

diff --git a/mercurial/exchangeutil.py b/mercurial/exchangeutil.py
--- a/mercurial/exchangeutil.py
+++ b/mercurial/exchangeutil.py
@@ -187,30 +187,35 @@  class pushoperation(object):
                                            str(phases.draft),
                                            str(phases.public))
                         if not r:
                             repo.ui.warn(_('updating %s to public failed!\n')
                                             % newremotehead)
-                repo.ui.debug('try to push obsolete markers to remote\n')
-                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)
+                self._pushobsolescence()
             finally:
                 if lock is not None:
                     lock.release()
         finally:
             locallock.release()
         self._pushbookmarks()
         return ret
 
+    def _pushobsolescence(self):
+        """Send local obsolescence marker to remote"""
+        self.repo.ui.debug('try to push obsolete markers to remote\n')
+        if (obsolete._enabled and self.repo.obsstore and
+            'obsolete' in self.remote.listkeys('namespaces')):
+            rslts = []
+            remotedata = self.repo.listkeys('obsolete')
+            for key in sorted(remotedata, reverse=True):
+                # reverse sort to ensure we end with dump0
+                data = remotedata[key]
+                rslts.append(self.remote.pushkey('obsolete', key, '', data))
+            if [r for r in rslts if not r]:
+                msg = _('failed to push some obsolete markers!\n')
+                self.repo.ui.warn(msg)
+
+
     def _pushbookmarks(self):
         """synchronise local bookmark position to remote"""
         repo = self.repo
         remote = self.remote
         unfi = repo.unfiltered()