[PATCH] pull: use `stepsdone` instead of `todosteps`

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Oct 13 14:58:36 CDT 2014

# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1413121236 25200
#      Sun Oct 12 06:40:36 2014 -0700
# Node ID d9093c94f3b96a22d026d0e376a85289e2f5ee47
# Parent  f70d2e37b0cc8e09fd5a50d0f38c68a4aaff2a5f
pull: use `stepsdone` instead of `todosteps`

The push process use a `stepsdone` attribute instead of a `todosteps` one (with
the logic swapped). We unify the two process by picking the `stepsdone` version.
I feel like `stepsdone` is fit more extension that would want to extend the push

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -800,13 +800,12 @@ class pulloperation(object):
         self.fetch = None
         # remote bookmarks data
         self.remotebookmarks = None
         # result of changegroup pulling (used as return code by pull)
         self.cgresult = None
-        # list of step remaining todo (related to future bundle2 usage)
-        self.todosteps = set(['changegroup', 'phases', 'obsmarkers',
-                              'bookmarks'])
+        # list of step already done
+        self.stepsdone = set()
     def pulledsubset(self):
         """heads of the set of changeset target by the pull"""
         # compute target subset
@@ -915,11 +914,11 @@ def _pullbundle2(pullop):
     For now, the only supported data are changegroup."""
     remotecaps = bundle2.bundle2caps(pullop.remote)
     kwargs = {'bundlecaps': caps20to10(pullop.repo)}
     # pulling changegroup
-    pullop.todosteps.remove('changegroup')
+    pullop.stepsdone.add('changegroup')
     kwargs['common'] = pullop.common
     kwargs['heads'] = pullop.heads or pullop.rheads
     kwargs['cg'] = pullop.fetch
     if 'b2x:listkeys' in remotecaps:
@@ -932,11 +931,11 @@ def _pullbundle2(pullop):
             pullop.repo.ui.status(_("requesting all changes\n"))
     if obsolete._enabled:
         remoteversions = bundle2.obsmarkersversion(remotecaps)
         if obsolete.commonversion(remoteversions) is not None:
             kwargs['obsmarkers'] = True
-            pullop.todosteps.remove('obsmarkers')
+            pullop.stepsdone.add('obsmarkers')
     _pullbundle2extraprepare(pullop, kwargs)
     if kwargs.keys() == ['format']:
         return # nothing to pull
     bundle = pullop.remote.getbundle('pull', **kwargs)
@@ -966,13 +965,13 @@ def _pullbundle2extraprepare(pullop, kwa
 def _pullchangeset(pullop):
     """pull changeset from unbundle into the local repo"""
     # We delay the open of the transaction as late as possible so we
     # don't open transaction for nothing or you break future useful
     # rollback call
-    if 'changegroup' not in pullop.todosteps:
+    if 'changegroup' in pullop.stepsdone:
-    pullop.todosteps.remove('changegroup')
+    pullop.stepsdone.add('changegroup')
     if not pullop.fetch:
             pullop.repo.ui.status(_("no changes found\n"))
             pullop.cgresult = 0
@@ -997,18 +996,20 @@ def _pullchangeset(pullop):
     pullop.cgresult = changegroup.addchangegroup(pullop.repo, cg, 'pull',
 def _pullphase(pullop):
     # Get remote phases data from remote
-    if 'phases' not in pullop.todosteps:
+    if 'phases' in pullop.stepsdone:
     remotephases = pullop.remote.listkeys('phases')
     _pullapplyphases(pullop, remotephases)
 def _pullapplyphases(pullop, remotephases):
     """apply phase movement from observed remote state"""
-    pullop.todosteps.remove('phases')
+    if 'phases' in pullop.stepsdone:
+        return
+    pullop.stepsdone.add('phases')
     publishing = bool(remotephases.get('publishing', False))
     if remotephases and not publishing:
         # remote is new and unpublishing
         pheads, _dr = phases.analyzeremotephases(pullop.repo,
@@ -1037,13 +1038,13 @@ def _pullapplyphases(pullop, remotephase
         tr = pullop.gettransaction()
         phases.advanceboundary(pullop.repo, tr, draft, dheads)
 def _pullbookmarks(pullop):
     """process the remote bookmark information to update the local one"""
-    if 'bookmarks' not in pullop.todosteps:
+    if 'bookmarks' in pullop.stepsdone:
-    pullop.todosteps.remove('bookmarks')
+    pullop.stepsdone.add('bookmarks')
     repo = pullop.repo
     remotebookmarks = pullop.remotebookmarks
     bookmod.updatefromremote(repo.ui, repo, remotebookmarks,
@@ -1055,13 +1056,13 @@ def _pullobsolete(pullop):
     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"""
-    if 'obsmarkers' not in pullop.todosteps:
+    if 'obsmarkers' in pullop.stepsdone:
-    pullop.todosteps.remove('obsmarkers')
+    pullop.stepsdone.add('obsmarkers')
     tr = None
     if obsolete._enabled:
         pullop.repo.ui.debug('fetching remote obsolete markers\n')
         remoteobs = pullop.remote.listkeys('obsolete')
         if 'dump0' in remoteobs:

More information about the Mercurial-devel mailing list