Show More
@@ -321,10 +321,10 b' def makepatch(' | |||||
321 | subj = b' '.join([prefix, opts.get(b'subject') or subj]) |
|
321 | subj = b' '.join([prefix, opts.get(b'subject') or subj]) | |
322 | else: |
|
322 | else: | |
323 | subj = b' '.join([prefix, subj]) |
|
323 | subj = b' '.join([prefix, subj]) | |
324 |
msg[ |
|
324 | msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get(b'test')) | |
325 |
msg[ |
|
325 | msg['X-Mercurial-Node'] = pycompat.sysstr(node) | |
326 |
msg[ |
|
326 | msg['X-Mercurial-Series-Index'] = '%i' % idx | |
327 |
msg[ |
|
327 | msg['X-Mercurial-Series-Total'] = '%i' % total | |
328 | return msg, subj, ds |
|
328 | return msg, subj, ds | |
329 |
|
329 | |||
330 |
|
330 | |||
@@ -421,7 +421,7 b' def _getbundlemsgs(repo, sender, bundle,' | |||||
421 | ) |
|
421 | ) | |
422 | emailencoders.encode_base64(datapart) |
|
422 | emailencoders.encode_base64(datapart) | |
423 | msg.attach(datapart) |
|
423 | msg.attach(datapart) | |
424 |
msg[ |
|
424 | msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test')) | |
425 | return [(msg, subj, None)] |
|
425 | return [(msg, subj, None)] | |
426 |
|
426 | |||
427 |
|
427 | |||
@@ -454,7 +454,7 b' def _makeintro(repo, sender, revs, patch' | |||||
454 |
|
454 | |||
455 | body = _getdescription(repo, body, sender, **opts) |
|
455 | body = _getdescription(repo, body, sender, **opts) | |
456 | msg = mail.mimeencode(ui, body, _charsets, opts.get('test')) |
|
456 | msg = mail.mimeencode(ui, body, _charsets, opts.get('test')) | |
457 |
msg[ |
|
457 | msg['Subject'] = mail.headencode(ui, subj, _charsets, opts.get('test')) | |
458 | return (msg, subj, diffstat) |
|
458 | return (msg, subj, diffstat) | |
459 |
|
459 | |||
460 |
|
460 | |||
@@ -522,9 +522,11 b' def _getoutgoing(repo, dest, revs):' | |||||
522 |
|
522 | |||
523 |
|
523 | |||
524 | def _msgid(node, timestamp): |
|
524 | def _msgid(node, timestamp): | |
525 | hostname = encoding.strtolocal(socket.getfqdn()) |
|
525 | try: | |
526 |
hostname = encoding.environ |
|
526 | hostname = encoding.strfromlocal(encoding.environ[b'HGHOSTNAME']) | |
527 | return b'<%s.%d@%s>' % (node, timestamp, hostname) |
|
527 | except KeyError: | |
|
528 | hostname = socket.getfqdn() | |||
|
529 | return '<%s.%d@%s>' % (node, timestamp, hostname) | |||
528 |
|
530 | |||
529 |
|
531 | |||
530 | emailopts = [ |
|
532 | emailopts = [ | |
@@ -912,10 +914,11 b' def email(ui, repo, *revs, **opts):' | |||||
912 | parent = opts.get(b'in_reply_to') or None |
|
914 | parent = opts.get(b'in_reply_to') or None | |
913 | # angle brackets may be omitted, they're not semantically part of the msg-id |
|
915 | # angle brackets may be omitted, they're not semantically part of the msg-id | |
914 | if parent is not None: |
|
916 | if parent is not None: | |
915 | if not parent.startswith(b'<'): |
|
917 | parent = encoding.strfromlocal(parent) | |
916 | parent = b'<' + parent |
|
918 | if not parent.startswith('<'): | |
917 | if not parent.endswith(b'>'): |
|
919 | parent = '<' + parent | |
918 |
|
|
920 | if not parent.endswith('>'): | |
|
921 | parent += '>' | |||
919 |
|
922 | |||
920 | sender_addr = eutil.parseaddr(encoding.strfromlocal(sender))[1] |
|
923 | sender_addr = eutil.parseaddr(encoding.strfromlocal(sender))[1] | |
921 | sender = mail.addressencode(ui, sender, _charsets, opts.get(b'test')) |
|
924 | sender = mail.addressencode(ui, sender, _charsets, opts.get(b'test')) | |
@@ -926,50 +929,30 b' def email(ui, repo, *revs, **opts):' | |||||
926 | ) |
|
929 | ) | |
927 | for i, (m, subj, ds) in enumerate(msgs): |
|
930 | for i, (m, subj, ds) in enumerate(msgs): | |
928 | try: |
|
931 | try: | |
929 |
m[ |
|
932 | m['Message-Id'] = genmsgid(m['X-Mercurial-Node']) | |
930 | if not firstpatch: |
|
933 | if not firstpatch: | |
931 |
firstpatch = m[ |
|
934 | firstpatch = m['Message-Id'] | |
932 |
m[ |
|
935 | m['X-Mercurial-Series-Id'] = firstpatch | |
933 | except TypeError: |
|
936 | except TypeError: | |
934 |
m[ |
|
937 | m['Message-Id'] = genmsgid('patchbomb') | |
935 | if parent: |
|
938 | if parent: | |
936 |
m[ |
|
939 | m['In-Reply-To'] = parent | |
937 |
m[ |
|
940 | m['References'] = parent | |
938 |
if not parent or |
|
941 | if not parent or 'X-Mercurial-Node' not in m: | |
939 |
parent = m[ |
|
942 | parent = m['Message-Id'] | |
940 |
|
943 | |||
941 |
m[ |
|
944 | m['User-Agent'] = 'Mercurial-patchbomb/%s' % util.version().decode() | |
942 |
m[ |
|
945 | m['Date'] = eutil.formatdate(start_time[0], localtime=True) | |
943 |
|
946 | |||
944 | start_time = (start_time[0] + 1, start_time[1]) |
|
947 | start_time = (start_time[0] + 1, start_time[1]) | |
945 |
m[ |
|
948 | m['From'] = sender | |
946 |
m[ |
|
949 | m['To'] = ', '.join(to) | |
947 | if cc: |
|
950 | if cc: | |
948 |
m[ |
|
951 | m['Cc'] = ', '.join(cc) | |
949 | if bcc: |
|
952 | if bcc: | |
950 |
m[ |
|
953 | m['Bcc'] = ', '.join(bcc) | |
951 | if replyto: |
|
954 | if replyto: | |
952 |
m[ |
|
955 | m['Reply-To'] = ', '.join(replyto) | |
953 | # Fix up all headers to be native strings. |
|
|||
954 | # TODO(durin42): this should probably be cleaned up above in the future. |
|
|||
955 | if pycompat.ispy3: |
|
|||
956 | for hdr, val in list(m.items()): |
|
|||
957 | change = False |
|
|||
958 | if isinstance(hdr, bytes): |
|
|||
959 | del m[hdr] |
|
|||
960 | hdr = pycompat.strurl(hdr) |
|
|||
961 | change = True |
|
|||
962 | if isinstance(val, bytes): |
|
|||
963 | # header value should be ASCII since it's encoded by |
|
|||
964 | # mail.headencode(), but -n/--test disables it and raw |
|
|||
965 | # value of platform encoding is stored. |
|
|||
966 | val = encoding.strfromlocal(val) |
|
|||
967 | if not change: |
|
|||
968 | # prevent duplicate headers |
|
|||
969 | del m[hdr] |
|
|||
970 | change = True |
|
|||
971 | if change: |
|
|||
972 | m[hdr] = val |
|
|||
973 | if opts.get(b'test'): |
|
956 | if opts.get(b'test'): | |
974 | ui.status(_(b'displaying '), subj, b' ...\n') |
|
957 | ui.status(_(b'displaying '), subj, b' ...\n') | |
975 | ui.pager(b'email') |
|
958 | ui.pager(b'email') | |
@@ -987,7 +970,7 b' def email(ui, repo, *revs, **opts):' | |||||
987 | progress.update(i, item=subj) |
|
970 | progress.update(i, item=subj) | |
988 | if not mbox: |
|
971 | if not mbox: | |
989 | # Exim does not remove the Bcc field |
|
972 | # Exim does not remove the Bcc field | |
990 |
del m[ |
|
973 | del m['Bcc'] | |
991 | fp = stringio() |
|
974 | fp = stringio() | |
992 | generator = mail.Generator(fp, mangle_from_=False) |
|
975 | generator = mail.Generator(fp, mangle_from_=False) | |
993 | generator.flatten(m, 0) |
|
976 | generator.flatten(m, 0) |
General Comments 0
You need to be logged in to leave comments.
Login now