mercurial/commands.py
changeset 2513 f22e3e8fd457
parent 2510 cbff06469488
child 2515 a6700c222314
equal deleted inserted replaced
2512:e4deeaac5e74 2513:f22e3e8fd457
  1785                 if m:
  1785                 if m:
  1786                     ui.debug(_('found patch at byte %d\n') % m.start(0))
  1786                     ui.debug(_('found patch at byte %d\n') % m.start(0))
  1787                     diffs_seen += 1
  1787                     diffs_seen += 1
  1788                     hgpatch = False
  1788                     hgpatch = False
  1789                     fp = cStringIO.StringIO()
  1789                     fp = cStringIO.StringIO()
       
  1790                     if message:
       
  1791                         fp.write(message)
       
  1792                         fp.write('\n')
  1790                     for line in payload[:m.start(0)].splitlines():
  1793                     for line in payload[:m.start(0)].splitlines():
  1791                         if line.startswith('# HG changeset patch'):
  1794                         if line.startswith('# HG changeset patch'):
  1792                             ui.debug(_('patch generated by hg export\n'))
  1795                             ui.debug(_('patch generated by hg export\n'))
  1793                             hgpatch = True
  1796                             hgpatch = True
       
  1797                             # drop earlier commit message content
       
  1798                             fp.seek(0)
       
  1799                             fp.truncate()
  1794                         elif hgpatch:
  1800                         elif hgpatch:
  1795                             if line.startswith('# User '):
  1801                             if line.startswith('# User '):
  1796                                 user = line[7:]
  1802                                 user = line[7:]
  1797                                 ui.debug('From: %s\n' % user)
  1803                                 ui.debug('From: %s\n' % user)
  1798                             elif line.startswith("# Date "):
  1804                             elif line.startswith("# Date "):
  1799                                 date = line[7:]
  1805                                 date = line[7:]
  1800                         if not line.startswith('# '):
  1806                         if not line.startswith('# '):
  1801                             fp.write(line)
  1807                             fp.write(line)
  1802                             fp.write('\n')
  1808                             fp.write('\n')
  1803                             hgpatch = False
  1809                     message = fp.getvalue()
  1804                     message = fp.getvalue() or message
       
  1805                     if tmpfp:
  1810                     if tmpfp:
  1806                         tmpfp.write(payload)
  1811                         tmpfp.write(payload)
  1807                         if not payload.endswith('\n'):
  1812                         if not payload.endswith('\n'):
  1808                             tmpfp.write('\n')
  1813                             tmpfp.write('\n')
  1809                 elif not diffs_seen and message and content_type == 'text/plain':
  1814                 elif not diffs_seen and message and content_type == 'text/plain':