Patchwork [1,of,2] wireproto: add a ``boolean`` type for getbundle parameters

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 4, 2014, 6:41 p.m.
Message ID <d45398ff6b1cf799b0e7.1407177692@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5248/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 4, 2014, 6:41 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1400804452 25200
#      Thu May 22 17:20:52 2014 -0700
# Node ID d45398ff6b1cf799b0e76b0d1f8c3e30b0079ba9
# Parent  3467cf39aae688e844d5c1c22b7daa85c590bef9
wireproto: add a ``boolean`` type for getbundle parameters

This will be used to control inclusion of some part in a bundle2.

Patch

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -347,10 +347,12 @@  class wirepeer(peer.peerrepository):
                 assert False, 'unexpected'
             elif keytype == 'nodes':
                 value = encodelist(value)
             elif keytype == 'csv':
                 value = ','.join(value)
+            elif keytype == 'boolean':
+                value = bool(value)
             elif keytype != 'plain':
                 raise KeyError('unknown getbundle option type %s'
                                % keytype)
             opts[key] = value
         f = self._callcompressable("getbundle", **opts)
@@ -650,10 +652,12 @@  def getbundle(repo, proto, others):
         keytype = gboptsmap[k]
         if keytype == 'nodes':
             opts[k] = decodelist(v)
         elif keytype == 'csv':
             opts[k] = set(v.split(','))
+        elif keytype == 'boolean':
+            opts[k] = '%i' % bool(v)
         elif keytype != 'plain':
             raise KeyError('unknown getbundle option type %s'
                            % keytype)
     cg = exchange.getbundle(repo, 'serve', **opts)
     return streamres(proto.groupchunks(cg))