# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 2017-09-20 17:17:37
# Node ID c1e7ce11db9bec57cb255dd2872c9f4f6097041c
# Parent  aa5e7b4a3a01e562b2d923eb460dcdecef8220f4

phase: isolate logic to update remote phrase through bundle2 pushkey

Move the logic to build bundle2 pushkey part into its dedicated function. It
will help to keep the logic clear when adding support for sending phases change
using 'phase-heads' part.

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -806,8 +806,11 @@ def _pushb2phases(pushop, bundler):
     if 'phases' in pushop.stepsdone:
         return
     b2caps = bundle2.bundle2caps(pushop.remote)
-    if not 'pushkey' in b2caps:
-        return
+    if 'pushkey' in b2caps:
+        _pushb2phasespushkey(pushop, bundler)
+
+def _pushb2phasespushkey(pushop, bundler):
+    """push phase information through a bundle2 - pushkey part"""
     pushop.stepsdone.add('phases')
     part2node = []