Mercurial > hg-stable
changeset 4777:5ee5cbfceff3
patch.extract: do not prepend subject if the description already starts with it
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Mon, 02 Jul 2007 10:59:16 -0700 |
parents | 03844af5ebcd |
children | e321f16f4eac |
files | mercurial/patch.py |
diffstat | 1 files changed, 9 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/patch.py Mon Jul 02 08:31:02 2007 -0700 +++ b/mercurial/patch.py Mon Jul 02 10:59:16 2007 -0700 @@ -50,7 +50,7 @@ try: msg = email.Parser.Parser().parse(fileobj) - message = msg['Subject'] + subject = msg['Subject'] user = msg['From'] # should try to parse msg['Date'] date = None @@ -58,13 +58,13 @@ branch = None parents = [] - if message: - if message.startswith('[PATCH'): - pend = message.find(']') + if subject: + if subject.startswith('[PATCH'): + pend = subject.find(']') if pend >= 0: - message = message[pend+1:].lstrip() - message = message.replace('\n\t', ' ') - ui.debug('Subject: %s\n' % message) + subject = subject[pend+1:].lstrip() + subject = subject.replace('\n\t', ' ') + ui.debug('Subject: %s\n' % subject) if user: ui.debug('From: %s\n' % user) diffs_seen = 0 @@ -84,9 +84,6 @@ ui.debug(_('found patch at byte %d\n') % m.start(0)) diffs_seen += 1 cfp = cStringIO.StringIO() - if message: - cfp.write(message) - cfp.write('\n') for line in payload[:m.start(0)].splitlines(): if line.startswith('# HG changeset patch'): ui.debug(_('patch generated by hg export\n')) @@ -123,6 +120,8 @@ os.unlink(tmpname) raise + if subject and not message.startswith(subject): + message = '%s\n%s' % (subject, message) tmpfp.close() if not diffs_seen: os.unlink(tmpname)