diff --git a/tests/test-import.out b/tests/test-import.out deleted file mode 100644 --- a/tests/test-import.out +++ /dev/null @@ -1,381 +0,0 @@ -adding a -adding d1/d2/a -% import exported patch -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../tip.patch -% message should be same -summary: second change -% committer should be same -user: someone -% import exported patch with external patcher -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../tip.patch -line2 -% import of plain diff should fail without message -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../tip.patch -abort: empty commit message -% import of plain diff should be ok with message -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../tip.patch -% import of plain diff with specific date and user -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../tip.patch -changeset: 1:ca68f19f3a40 -tag: tip -user: user@nowhere.net -date: Thu Jan 01 00:00:01 1970 +0000 -files: a -description: -patch - - -diff -r 80971e65b431 -r ca68f19f3a40 a ---- a/a Thu Jan 01 00:00:00 1970 +0000 -+++ b/a Thu Jan 01 00:00:01 1970 +0000 -@@ -1,1 +1,2 @@ - line 1 -+line 2 - -% import of plain diff should be ok with --no-commit -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../tip.patch -diff -r 80971e65b431 a ---- a/a -+++ b/a -@@ -1,1 +1,2 @@ - line 1 -+line 2 -% hg -R repo import -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying tip.patch -% import from stdin -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -% import two patches in one stream -applying patch from stdin -applied 80971e65b431 -1d4bd90af0e4 tip -1d4bd90af0e4 tip -% override commit message -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -summary: override -% plain diff in email, subject, message body -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../msg.patch -user: email patcher -summary: email patch -% plain diff in email, no subject, message body -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -% plain diff in email, subject, no message body -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -% plain diff in email, no subject, no message body, should fail -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -abort: empty commit message -% hg export in email, should use patch header -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -summary: second change -% plain diff in email, [PATCH] subject, message body with subject -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin -email patch - -next line ---- -% import patch1 patch2; rollback -parent: 0 -applying ../patch1 -applying ../patch2 -applied 1d4bd90af0e4 -rolling back to revision 1 (undo commit) -parent: 1 -% hg import in a subdirectory -requesting all changes -adding changesets -adding manifests -adding file changes -added 1 changesets with 2 changes to 2 files -updating to branch default -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying ../../../tip.patch -% message should be 'subdir change' -summary: subdir change -% committer should be 'someoneelse' -user: someoneelse -% should be empty -% test fuzziness -adding a -1 files updated, 0 files merged, 0 files removed, 0 files unresolved -created new head -applying tip.patch -patching file a -Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines). -reverting a -% test fuzziness with eol=auto -applying tip.patch -patching file a -Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines). -adding a -adding b1 -adding c1 -adding d -diff --git a/a b/a ---- a/a -+++ b/a -@@ -0,0 +1,1 @@ -+a -diff --git a/b1 b/b2 -rename from b1 -rename to b2 ---- a/b1 -+++ b/b2 -@@ -0,0 +1,1 @@ -+b -diff --git a/c1 b/c1 ---- a/c1 -+++ b/c1 -@@ -0,0 +1,1 @@ -+c -diff --git a/c1 b/c2 -copy from c1 -copy to c2 ---- a/c1 -+++ b/c2 -@@ -0,0 +1,1 @@ -+c -diff --git a/d b/d ---- a/d -+++ b/d -@@ -1,1 +0,0 @@ --d -4 files updated, 0 files merged, 2 files removed, 0 files unresolved -applying empty.diff -% a file -a -% b1 file -% b2 file -b -% c1 file -c -% c2 file -c -% d file -% test trailing binary removal -adding a -adding b -R a -R b -diff --git a/a b/a -diff --git a/b b/b -2 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying remove.diff -% test update+rename with common name (issue 927) -adding a -1 files updated, 0 files merged, 1 files removed, 0 files unresolved -applying copy.diff -% view a -a -% view a2 -a -% test -p0 -adding a -applying patch from stdin -bb -% test paths outside repo root -applying patch from stdin -abort: ../outside/foo not under root -% test import with similarity and git and strip (issue295 et al.) -adding a -applying ../rename.diff -patching file a -patching file b -removing a -adding b -recording removal of a as rename to b (88% similar) -A b - a -R a -undeleting a -forgetting b -applying ../rename.diff -patching file a -patching file b -removing a -adding b -A b -R a -% add empty file from the end of patch (issue 1495) -adding a -applying a.patch -% create file when source is not /dev/null -applying ../create.patch -a -applying ../create2.patch -a -% 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 - - -% --- in commit message -applying a.patch -changeset: 0:f34d9187897d -tag: tip -user: test -date: Thu Jan 01 00:00:00 1970 +0000 -files: a -description: -module: summary - - -% tricky header splitting -applying ../trickyheaders.patch -# HG changeset patch -# User User B -# Date 0 0 -# Node ID eb56ab91903632294ac504838508cb370c0901d2 -# Parent 0000000000000000000000000000000000000000 -from: tricky! - -That is not a header. - -diff --git a/foo b/foo -new file mode 100644 ---- /dev/null -+++ b/foo -@@ -0,0 +1,1 @@ -+foo -% issue2102 -adding src/cmd/gc/mksys.bash -applying patch from stdin -parent: 1:d59915696727 tip - help management of empty pkg and lib directories in perforce -branch: default -commit: (clean) -update: (current) -diff --git a/lib/place-holder b/lib/place-holder -new file mode 100644 ---- /dev/null -+++ b/lib/place-holder -@@ -0,0 +1,2 @@ -+perforce does not maintain empty directories. -+this file helps. -diff --git a/pkg/place-holder b/pkg/place-holder -new file mode 100644 ---- /dev/null -+++ b/pkg/place-holder -@@ -0,0 +1,2 @@ -+perforce does not maintain empty directories. -+this file helps. -diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash -old mode 100644 -new mode 100755 -% diff lines looking like headers -adding a -adding b -adding c -3 files updated, 0 files merged, 0 files removed, 0 files unresolved -applying patch from stdin diff --git a/tests/test-import b/tests/test-import.t old mode 100755 new mode 100644 rename from tests/test-import rename to tests/test-import.t --- a/tests/test-import +++ b/tests/test-import.t @@ -1,497 +1,916 @@ -#!/bin/sh + $ hg init a + $ mkdir a/d1 + $ mkdir a/d1/d2 + $ echo line 1 > a/a + $ echo line 1 > a/d1/d2/a + $ hg --cwd a ci -Ama + adding a + adding d1/d2/a + + $ echo line 2 >> a/a + $ hg --cwd a ci -u someone -d '1 0' -m'second change' + + +import exported patch -hg init a -mkdir a/d1 -mkdir a/d1/d2 -echo line 1 > a/a -echo line 1 > a/d1/d2/a -hg --cwd a ci -Ama + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip > tip.patch + $ hg --cwd b import ../tip.patch + applying ../tip.patch -echo line 2 >> a/a -hg --cwd a ci -u someone -d '1 0' -m'second change' +message should be same + + $ hg --cwd b tip | grep 'second change' + summary: second change + +committer should be same + + $ hg --cwd b tip | grep someone + user: someone + $ rm -r b + + +import exported patch with external patcher -echo % import exported patch -hg clone -r0 a b -hg --cwd a export tip > tip.patch -hg --cwd b import ../tip.patch -echo % message should be same -hg --cwd b tip | grep 'second change' -echo % committer should be same -hg --cwd b tip | grep someone -rm -r b + $ cat > dummypatch.py < print 'patching file a' + > file('a', 'wb').write('line2\n') + > EOF + $ chmod +x dummypatch.py + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip > tip.patch + $ hg --config ui.patch='python ../dummypatch.py' --cwd b import ../tip.patch + applying ../tip.patch + $ cat b/a + line2 + $ rm -r b + + +import of plain diff should fail without message -echo % import exported patch with external patcher -cat > dummypatch.py < tip.patch -hg --config ui.patch='python ../dummypatch.py' --cwd b import ../tip.patch -cat b/a -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a diff -r0:1 > tip.patch + $ hg --cwd b import ../tip.patch + applying ../tip.patch + abort: empty commit message + $ rm -r b + -echo % import of plain diff should fail without message -hg clone -r0 a b -hg --cwd a diff -r0:1 > tip.patch -hg --cwd b import ../tip.patch -rm -r b +import of plain diff should be ok with message + + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a diff -r0:1 > tip.patch + $ hg --cwd b import -mpatch ../tip.patch + applying ../tip.patch + $ rm -r b + + +import of plain diff with specific date and user -echo % import of plain diff should be ok with message -hg clone -r0 a b -hg --cwd a diff -r0:1 > tip.patch -hg --cwd b import -mpatch ../tip.patch -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a diff -r0:1 > tip.patch + $ hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../tip.patch + applying ../tip.patch + $ hg -R b tip -pv + changeset: 1:ca68f19f3a40 + tag: tip + user: user@nowhere.net + date: Thu Jan 01 00:00:01 1970 +0000 + files: a + description: + patch + + + diff -r 80971e65b431 -r ca68f19f3a40 a + --- a/a Thu Jan 01 00:00:00 1970 +0000 + +++ b/a Thu Jan 01 00:00:01 1970 +0000 + @@ -1,1 +1,2 @@ + line 1 + +line 2 + + $ rm -r b -echo % import of plain diff with specific date and user -hg clone -r0 a b -hg --cwd a diff -r0:1 > tip.patch -hg --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../tip.patch -hg -R b tip -pv -rm -r b + +import of plain diff should be ok with --no-commit -echo % import of plain diff should be ok with --no-commit -hg clone -r0 a b -hg --cwd a diff -r0:1 > tip.patch -hg --cwd b import --no-commit ../tip.patch -hg --cwd b diff --nodates -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a diff -r0:1 > tip.patch + $ hg --cwd b import --no-commit ../tip.patch + applying ../tip.patch + $ hg --cwd b diff --nodates + diff -r 80971e65b431 a + --- a/a + +++ b/a + @@ -1,1 +1,2 @@ + line 1 + +line 2 + $ rm -r b + + +hg -R repo import +put the clone in a subdir - having a directory named "a" +used to hide a bug. -echo % hg -R repo import -# put the clone in a subdir - having a directory named "a" -# used to hide a bug. -mkdir dir -hg clone -r0 a dir/b -hg --cwd a export tip > dir/tip.patch -cd dir -hg -R b import tip.patch -cd .. -rm -r dir + $ mkdir dir + $ hg clone -r0 a dir/b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip > dir/tip.patch + $ cd dir + $ hg -R b import tip.patch + applying tip.patch + $ cd .. + $ rm -r dir + + +import from stdin -echo % import from stdin -hg clone -r0 a b -hg --cwd a export tip | hg --cwd b import - -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip | hg --cwd b import - + applying patch from stdin + $ rm -r b + + +import two patches in one stream -echo % import two patches in one stream -hg init b -hg --cwd a export 0:tip | hg --cwd b import - -hg --cwd a id -hg --cwd b id -rm -r b + $ hg init b + $ hg --cwd a export 0:tip | hg --cwd b import - + applying patch from stdin + applied 80971e65b431 + $ hg --cwd a id + 1d4bd90af0e4 tip + $ hg --cwd b id + 1d4bd90af0e4 tip + $ rm -r b + + +override commit message + + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip | hg --cwd b import -m 'override' - + applying patch from stdin + $ hg --cwd b tip | grep override + summary: override + $ rm -r b -echo % override commit message -hg clone -r0 a b -hg --cwd a export tip | hg --cwd b import -m 'override' - -hg --cwd b tip | grep override -rm -r b + $ cat > mkmsg.py < import email.Message, sys + > msg = email.Message.Message() + > msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read()) + > msg['Subject'] = 'email patch' + > msg['From'] = 'email patcher' + > sys.stdout.write(msg.as_string()) + > EOF + + +plain diff in email, subject, message body -cat > mkmsg.py < tip.patch + $ python mkmsg.py > msg.patch + $ hg --cwd b import ../msg.patch + applying ../msg.patch + $ hg --cwd b tip | grep email + user: email patcher + summary: email patch + $ rm -r b + + +plain diff in email, no subject, message body + + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ grep -v '^Subject:' msg.patch | hg --cwd b import - + applying patch from stdin + $ rm -r b + + +plain diff in email, subject, no message body -echo % plain diff in email, subject, message body -hg clone -r0 a b -hg --cwd a diff -r0:1 > tip.patch -python mkmsg.py > msg.patch -hg --cwd b import ../msg.patch -hg --cwd b tip | grep email -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ grep -v '^email ' msg.patch | hg --cwd b import - + applying patch from stdin + $ rm -r b + + +plain diff in email, no subject, no message body, should fail -echo % plain diff in email, no subject, message body -hg clone -r0 a b -grep -v '^Subject:' msg.patch | hg --cwd b import - -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - + applying patch from stdin + abort: empty commit message + $ rm -r b + + +hg export in email, should use patch header -echo % plain diff in email, subject, no message body -hg clone -r0 a b -grep -v '^email ' msg.patch | hg --cwd b import - -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip > tip.patch + $ python mkmsg.py | hg --cwd b import - + applying patch from stdin + $ hg --cwd b tip | grep second + summary: second change + $ rm -r b -echo % plain diff in email, no subject, no message body, should fail -hg clone -r0 a b -egrep -v '^(Subject|email)' msg.patch | hg --cwd b import - -rm -r b + +subject: duplicate detection, removal of [PATCH] +The '---' tests the gitsendmail handling without proper mail headers -echo % hg export in email, should use patch header -hg clone -r0 a b -hg --cwd a export tip > tip.patch -python mkmsg.py | hg --cwd b import - -hg --cwd b tip | grep second -rm -r b + $ cat > mkmsg2.py < import email.Message, sys + > msg = email.Message.Message() + > msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read()) + > msg['Subject'] = '[PATCH] email patch' + > msg['From'] = 'email patcher' + > sys.stdout.write(msg.as_string()) + > EOF + + +plain diff in email, [PATCH] subject, message body with subject -# subject: duplicate detection, removal of [PATCH] -# The '---' tests the gitsendmail handling without proper mail headers -cat > mkmsg2.py < tip.patch + $ python mkmsg2.py | hg --cwd b import - + applying patch from stdin + $ hg --cwd b tip --template '{desc}\n' + email patch + + next line + --- + $ rm -r b + + +We weren't backing up the correct dirstate file when importing many patches +(issue963) +import patch1 patch2; rollback -echo '% plain diff in email, [PATCH] subject, message body with subject' -hg clone -r0 a b -hg --cwd a diff -r0:1 > tip.patch -python mkmsg2.py | hg --cwd b import - -hg --cwd b tip --template '{desc}\n' -rm -r b + $ echo line 3 >> a/a + $ hg --cwd a ci -m'third change' + $ hg --cwd a export -o '../patch%R' 1 2 + $ hg clone -qr0 a b + $ hg --cwd b parents --template 'parent: {rev}\n' + parent: 0 + $ hg --cwd b import ../patch1 ../patch2 + applying ../patch1 + applying ../patch2 + applied 1d4bd90af0e4 + $ hg --cwd b rollback + rolling back to revision 1 (undo commit) + $ hg --cwd b parents --template 'parent: {rev}\n' + parent: 1 + $ rm -r b + + +importing a patch in a subdirectory failed at the commit stage + + $ echo line 2 >> a/d1/d2/a + $ hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' + +hg import in a subdirectory -# We weren't backing up the correct dirstate file when importing many patches -# (issue963) -echo '% import patch1 patch2; rollback' -echo line 3 >> a/a -hg --cwd a ci -m'third change' -hg --cwd a export -o '../patch%R' 1 2 -hg clone -qr0 a b -hg --cwd b parents --template 'parent: {rev}\n' -hg --cwd b import ../patch1 ../patch2 -hg --cwd b rollback -hg --cwd b parents --template 'parent: {rev}\n' -rm -r b + $ hg clone -r0 a b + requesting all changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 2 changes to 2 files + updating to branch default + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch + $ dir=`pwd` + $ cd b/d1/d2 2>&1 > /dev/null + $ hg import ../../../tip.patch + applying ../../../tip.patch + $ cd "$dir" + +message should be 'subdir change' + + $ hg --cwd b tip | grep 'subdir change' + summary: subdir change + +committer should be 'someoneelse' + + $ hg --cwd b tip | grep someoneelse + user: someoneelse + +should be empty + + $ hg --cwd b status + + +Test fuzziness (ambiguous patch location, fuzz=2) -# bug non regression test -# importing a patch in a subdirectory failed at the commit stage -echo line 2 >> a/d1/d2/a -hg --cwd a ci -u someoneelse -d '1 0' -m'subdir change' -echo % hg import in a subdirectory -hg clone -r0 a b -hg --cwd a export tip | sed -e 's/d1\/d2\///' > tip.patch -dir=`pwd` -cd b/d1/d2 2>&1 > /dev/null -hg import ../../../tip.patch -cd "$dir" -echo "% message should be 'subdir change'" -hg --cwd b tip | grep 'subdir change' -echo "% committer should be 'someoneelse'" -hg --cwd b tip | grep someoneelse -echo "% should be empty" -hg --cwd b status + $ hg init fuzzy + $ cd fuzzy + $ echo line1 > a + $ echo line0 >> a + $ echo line3 >> a + $ hg ci -Am adda + adding a + $ echo line1 > a + $ echo line2 >> a + $ echo line0 >> a + $ echo line3 >> a + $ hg ci -m change a + $ hg export tip > tip.patch + $ hg up -C 0 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ echo line1 > a + $ echo line0 >> a + $ echo line1 >> a + $ echo line0 >> a + $ hg ci -m brancha + created new head + $ hg import --no-commit -v tip.patch + applying tip.patch + patching file a + Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines). + $ hg revert -a + reverting a + +test fuzziness with eol=auto + + $ hg --config patch.eol=auto import --no-commit -v tip.patch + applying tip.patch + patching file a + Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines). + $ cd .. -# Test fuzziness (ambiguous patch location, fuzz=2) -echo % test fuzziness -hg init fuzzy -cd fuzzy -echo line1 > a -echo line0 >> a -echo line3 >> a -hg ci -Am adda -echo line1 > a -echo line2 >> a -echo line0 >> a -echo line3 >> a -hg ci -m change a -hg export tip > tip.patch -hg up -C 0 -echo line1 > a -echo line0 >> a -echo line1 >> a -echo line0 >> a -hg ci -m brancha -hg import --no-commit -v tip.patch -hg revert -a -echo '% test fuzziness with eol=auto' -hg --config patch.eol=auto import --no-commit -v tip.patch -cd .. +Test hunk touching empty files (issue906) -# Test hunk touching empty files (issue906) -hg init empty -cd empty -touch a -touch b1 -touch c1 -echo d > d -hg ci -Am init -echo a > a -echo b > b1 -hg mv b1 b2 -echo c > c1 -hg copy c1 c2 -rm d -touch d -hg diff --git -hg ci -m empty -hg export --git tip > empty.diff -hg up -C 0 -hg import empty.diff -for name in a b1 b2 c1 c2 d; -do - echo % $name file - test -f $name && cat $name -done -cd .. + $ hg init empty + $ cd empty + $ touch a + $ touch b1 + $ touch c1 + $ echo d > d + $ hg ci -Am init + adding a + adding b1 + adding c1 + adding d + $ echo a > a + $ echo b > b1 + $ hg mv b1 b2 + $ echo c > c1 + $ hg copy c1 c2 + $ rm d + $ touch d + $ hg diff --git + diff --git a/a b/a + --- a/a + +++ b/a + @@ -0,0 +1,1 @@ + +a + diff --git a/b1 b/b2 + rename from b1 + rename to b2 + --- a/b1 + +++ b/b2 + @@ -0,0 +1,1 @@ + +b + diff --git a/c1 b/c1 + --- a/c1 + +++ b/c1 + @@ -0,0 +1,1 @@ + +c + diff --git a/c1 b/c2 + copy from c1 + copy to c2 + --- a/c1 + +++ b/c2 + @@ -0,0 +1,1 @@ + +c + diff --git a/d b/d + --- a/d + +++ b/d + @@ -1,1 +0,0 @@ + -d + $ hg ci -m empty + $ hg export --git tip > empty.diff + $ hg up -C 0 + 4 files updated, 0 files merged, 2 files removed, 0 files unresolved + $ hg import empty.diff + applying empty.diff + $ for name in a b1 b2 c1 c2 d; do + > echo % $name file + > test -f $name && cat $name + > done + % a file + a + % b1 file + % b2 file + b + % c1 file + c + % c2 file + c + % d file + $ cd .. -# Test importing a patch ending with a binary file removal -echo % test trailing binary removal -hg init binaryremoval -cd binaryremoval -echo a > a -python -c "file('b', 'wb').write('a\x00b')" -hg ci -Am addall -hg rm a -hg rm b -hg st -hg ci -m remove -hg export --git . > remove.diff -cat remove.diff | grep git -hg up -C 0 -hg import remove.diff -hg manifest -cd .. + +Test importing a patch ending with a binary file removal + + $ hg init binaryremoval + $ cd binaryremoval + $ echo a > a + $ python -c "file('b', 'wb').write('a\x00b')" + $ hg ci -Am addall + adding a + adding b + $ hg rm a + $ hg rm b + $ hg st + R a + R b + $ hg ci -m remove + $ hg export --git . > remove.diff + $ cat remove.diff | grep git + diff --git a/a b/a + diff --git a/b b/b + $ hg up -C 0 + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg import remove.diff + applying remove.diff + $ hg manifest + $ cd .. + + +test update+rename with common name (issue 927) -echo % 'test update+rename with common name (issue 927)' -hg init t -cd t -touch a -hg ci -Am t -echo a > a -# Here, bfile.startswith(afile) -hg copy a a2 -hg ci -m copya -hg export --git tip > copy.diff -hg up -C 0 -hg import copy.diff -echo % view a -# a should contain an 'a' -cat a -echo % view a2 -# and a2 should have duplicated it -cat a2 -cd .. + $ hg init t + $ cd t + $ touch a + $ hg ci -Am t + adding a + $ echo a > a + +Here, bfile.startswith(afile) + + $ hg copy a a2 + $ hg ci -m copya + $ hg export --git tip > copy.diff + $ hg up -C 0 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved + $ hg import copy.diff + applying copy.diff + +a should contain an 'a' + + $ cat a + a + +and a2 should have duplicated it -echo % 'test -p0' -hg init p0 -cd p0 -echo a > a -hg ci -Am t -hg import -p0 - << EOF -foobar ---- a Sat Apr 12 22:43:58 2008 -0400 -+++ a Sat Apr 12 22:44:05 2008 -0400 -@@ -1,1 +1,1 @@ --a -+bb -EOF -hg status -cat a -cd .. + $ cat a2 + a + $ cd .. + + +test -p0 + + $ hg init p0 + $ cd p0 + $ echo a > a + $ hg ci -Am t + adding a + $ hg import -p0 - << EOF + > foobar + > --- a Sat Apr 12 22:43:58 2008 -0400 + > +++ a Sat Apr 12 22:44:05 2008 -0400 + > @@ -1,1 +1,1 @@ + > -a + > +bb + > EOF + applying patch from stdin + $ hg status + $ cat a + bb + $ cd .. + + +test paths outside repo root -echo % 'test paths outside repo root' -mkdir outside -touch outside/foo -hg init inside -cd inside -hg import - < diff --git a/a b/b + > rename from ../outside/foo + > rename to bar + > EOF + applying patch from stdin + abort: ../outside/foo not under root + $ cd .. + + +test import with similarity and git and strip (issue295 et al.) -echo '% test import with similarity and git and strip (issue295 et al.)' -hg init sim -cd sim -echo 'this is a test' > a -hg ci -Ama -cat > ../rename.diff < a + $ hg ci -Ama + adding a + $ cat > ../rename.diff < diff --git a/foo/a b/foo/a + > deleted file mode 100644 + > --- a/foo/a + > +++ /dev/null + > @@ -1,1 +0,0 @@ + > -this is a test + > diff --git a/foo/b b/foo/b + > new file mode 100644 + > --- /dev/null + > +++ b/foo/b + > @@ -0,0 +1,2 @@ + > +this is a test + > +foo + > EOF + $ hg import --no-commit -v -s 1 ../rename.diff -p2 + applying ../rename.diff + patching file a + patching file b + removing a + adding b + recording removal of a as rename to b (88% similar) + $ hg st -C + A b + a + R a + $ hg revert -a + undeleting a + forgetting b + $ rm b + $ hg import --no-commit -v -s 100 ../rename.diff -p2 + applying ../rename.diff + patching file a + patching file b + removing a + adding b + $ hg st -C + A b + R a + $ cd .. -echo '% add empty file from the end of patch (issue 1495)' -hg init addemptyend -cd addemptyend -touch a -hg addremove -hg ci -m "commit" -cat > a.patch < a.patch < diff --git a/a b/a + > --- a/a + > +++ b/a + > @@ -0,0 +1,1 @@ + > +a + > diff --git a/b b/b + > new file mode 100644 + > EOF + $ hg import --no-commit a.patch + applying a.patch + $ cd .. + + +create file when source is not /dev/null + + $ cat > create.patch < diff -Naur proj-orig/foo proj-new/foo + > --- proj-orig/foo 1969-12-31 16:00:00.000000000 -0800 + > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700 + > @@ -0,0 +1,1 @@ + > +a + > EOF + +some people have patches like the following too -echo '% create file when source is not /dev/null' -cat > create.patch < create2.patch < create2.patch < diff -Naur proj-orig/foo proj-new/foo + > --- proj-orig/foo.orig 1969-12-31 16:00:00.000000000 -0800 + > +++ proj-new/foo 2009-07-17 16:50:45.801368000 -0700 + > @@ -0,0 +1,1 @@ + > +a + > EOF + $ hg init oddcreate + $ cd oddcreate + $ hg import --no-commit ../create.patch + applying ../create.patch + $ cat foo + a + $ rm foo + $ hg revert foo + $ hg import --no-commit ../create2.patch + applying ../create2.patch + $ cat foo + a + + +first line mistaken for email headers (issue 1859) -echo % 'first line mistaken for email headers (issue 1859)' -hg init emailconfusion -cd emailconfusion -cat > a.patch < a.patch < 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 + applying a.patch + $ hg parents -v + changeset: 0:5a681217c0ad + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + files: a + description: + module: summary + + description + + + $ cd .. -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 .. - -echo % '--- in commit message' -hg init commitconfusion -cd commitconfusion -cat > a.patch < trickyheaders.patch < -Subject: [PATCH] from: tricky! + $ hg init commitconfusion + $ cd commitconfusion + $ cat > a.patch < module: summary + > + > --- description + > + > diff --git a/a b/a + > new file mode 100644 + > --- /dev/null + > +++ b/a + > @@ -0,0 +1,1 @@ + > +a + > EOF + > hg import -d '0 0' a.patch + > hg parents -v + > cd .. + > + > echo '% tricky header splitting' + > cat > trickyheaders.patch < From: User A + > Subject: [PATCH] from: tricky! + > + > # HG changeset patch + > # User User B + > # Date 1266264441 18000 + > # Branch stable + > # Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0 + > # Parent 0000000000000000000000000000000000000000 + > from: tricky! + > + > That is not a header. + > + > diff -r 000000000000 -r f2be6a1170ac foo + > --- /dev/null + > +++ b/foo + > @@ -0,0 +1,1 @@ + > +foo + > EOF + applying a.patch + changeset: 0:f34d9187897d + tag: tip + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + files: a + description: + module: summary + + + % tricky header splitting -# HG changeset patch -# User User B -# Date 1266264441 18000 -# Branch stable -# Node ID f2be6a1170ac83bf31cb4ae0bad00d7678115bc0 -# Parent 0000000000000000000000000000000000000000 -from: tricky! - -That is not a header. + $ hg init trickyheaders + $ cd trickyheaders + $ hg import -d '0 0' ../trickyheaders.patch + applying ../trickyheaders.patch + $ hg export --git tip + # HG changeset patch + # User User B + # Date 0 0 + # Node ID eb56ab91903632294ac504838508cb370c0901d2 + # Parent 0000000000000000000000000000000000000000 + from: tricky! + + That is not a header. + + diff --git a/foo b/foo + new file mode 100644 + --- /dev/null + +++ b/foo + @@ -0,0 +1,1 @@ + +foo + $ cd .. -diff -r 000000000000 -r f2be6a1170ac foo ---- /dev/null -+++ b/foo -@@ -0,0 +1,1 @@ -+foo -EOF -hg init trickyheaders -cd trickyheaders -hg import -d '0 0' ../trickyheaders.patch -hg export --git tip -cd .. +issue2102 -echo '% issue2102' -hg init issue2102 -cd issue2102 -mkdir -p src/cmd/gc -touch src/cmd/gc/mksys.bash -hg ci -Am init -hg import - < # HG changeset patch + > # User Rob Pike + > # Date 1216685449 25200 + > # Node ID 03aa2b206f499ad6eb50e6e207b9e710d6409c98 + > # Parent 93d10138ad8df586827ca90b4ddb5033e21a3a84 + > help management of empty pkg and lib directories in perforce + > + > R=gri + > DELTA=4 (4 added, 0 deleted, 0 changed) + > OCL=13328 + > CL=13328 + > + > diff --git a/lib/place-holder b/lib/place-holder + > new file mode 100644 + > --- /dev/null + > +++ b/lib/place-holder + > @@ -0,0 +1,2 @@ + > +perforce does not maintain empty directories. + > +this file helps. + > diff --git a/pkg/place-holder b/pkg/place-holder + > new file mode 100644 + > --- /dev/null + > +++ b/pkg/place-holder + > @@ -0,0 +1,2 @@ + > +perforce does not maintain empty directories. + > +this file helps. + > diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash + > old mode 100644 + > new mode 100755 + > EOF + applying patch from stdin + $ hg sum + parent: 1:d59915696727 tip + help management of empty pkg and lib directories in perforce + branch: default + commit: (clean) + update: (current) + $ hg diff --git -c tip + diff --git a/lib/place-holder b/lib/place-holder + new file mode 100644 + --- /dev/null + +++ b/lib/place-holder + @@ -0,0 +1,2 @@ + +perforce does not maintain empty directories. + +this file helps. + diff --git a/pkg/place-holder b/pkg/place-holder + new file mode 100644 + --- /dev/null + +++ b/pkg/place-holder + @@ -0,0 +1,2 @@ + +perforce does not maintain empty directories. + +this file helps. + diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash + old mode 100644 + new mode 100755 + $ cd .. -diff --git a/lib/place-holder b/lib/place-holder -new file mode 100644 ---- /dev/null -+++ b/lib/place-holder -@@ -0,0 +1,2 @@ -+perforce does not maintain empty directories. -+this file helps. -diff --git a/pkg/place-holder b/pkg/place-holder -new file mode 100644 ---- /dev/null -+++ b/pkg/place-holder -@@ -0,0 +1,2 @@ -+perforce does not maintain empty directories. -+this file helps. -diff --git a/src/cmd/gc/mksys.bash b/src/cmd/gc/mksys.bash -old mode 100644 -new mode 100755 -EOF -hg sum -hg diff --git -c tip -cd .. + +diff lines looking like headers + + $ hg init difflineslikeheaders + $ cd difflineslikeheaders + $ echo a >a + $ echo b >b + $ echo c >c + $ hg ci -Am1 + adding a + adding b + adding c -echo '% diff lines looking like headers' -hg init difflineslikeheaders -cd difflineslikeheaders -echo a >a -echo b >b -echo c >c -hg ci -Am1 + $ echo "key: value" >>a + $ echo "key: value" >>b + $ echo "foo" >>c + $ hg ci -m2 -echo "key: value" >>a -echo "key: value" >>b -echo "foo" >>c -hg ci -m2 + $ hg up -C 0 + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg diff --git -c1 >want + $ hg diff -c1 | hg import --no-commit - + applying patch from stdin + $ hg diff --git >have + $ diff want have + $ cd .. -hg up -C 0 -hg diff --git -c1 >want -hg diff -c1 | hg import --no-commit - -hg diff --git >have -diff want have -cd .. -