[PATCH 1 of 6 clone bundles] wireproto: properly parse false boolean args (BC)

Gregory Szorc gregory.szorc at gmail.com
Wed Oct 14 18:07:53 UTC 2015


# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1444845515 25200
#      Wed Oct 14 10:58:35 2015 -0700
# Node ID 2a84ef46763f9e6d1fcc71348ea179fef144f869
# Parent  3449926bb969e485e5dff5eb6bfaf6f4be5523f0
wireproto: properly parse false boolean args (BC)

The client represents boolean arguments as '0' and '1'.
bool('0') == bool('1') == True, so a simple bool(val) isn't sufficient
for converting the argument back to a bool type.

Currently, "obsmarkers" is the only boolean argument to getbundle.

I /think/ the only place where we currently set the "obsmarkers"
argument is during bundle2 pulls. As a result of this bug, the server
/might/ be sending obsolete markers bundle2 part(s) to clients that
don't request them. That is why I marked this BC.

Surprisingly there was no test fall out from this change. I suspect a
lapse in test coverage.

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -624,9 +624,14 @@ def getbundle(repo, proto, others):
             opts[k] = list(v.split(','))
         elif keytype == 'scsv':
             opts[k] = set(v.split(','))
         elif keytype == 'boolean':
-            opts[k] = bool(v)
+            # Client should serialize False as '0', which is a non-empty string
+            # so it evaluates as a True bool.
+            if v == '0':
+                opts[k] = False
+            else:
+                opts[k] = bool(v)
         elif keytype != 'plain':
             raise KeyError('unknown getbundle option type %s'
                            % keytype)
     cg = exchange.getbundle(repo, 'serve', **opts)


More information about the Mercurial-devel mailing list