Mercurial > hg-stable
changeset 9573:b8352a3617f3
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.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 08 Oct 2009 23:42:33 +0200 |
parents | 1f665246dab3 |
children | 9e9f63d5c456 012f1244cd4c |
files | mercurial/patch.py tests/test-import tests/test-import.out |
diffstat | 3 files changed, 37 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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 <<EOF +module: summary + +description + + +diff -r 000000000000 -r 9b4c1e343b55 test.txt +--- /dev/null ++++ b/a +@@ -0,0 +1,1 @@ ++a +EOF +hg import -d '0 0' a.patch +hg parents -v +cd .. +
--- a/tests/test-import.out Thu Oct 08 23:32:36 2009 +0200 +++ b/tests/test-import.out Thu Oct 08 23:42:33 2009 +0200 @@ -292,3 +292,16 @@ % add empty file from the end of patch (issue 1495) adding a applying a.patch +% first line mistaken for email headers (issue 1859) +applying a.patch +changeset: 0:5a681217c0ad +tag: tip +user: test +date: Thu Jan 01 00:00:00 1970 +0000 +files: a +description: +module: summary + +description + +