bundle2: use ProgrammingError to report bad use of addparam()
authorYuya Nishihara <yuya@tcha.org>
Sun, 08 Jul 2018 19:24:18 +0900
changeset 38609 d474b3b44d4f
parent 38608 980aee54fd70
child 38610 3d8ef60569d8
bundle2: use ProgrammingError to report bad use of addparam() This allows us to embed error message in bytes.
contrib/python3-whitelist
mercurial/bundle2.py
tests/test-bundle2-format.t
--- a/contrib/python3-whitelist	Sun Jul 08 19:34:11 2018 +0900
+++ b/contrib/python3-whitelist	Sun Jul 08 19:24:18 2018 +0900
@@ -38,6 +38,7 @@
 test-bundle-vs-outgoing.t
 test-bundle.t
 test-bundle2-exchange.t
+test-bundle2-format.t
 test-bundle2-multiple-changegroups.t
 test-bundle2-pushback.t
 test-cappedreader.py
--- a/mercurial/bundle2.py	Sun Jul 08 19:34:11 2018 +0900
+++ b/mercurial/bundle2.py	Sun Jul 08 19:24:18 2018 +0900
@@ -628,9 +628,10 @@
     def addparam(self, name, value=None):
         """add a stream level parameter"""
         if not name:
-            raise ValueError(r'empty parameter name')
+            raise error.ProgrammingError(b'empty parameter name')
         if name[0:1] not in pycompat.bytestr(string.ascii_letters):
-            raise ValueError(r'non letter first character: %s' % name)
+            raise error.ProgrammingError(b'non letter first character: %s'
+                                         % name)
         self._params.append((name, value))
 
     def addpart(self, part):
--- a/tests/test-bundle2-format.t	Sun Jul 08 19:34:11 2018 +0900
+++ b/tests/test-bundle2-format.t	Sun Jul 08 19:24:18 2018 +0900
@@ -91,8 +91,8 @@
   >         p = p.split(b'=', 1)
   >         try:
   >             bundler.addparam(*p)
-  >         except ValueError as exc:
-  >             raise error.Abort('%s' % exc)
+  >         except error.ProgrammingError as exc:
+  >             raise error.Abort(b'%s' % exc)
   > 
   >     if opts['compress']:
   >         bundler.setcompression(opts['compress'])