hgext/patchbomb.py
changeset 39035 cecb05c371f7
parent 39034 751caa6a2936
child 39038 2161faf0d24b
equal deleted inserted replaced
39034:751caa6a2936 39035:cecb05c371f7
   787             m['Reply-To'] = ', '.join(replyto)
   787             m['Reply-To'] = ', '.join(replyto)
   788         # Fix up all headers to be native strings.
   788         # Fix up all headers to be native strings.
   789         # TODO(durin42): this should probably be cleaned up above in the future.
   789         # TODO(durin42): this should probably be cleaned up above in the future.
   790         if pycompat.ispy3:
   790         if pycompat.ispy3:
   791             for hdr, val in list(m.items()):
   791             for hdr, val in list(m.items()):
       
   792                 change = False
   792                 if isinstance(hdr, bytes):
   793                 if isinstance(hdr, bytes):
   793                     del m[hdr]
   794                     del m[hdr]
   794                     hdr = pycompat.strurl(hdr)
   795                     hdr = pycompat.strurl(hdr)
       
   796                     change = True
   795                 if isinstance(val, bytes):
   797                 if isinstance(val, bytes):
   796                     val = pycompat.strurl(val)
   798                     val = pycompat.strurl(val)
   797                 m[hdr] = val
   799                     if not change:
       
   800                         # prevent duplicate headers
       
   801                         del m[hdr]
       
   802                     change = True
       
   803                 if change:
       
   804                     m[hdr] = val
   798         if opts.get('test'):
   805         if opts.get('test'):
   799             ui.status(_('displaying '), subj, ' ...\n')
   806             ui.status(_('displaying '), subj, ' ...\n')
   800             ui.pager('email')
   807             ui.pager('email')
   801             generator = emailgen.Generator(_bytesgenerator(ui),
   808             generator = emailgen.Generator(_bytesgenerator(ui),
   802                                            mangle_from_=False)
   809                                            mangle_from_=False)