Patchwork [09,of,15] pull: reorganize bundle2 argument bundling

login
register
mail settings
Submitter Boris Feld
Date Jan. 19, 2018, 8:08 p.m.
Message ID <0db72f8d443d7ca27d57.1516392533@FB>
Download mbox | patch
Permalink /patch/26964/
State Deferred, archived
Headers show

Comments

Boris Feld - Jan. 19, 2018, 8:08 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1516203125 -3600
#      Wed Jan 17 16:32:05 2018 +0100
# Node ID 0db72f8d443d7ca27d57e650aa44b5d74ef965c2
# Parent  77a0634011b5bc89472a134c5ea2b5623f6ca273
# EXP-Topic b2-stream
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0db72f8d443d
pull: reorganize bundle2 argument bundling

We are about to add the ability to use stream bundle with bundle2. Before doing
so, we need to gather some code that will not be used in the bundle2 case. There
is no behavior change within this changeset.

Patch

diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -1450,24 +1450,32 @@  def _pullbundle2(pullop):
     For now, the only supported data are changegroup."""
     kwargs = {'bundlecaps': caps20to10(pullop.repo)}
 
+    # make ui easier to access
+    ui = pullop.repo.ui
+
     # At the moment we don't do stream clones over bundle2. If that is
     # implemented then here's where the check for that will go.
     streaming = False
 
+    # declare pull perimeters
+    kwargs['common'] = pullop.common
+    kwargs['heads'] = pullop.heads or pullop.rheads
+
     # pulling changegroup
     pullop.stepsdone.add('changegroup')
 
-    kwargs['common'] = pullop.common
-    kwargs['heads'] = pullop.heads or pullop.rheads
     kwargs['cg'] = pullop.fetch
 
-    ui = pullop.repo.ui
     legacyphase = 'phases' in ui.configlist('devel', 'legacy.exchange')
     hasbinaryphase = 'heads' in pullop.remotebundle2caps.get('phases', ())
     if (not legacyphase and hasbinaryphase):
         kwargs['phases'] = True
         pullop.stepsdone.add('phases')
 
+    if 'listkeys' in pullop.remotebundle2caps:
+        if 'phases' not in pullop.stepsdone:
+            kwargs['listkeys'] = ['phases']
+
     bookmarksrequested = False
     legacybookmark = 'bookmarks' in ui.configlist('devel', 'legacy.exchange')
     hasbinarybook = 'bookmarks' in pullop.remotebundle2caps
@@ -1482,8 +1490,6 @@  def _pullbundle2(pullop):
         bookmarksrequested = True
 
     if 'listkeys' in pullop.remotebundle2caps:
-        if 'phases' not in pullop.stepsdone:
-            kwargs['listkeys'] = ['phases']
         if 'request-bookmarks' not in pullop.stepsdone:
             # make sure to always includes bookmark data when migrating
             # `hg incoming --bundle` to using this function.