diff --git a/mercurial/exchange.py b/mercurial/exchange.py
index de2544933139de731f097ee98b7604e01d135bf6_bWVyY3VyaWFsL2V4Y2hhbmdlLnB5..0c469df6e9149b8231b827f9ee3944e9cd52da22_bWVyY3VyaWFsL2V4Y2hhbmdlLnB5 100644
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -473,23 +473,7 @@
             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:
@@ -498,6 +482,24 @@
 
     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