changeset 39072:cecb05c371f7

patchbomb: don't unintentionally duplicate headers This dict-like of headers is only mostly dict-like: if you set a key that already exists, you it appends another value, rather than replacing the one that was already present. This fixes test-patchbomb-bookmark.t on Python 3. Differential Revision: https://phab.mercurial-scm.org/D4229
author Augie Fackler <augie@google.com>
date Thu, 09 Aug 2018 19:39:33 -0400
parents 751caa6a2936
children 598467614c15
files contrib/python3-whitelist hgext/patchbomb.py
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/python3-whitelist	Thu Aug 09 19:37:57 2018 -0400
+++ b/contrib/python3-whitelist	Thu Aug 09 19:39:33 2018 -0400
@@ -363,6 +363,7 @@
 test-parseindex2.py
 test-patch-offset.t
 test-patch.t
+test-patchbomb-bookmark.t
 test-patchbomb-tls.t
 test-pathconflicts-merge.t
 test-pathconflicts-update.t
--- a/hgext/patchbomb.py	Thu Aug 09 19:37:57 2018 -0400
+++ b/hgext/patchbomb.py	Thu Aug 09 19:39:33 2018 -0400
@@ -789,12 +789,19 @@
         # TODO(durin42): this should probably be cleaned up above in the future.
         if pycompat.ispy3:
             for hdr, val in list(m.items()):
+                change = False
                 if isinstance(hdr, bytes):
                     del m[hdr]
                     hdr = pycompat.strurl(hdr)
+                    change = True
                 if isinstance(val, bytes):
                     val = pycompat.strurl(val)
-                m[hdr] = val
+                    if not change:
+                        # prevent duplicate headers
+                        del m[hdr]
+                    change = True
+                if change:
+                    m[hdr] = val
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.pager('email')