# HG changeset patch # User Patrick Mezard # Date 1255038153 -7200 # Node ID b8352a3617f3a5040decd14f15db57e2462bc204 # Parent 1f665246dab3140a72954fbd089a784224898462 patch: do not swallow header-like patch first line (issue1859) Current solution is hackish but looks like a good trade-off short of rewriting patch.extract() significantly. diff -r 1f665246dab3 -r b8352a3617f3 mercurial/patch.py --- a/mercurial/patch.py Thu Oct 08 23:32:36 2009 +0200 +++ b/mercurial/patch.py Thu Oct 08 23:42:33 2009 +0200 @@ -63,6 +63,10 @@ subject = msg['Subject'] user = msg['From'] + if not subject and not user: + # Not an email, restore parsed headers if any + subject = '\n'.join(': '.join(h) for h in msg.items()) + '\n' + gitsendmail = 'git-send-email' in msg.get('X-Mailer', '') # should try to parse msg['Date'] date = None diff -r 1f665246dab3 -r b8352a3617f3 tests/test-import --- a/tests/test-import Thu Oct 08 23:32:36 2009 +0200 +++ b/tests/test-import Thu Oct 08 23:42:33 2009 +0200 @@ -332,3 +332,23 @@ EOF hg import --no-commit a.patch cd .. + +echo % 'first line mistaken for email headers (issue 1859)' +hg init emailconfusion +cd emailconfusion +cat > a.patch <