Patchwork [4,of,4,main-line-of-work] getbundle: sort bundlecaps before exchanging then over the wire

login
register
mail settings
Submitter Pierre-Yves David
Date May 16, 2015, 1:45 a.m.
Message ID <dfe2bac65fb1d4b6cdd3.1431740737@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/9114/
State Accepted
Headers show

Comments

Pierre-Yves David - May 16, 2015, 1:45 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1431259873 25200
#      Sun May 10 05:11:13 2015 -0700
# Node ID dfe2bac65fb1d4b6cdd3a95f116ce7822614912d
# Parent  c66322e088ae697101200a961480c5f8ff171997
getbundle: sort bundlecaps before exchanging then over the wire

The 'bundlecaps' argument is built as a set, we need to stabilise the order
before exchanging them. Otherwise, in the test, http logs are unstable when the
'bundlecaps' contains something (eg: using bundle2).
Matt Mackall - May 18, 2015, 2:17 a.m.
On Fri, 2015-05-15 at 18:45 -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1431259873 25200
> #      Sun May 10 05:11:13 2015 -0700
> # Node ID dfe2bac65fb1d4b6cdd3a95f116ce7822614912d
> # Parent  c66322e088ae697101200a961480c5f8ff171997
> getbundle: sort bundlecaps before exchanging then over the wire

These are queued for default, thanks.

Patch

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -343,10 +343,15 @@  class wirepeer(peer.peerrepository):
         return changegroupmod.cg1unpacker(f, 'UN')
 
     def getbundle(self, source, **kwargs):
         self.requirecap('getbundle', _('look up remote changes'))
         opts = {}
+        bundlecaps = kwargs.get('bundlecaps')
+        if bundlecaps is not None:
+            kwargs['bundlecaps'] = sorted(bundlecaps)
+        else:
+            bundlecaps = () # kwargs could have it to None
         for key, value in kwargs.iteritems():
             if value is None:
                 continue
             keytype = gboptsmap.get(key)
             if keytype is None:
@@ -360,13 +365,10 @@  class wirepeer(peer.peerrepository):
             elif keytype != 'plain':
                 raise KeyError('unknown getbundle option type %s'
                                % keytype)
             opts[key] = value
         f = self._callcompressable("getbundle", **opts)
-        bundlecaps = kwargs.get('bundlecaps')
-        if bundlecaps is None:
-            bundlecaps = () # kwargs could have it to None
         if util.any((cap.startswith('HG2') for cap in bundlecaps)):
             return bundle2.getunbundler(self.ui, f)
         else:
             return changegroupmod.cg1unpacker(f, 'UN')