changeset 34256:ab379eed2e31

bundle2: raise a more helpful error if building a bundle part header fails I've tripped on this several times now, and am tired of debugging. Now the header parts are part of the error message when the ''.join() fails, which makes debugging obvious.
author Augie Fackler <raf@durin42.com>
date Fri, 15 Sep 2017 18:37:29 -0400
parents b59620c52eec
children 448725a2ef73
files mercurial/bundle2.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/bundle2.py	Fri Sep 15 18:57:50 2017 +0200
+++ b/mercurial/bundle2.py	Fri Sep 15 18:37:29 2017 -0400
@@ -1050,7 +1050,11 @@
             header.append(key)
             header.append(value)
         ## finalize header
-        headerchunk = ''.join(header)
+        try:
+            headerchunk = ''.join(header)
+        except TypeError:
+            raise TypeError(r'Found a non-bytes trying to '
+                            r'build bundle part header: %r' % header)
         outdebug(ui, 'header chunk size: %i' % len(headerchunk))
         yield _pack(_fpartheadersize, len(headerchunk))
         yield headerchunk