mercurial/patch.py
changeset 36835 5bc7ff103081
parent 36676 c6a61298ac32
child 36837 472c68cda3f8
equal deleted inserted replaced
36834:1527f40de3b3 36835:5bc7ff103081
   214                         br'\*\*\*[ \t].*?^---[ \t])',
   214                         br'\*\*\*[ \t].*?^---[ \t])',
   215                         re.MULTILINE | re.DOTALL)
   215                         re.MULTILINE | re.DOTALL)
   216 
   216 
   217     data = {}
   217     data = {}
   218     fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
   218     fd, tmpname = tempfile.mkstemp(prefix='hg-patch-')
   219     tmpfp = os.fdopen(fd, pycompat.sysstr('wb'))
   219     tmpfp = os.fdopen(fd, r'wb')
   220     try:
   220     try:
   221         msg = pycompat.emailparser().parse(fileobj)
   221         msg = pycompat.emailparser().parse(fileobj)
   222 
   222 
   223         subject = msg['Subject'] and mail.headdecode(msg['Subject'])
   223         subject = msg['Subject'] and mail.headdecode(msg['Subject'])
   224         data['user'] = msg['From'] and mail.headdecode(msg['From'])
   224         data['user'] = msg['From'] and mail.headdecode(msg['From'])
  1104                 (patchfd, patchfn) = tempfile.mkstemp(prefix="hg-editor-",
  1104                 (patchfd, patchfn) = tempfile.mkstemp(prefix="hg-editor-",
  1105                         suffix=".diff", text=True)
  1105                         suffix=".diff", text=True)
  1106                 ncpatchfp = None
  1106                 ncpatchfp = None
  1107                 try:
  1107                 try:
  1108                     # Write the initial patch
  1108                     # Write the initial patch
  1109                     f = os.fdopen(patchfd, pycompat.sysstr("w"))
  1109                     f = os.fdopen(patchfd, r"w")
  1110                     chunk.header.write(f)
  1110                     chunk.header.write(f)
  1111                     chunk.write(f)
  1111                     chunk.write(f)
  1112                     f.write('\n'.join(['# ' + i for i in phelp.splitlines()]))
  1112                     f.write('\n'.join(['# ' + i for i in phelp.splitlines()]))
  1113                     f.close()
  1113                     f.close()
  1114                     # Start the editor and wait for it to complete
  1114                     # Start the editor and wait for it to complete