Mercurial > hg-stable
changeset 34284:a48b3db0baba
bundle2: stop using %r to quote part names
Valid part names are restricted to [a-zA-Z0-9_:-]+, so I'm not worried
about having quoting present in places where we should have
predominantly valid part names. This will significantly ease the
Python 3 transition, and simultaneously isn't a BC because this is
only in error messages that should never be shown.
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 18 Sep 2017 13:35:43 -0400 |
parents | b90bd9a98c8b |
children | ea7588c11c36 |
files | mercurial/bundle2.py tests/test-bundle2-format.t |
diffstat | 2 files changed, 16 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Mon Sep 18 16:01:03 2017 -0700 +++ b/mercurial/bundle2.py Mon Sep 18 13:35:43 2017 -0400 @@ -470,12 +470,12 @@ if handler is None: status = 'unsupported-type' raise error.BundleUnknownFeatureError(parttype=part.type) - indebug(op.ui, 'found a handler for part %r' % part.type) + indebug(op.ui, 'found a handler for part %s' % part.type) unknownparams = part.mandatorykeys - handler.params if unknownparams: unknownparams = list(unknownparams) unknownparams.sort() - status = 'unsupported-params (%s)' % unknownparams + status = 'unsupported-params (%s)' % ', '.join(unknownparams) raise error.BundleUnknownFeatureError(parttype=part.type, params=unknownparams) status = 'supported' @@ -616,7 +616,7 @@ if not name: raise ValueError('empty parameter name') if name[0] not in pycompat.bytestr(string.ascii_letters): - raise ValueError('non letter first character: %r' % name) + raise ValueError('non letter first character: %s' % name) self._params.append((name, value)) def addpart(self, part): @@ -792,14 +792,14 @@ ignored or failing. """ if not name: - raise ValueError('empty parameter name') - if name[0] not in pycompat.bytestr(string.ascii_letters): - raise ValueError('non letter first character: %r' % name) + raise ValueError(r'empty parameter name') + if name[0:1] not in pycompat.bytestr(string.ascii_letters): + raise ValueError(r'non letter first character: %s' % name) try: handler = b2streamparamsmap[name.lower()] except KeyError: - if name[0].islower(): - indebug(self.ui, "ignoring unknown parameter %r" % name) + if name[0:1].islower(): + indebug(self.ui, "ignoring unknown parameter %s" % name) else: raise error.BundleUnknownFeatureError(params=(name,)) else:
--- a/tests/test-bundle2-format.t Mon Sep 18 16:01:03 2017 -0700 +++ b/tests/test-bundle2-format.t Mon Sep 18 13:35:43 2017 -0400 @@ -410,8 +410,8 @@ $ hg statbundle2 --debug --config progress.debug=true --config devel.bundle2.debug=true < ../out.hg2 bundle2-input: start processing of HG20 stream bundle2-input: reading bundle2 stream parameters - bundle2-input: ignoring unknown parameter 'e|! 7/' - bundle2-input: ignoring unknown parameter 'simple' + bundle2-input: ignoring unknown parameter e|! 7/ + bundle2-input: ignoring unknown parameter simple options count: 2 - e|! 7/ babar%#==tutu @@ -434,7 +434,7 @@ bad parameter name $ hg bundle2 --param 42babar - abort: non letter first character: '42babar' + abort: non letter first character: 42babar [255] @@ -651,7 +651,7 @@ bundle2-input: part type: "test:song" bundle2-input: part id: "2" bundle2-input: part parameters: 0 - bundle2-input: found a handler for part 'test:song' + bundle2-input: found a handler for part test:song bundle2-input-part: "test:song" (advisory) supported The choir starts singing: bundle2-input: payload chunk size: 178 @@ -664,7 +664,7 @@ bundle2-input: part type: "test:debugreply" bundle2-input: part id: "3" bundle2-input: part parameters: 0 - bundle2-input: found a handler for part 'test:debugreply' + bundle2-input: found a handler for part test:debugreply bundle2-input-part: "test:debugreply" (advisory) supported debugreply: no reply bundle2-input: payload chunk size: 0 @@ -681,15 +681,15 @@ bundle2-input: part type: "test:song" bundle2-input: part id: "5" bundle2-input: part parameters: 1 - bundle2-input: found a handler for part 'test:song' + bundle2-input: found a handler for part test:song bundle2-input: ignoring unsupported advisory part test:song - randomparam - bundle2-input-part: "test:song" (advisory) (params: 1 mandatory) unsupported-params (['randomparam']) + bundle2-input-part: "test:song" (advisory) (params: 1 mandatory) unsupported-params (randomparam) bundle2-input: payload chunk size: 0 bundle2-input: part header size: 16 bundle2-input: part type: "test:ping" bundle2-input: part id: "6" bundle2-input: part parameters: 0 - bundle2-input: found a handler for part 'test:ping' + bundle2-input: found a handler for part test:ping bundle2-input-part: "test:ping" (advisory) supported received ping request (id 6) bundle2-input: payload chunk size: 0