Patchwork [10,of,13] pull: move phases synchronisation in its own function

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 12, 2014, 1:34 a.m.
Message ID <93c4f719c762381d8b5a.1392168864@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3609/
State Accepted
Commit 0c469df6e9149b8231b827f9ee3944e9cd52da22
Headers show

Comments

Pierre-Yves David - Feb. 12, 2014, 1:34 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1391160356 28800
#      Fri Jan 31 01:25:56 2014 -0800
# Node ID 93c4f719c762381d8b5a820b5896a4851de55653
# Parent  7935b9c338c49f4a53fd1ab15948708573248e4f
pull: move phases synchronisation in its own function

Now that every necessary information is held in the `pulloperation` object, we
can finally extract the phase synchronisation phase to it's own function.

This changeset is pure code movement only.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -412,35 +412,37 @@  def pull(repo, remote, heads=None, force
             # We pulled a specific subset
             # sync on this subset
             subset = pullop.heads
         pullop.pulledsubset = subset
 
-        # Get remote phases data from remote
-        remotephases = pullop.remote.listkeys('phases')
-        publishing = bool(remotephases.get('publishing', False))
-        if remotephases and not publishing:
-            # remote is new and unpublishing
-            pheads, _dr = phases.analyzeremotephases(pullop.repo,
-                                                     pullop.pulledsubset,
-                                                     remotephases)
-            phases.advanceboundary(pullop.repo, phases.public, pheads)
-            phases.advanceboundary(pullop.repo, phases.draft,
-                                   pullop.pulledsubset)
-        else:
-            # Remote is old or publishing all common changesets
-            # should be seen as public
-            phases.advanceboundary(pullop.repo, phases.public,
-                                   pullop.pulledsubset)
-
+        _pullphase(pullop)
         _pullobsolete(pullop)
         pullop.closetransaction()
     finally:
         pullop.releasetransaction()
         lock.release()
 
     return result
 
+def _pullphase(pullop):
+    # Get remote phases data from remote
+    remotephases = pullop.remote.listkeys('phases')
+    publishing = bool(remotephases.get('publishing', False))
+    if remotephases and not publishing:
+        # remote is new and unpublishing
+        pheads, _dr = phases.analyzeremotephases(pullop.repo,
+                                                 pullop.pulledsubset,
+                                                 remotephases)
+        phases.advanceboundary(pullop.repo, phases.public, pheads)
+        phases.advanceboundary(pullop.repo, phases.draft,
+                               pullop.pulledsubset)
+    else:
+        # Remote is old or publishing all common changesets
+        # should be seen as public
+        phases.advanceboundary(pullop.repo, phases.public,
+                               pullop.pulledsubset)
+
 def _pullobsolete(pullop):
     """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