Patchwork [10,of,16] pull: extract obsolescence marker pulling in a dedicated method

login
register
mail settings
Submitter Pierre-Yves David
Date April 17, 2013, 3:58 p.m.
Message ID <bdd829b196108ee50990.1366214325@crater1.logilab.fr>
Download mbox | patch
Permalink /patch/1394/
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 1366207506 -7200
#      Wed Apr 17 16:05:06 2013 +0200
# Node ID bdd829b196108ee5099021f0a4c7b56c7a3af078
# Parent  e6ecd45da44df1349d05615753963759a5b52ef8
pull: extract obsolescence marker pulling in a dedicated method

Having a dedicated function will allows us to experiment with other exchange
strategy in extension. We 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
@@ -312,24 +312,28 @@  class pulloperation(object):
             else:
                 # Remote is old or publishing all common changesets
                 # should be seen as public
                 phases.advanceboundary(repo, phases.public, subset)
 
-            if obsolete._enabled:
-                repo.ui.debug('fetching remote obsolete markers\n')
-                remoteobs = remote.listkeys('obsolete')
-                if 'dump0' in remoteobs:
-                    if self._tr is None:
-                        self._tr = repo.transaction(self._trname)
-                    for key in sorted(remoteobs, reverse=True):
-                        if key.startswith('dump'):
-                            data = base85.b85decode(remoteobs[key])
-                            repo.obsstore.mergemarkers(self._tr, data)
-                    repo.invalidatevolatilesets()
+            self._pullobsolescence()  # may touch self._tr
             if self._tr is not None:
                 self._tr.close()
         finally:
             if self._tr is not None:
                 self._tr.release()
             lock.release()
 
         return result
+
+    def _pullobsolescence(self):
+        """Pull new obsolescence marker from remote"""
+        if obsolete._enabled:
+            self.repo.ui.debug('fetching remote obsolete markers\n')
+            remoteobs = self.remote.listkeys('obsolete')
+            if 'dump0' in remoteobs:
+                if self._tr is None:
+                    self._tr = self.repo.transaction(self._trname)
+                for key in sorted(remoteobs, reverse=True):
+                    if key.startswith('dump'):
+                        data = base85.b85decode(remoteobs[key])
+                        self.repo.obsstore.mergemarkers(self._tr, data)
+                self.repo.invalidatevolatilesets()