##// END OF EJS Templates
patch.extract: do not prepend subject if the description already starts with it
Brendan Cully -
r4777:5ee5cbfc default
parent child Browse files
Show More
@@ -50,7 +50,7 b' def extract(ui, fileobj):'
50 try:
50 try:
51 msg = email.Parser.Parser().parse(fileobj)
51 msg = email.Parser.Parser().parse(fileobj)
52
52
53 message = msg['Subject']
53 subject = msg['Subject']
54 user = msg['From']
54 user = msg['From']
55 # should try to parse msg['Date']
55 # should try to parse msg['Date']
56 date = None
56 date = None
@@ -58,13 +58,13 b' def extract(ui, fileobj):'
58 branch = None
58 branch = None
59 parents = []
59 parents = []
60
60
61 if message:
61 if subject:
62 if message.startswith('[PATCH'):
62 if subject.startswith('[PATCH'):
63 pend = message.find(']')
63 pend = subject.find(']')
64 if pend >= 0:
64 if pend >= 0:
65 message = message[pend+1:].lstrip()
65 subject = subject[pend+1:].lstrip()
66 message = message.replace('\n\t', ' ')
66 subject = subject.replace('\n\t', ' ')
67 ui.debug('Subject: %s\n' % message)
67 ui.debug('Subject: %s\n' % subject)
68 if user:
68 if user:
69 ui.debug('From: %s\n' % user)
69 ui.debug('From: %s\n' % user)
70 diffs_seen = 0
70 diffs_seen = 0
@@ -84,9 +84,6 b' def extract(ui, fileobj):'
84 ui.debug(_('found patch at byte %d\n') % m.start(0))
84 ui.debug(_('found patch at byte %d\n') % m.start(0))
85 diffs_seen += 1
85 diffs_seen += 1
86 cfp = cStringIO.StringIO()
86 cfp = cStringIO.StringIO()
87 if message:
88 cfp.write(message)
89 cfp.write('\n')
90 for line in payload[:m.start(0)].splitlines():
87 for line in payload[:m.start(0)].splitlines():
91 if line.startswith('# HG changeset patch'):
88 if line.startswith('# HG changeset patch'):
92 ui.debug(_('patch generated by hg export\n'))
89 ui.debug(_('patch generated by hg export\n'))
@@ -123,6 +120,8 b' def extract(ui, fileobj):'
123 os.unlink(tmpname)
120 os.unlink(tmpname)
124 raise
121 raise
125
122
123 if subject and not message.startswith(subject):
124 message = '%s\n%s' % (subject, message)
126 tmpfp.close()
125 tmpfp.close()
127 if not diffs_seen:
126 if not diffs_seen:
128 os.unlink(tmpname)
127 os.unlink(tmpname)
General Comments 0
You need to be logged in to leave comments. Login now