bundle2: support transmission of params error over the wire
authorPierre-Yves David <pierre-yves.david@fb.com>
Wed, 28 May 2014 15:57:23 -0700
changeset 21622 457492741007
parent 21621 b6eb56a9335d
child 21623 5b26d82e4e2a
bundle2: support transmission of params error over the wire We picked a null character to split each parameter during the transfer. This is fragile if the same character is used in parameter name. However other codes will already behave in a strange way in that case, so we are not introducing any regression. A better format may be picked for the final version of the protocol.
mercurial/bundle2.py
mercurial/wireproto.py
--- a/mercurial/bundle2.py	Wed May 28 15:53:34 2014 -0700
+++ b/mercurial/bundle2.py	Wed May 28 15:57:23 2014 -0700
@@ -831,8 +831,13 @@
 @parthandler('b2x:error:unsupportedcontent')
 def handlereplycaps(op, inpart):
     """Used to transmit unknown content error over the wire"""
-    parttype = inpart.params['parttype']
-    raise error.BundleValueError(parttype=parttype)
+    kwargs = {}
+    kwargs['parttype'] = inpart.params['parttype']
+    params = inpart.params.get('params')
+    if params is not None:
+        kwargs['params'] = params.split('\0')
+
+    raise error.BundleValueError(**kwargs)
 
 @parthandler('b2x:error:pushraced')
 def handlereplycaps(op, inpart):
--- a/mercurial/wireproto.py	Wed May 28 15:53:34 2014 -0700
+++ b/mercurial/wireproto.py	Wed May 28 15:57:23 2014 -0700
@@ -807,6 +807,8 @@
             bundler = bundle2.bundle20(repo.ui)
             errpart = bundler.newpart('B2X:ERROR:UNSUPPORTEDCONTENT')
             errpart.addparam('parttype', exc.parttype)
+            if exc.params:
+                errpart.addparam('params', '\0'.join(exc.params))
             return streamres(bundler.getchunks())
     except util.Abort, inst:
         # The old code we moved used sys.stderr directly.