comparison mercurial/patch.py @ 5418:9b469bdb1ce1

patch: fix git sendmail handling without proper mail headers
author Patrick Mezard <pmezard@gmail.com>
date Mon, 08 Oct 2007 22:20:23 +0200
parents 477136fa6571
children bff41174563f
comparison
equal deleted inserted replaced
5417:b8872655f951 5418:9b469bdb1ce1
57 try: 57 try:
58 msg = email.Parser.Parser().parse(fileobj) 58 msg = email.Parser.Parser().parse(fileobj)
59 59
60 subject = msg['Subject'] 60 subject = msg['Subject']
61 user = msg['From'] 61 user = msg['From']
62 gitsendmail = 'git-send-email' in msg.get('X-Mailer', '')
62 # should try to parse msg['Date'] 63 # should try to parse msg['Date']
63 date = None 64 date = None
64 nodeid = None 65 nodeid = None
65 branch = None 66 branch = None
66 parents = [] 67 parents = []
109 branch = line[9:] 110 branch = line[9:]
110 elif line.startswith("# Node ID "): 111 elif line.startswith("# Node ID "):
111 nodeid = line[10:] 112 nodeid = line[10:]
112 elif line.startswith("# Parent "): 113 elif line.startswith("# Parent "):
113 parents.append(line[10:]) 114 parents.append(line[10:])
114 elif line == '---' and 'git-send-email' in msg['X-Mailer']: 115 elif line == '---' and gitsendmail:
115 ignoretext = True 116 ignoretext = True
116 if not line.startswith('# ') and not ignoretext: 117 if not line.startswith('# ') and not ignoretext:
117 cfp.write(line) 118 cfp.write(line)
118 cfp.write('\n') 119 cfp.write('\n')
119 message = cfp.getvalue() 120 message = cfp.getvalue()