Mercurial > hg
changeset 5235:988ed47d9d65
mq: some improvements to header rewriting (closes #690)
Tested with qrefresh -m against the mm series.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Thu, 23 Aug 2007 13:59:52 -0700 |
parents | b772c0b9f0bd |
children | 335696e2a58f 8860f29447c1 |
files | hgext/mq.py |
diffstat | 1 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/mq.py Thu Aug 23 12:24:54 2007 -0700 +++ b/hgext/mq.py Thu Aug 23 13:59:52 2007 -0700 @@ -926,17 +926,24 @@ break msg = opts.get('msg', '').rstrip() + if msg and comments: + # Remove existing message, keeping the rest of the comments + # fields. + # If comments contains 'subject: ', message will prepend + # the field and a blank line. + if message: + subj = 'subject: ' + message[0].lower() + for i in xrange(len(comments)): + if subj == comments[i].lower(): + del comments[i] + message = message[2:] + break + ci = 0 + for mi in xrange(len(message)): + while message[mi] != comments[ci]: + ci += 1 + del comments[ci] if msg: - if comments: - # Remove existing message. - ci = 0 - subj = None - for mi in xrange(len(message)): - if comments[ci].lower().startswith('subject: '): - subj = comments[ci][9:] - while message[mi] != comments[ci] and message[mi] != subj: - ci += 1 - del comments[ci] comments.append(msg) patchf.seek(0)