##// END OF EJS Templates
run-tests: give each child its own tmp dir (issue1911)...
run-tests: give each child its own tmp dir (issue1911) Fixes bug introduced by f8b4df4b033d (issue1911: --tmpdir plus parallel mode = fail), and also fixes the long-standing quirk that parallel mode created multiple /tmp/hgtests.XXXXXX directories. Now there is only one /tmp/hgtests.XXXXXX, with child0, child1, etc. under it.

File last commit:

r9594:f0c5c59d merge default
r9899:be574a37 stable
Show More
test-import
367 lines | 7.5 KiB | text/plain | TextLexer
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 #!/bin/sh
hg init a
"Mathieu Clabaut "
Import say a file is not tracked after patching : test case
r2773 mkdir a/d1
mkdir a/d1/d2
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 echo line 1 > a/a
"Mathieu Clabaut "
Import say a file is not tracked after patching : test case
r2773 echo line 1 > a/d1/d2/a
Martin Geisler
tests: removed redundant "-d '0 0'" from test scripts...
r8167 hg --cwd a ci -Ama
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
echo line 2 >> a/a
hg --cwd a ci -u someone -d '1 0' -m'second change'
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
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
Patrick Mezard
patch: fix patched files records in externalpatcher()
r7247 echo % import exported patch with external patcher
cat > dummypatch.py <<EOF
print 'patching file a'
file('a', 'wb').write('line2\n')
EOF
chmod +x dummypatch.py
hg clone -r0 a b
hg --cwd a export tip > tip.patch
hg --config ui.patch='python ../dummypatch.py' --cwd b import ../tip.patch
cat b/a
rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 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
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
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
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
Jesse Glick
Permitting the import command to accept a --user option....
r5953 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
Thomas Arendsen Hein
Test case for hg import --no-commit
r5937 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
Alexis S. L. Carvalho
Fix handling of paths when run outside the repo....
r4230 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
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 echo % import from stdin
hg clone -r0 a b
hg --cwd a export tip | hg --cwd b import -
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
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
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
cat > mkmsg.py <<EOF
import email.Message, sys
msg = email.Message.Message()
Patrick Mezard
test-import: read email payload in binary mode
r5530 msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read())
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513 msg['Subject'] = 'email patch'
msg['From'] = 'email patcher'
sys.stdout.write(msg.as_string())
EOF
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
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
echo % plain diff in email, no subject, message body
hg clone -r0 a b
grep -v '^Subject:' msg.patch | hg --cwd b import -
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
echo % plain diff in email, subject, no message body
hg clone -r0 a b
grep -v '^email ' msg.patch | hg --cwd b import -
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
echo % plain diff in email, no subject, no message body, should fail
hg clone -r0 a b
Danek Duvall
Fix some tests for portability.
r2843 egrep -v '^(Subject|email)' msg.patch | hg --cwd b import -
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
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
Thomas Arendsen Hein
Don't use -f for rm in tests where not needed. Drop /bin/ from /bin/rm.
r3988 rm -r b
Vadim Gelfer
import: added tests, fixed bugs found by tests and asak.
r2513
Thomas Arendsen Hein
Added import test for [PATCH] subject and message body with subject
r4779 # subject: duplicate detection, removal of [PATCH]
Patrick Mezard
patch: fix git sendmail handling without proper mail headers
r5418 # The '---' tests the gitsendmail handling without proper mail headers
Thomas Arendsen Hein
Added import test for [PATCH] subject and message body with subject
r4779 cat > mkmsg2.py <<EOF
import email.Message, sys
msg = email.Message.Message()
Patrick Mezard
patch: fix git sendmail handling without proper mail headers
r5418 msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read())
Thomas Arendsen Hein
Added import test for [PATCH] subject and message body with subject
r4779 msg['Subject'] = '[PATCH] email patch'
msg['From'] = 'email patcher'
sys.stdout.write(msg.as_string())
EOF
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
Alexis S. L. Carvalho
hg import: write the dirstate after every commit...
r5986 # 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
Martin Geisler
tests: replace #...# syntax with {...}
r8523 hg --cwd b parents --template 'parent: {rev}\n'
Alexis S. L. Carvalho
hg import: write the dirstate after every commit...
r5986 hg --cwd b import ../patch1 ../patch2
hg --cwd b rollback
Martin Geisler
tests: replace #...# syntax with {...}
r8523 hg --cwd b parents --template 'parent: {rev}\n'
Alexis S. L. Carvalho
hg import: write the dirstate after every commit...
r5986 rm -r b
Thomas Arendsen Hein
Added import test for [PATCH] subject and message body with subject
r4779
"Mathieu Clabaut "
Import say a file is not tracked after patching : test case
r2773 # 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
Danek Duvall
Fix some tests for portability.
r2843 dir=`pwd`
cd b/d1/d2 2>&1 > /dev/null
"Mathieu Clabaut "
Import say a file is not tracked after patching : test case
r2773 hg import ../../../tip.patch
Danek Duvall
Fix some tests for portability.
r2843 cd $dir
"Mathieu Clabaut "
Import say a file is not tracked after patching : test case
r2773 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
Patrick Mezard
test-import: test fuzziness, ambiguous patch locations
r5548
# 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 -v tip.patch
cd ..
Patrick Mezard
patch: handle empty vs no file in git patches (issue906)
r5852
# 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 ..
Patrick Mezard
patch: fix iterhunks() with trailing binary file removal...
r6179 # 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 ..
Patrick Mezard
patch: fix corner case with update + copy patch handling (issue 937)...
r6295 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 ..
Benoit Boissinot
fix import with -p0
r6520
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 ..
Brendan Cully
Check that git patches only touch files under root
r6758
echo % 'test paths outside repo root'
mkdir outside
touch outside/foo
hg init inside
cd inside
hg import - <<EOF
diff --git a/a b/b
rename from ../outside/foo
rename to bar
EOF
cd ..
Brendan Cully
import: add similarity option (issue295)
r7402
echo '% test import with similarity (issue295)'
hg init sim
cd sim
echo 'this is a test' > a
hg ci -Ama
cat > ../rename.diff <<EOF
diff --git a/a b/a
deleted file mode 100644
--- a/a
+++ /dev/null
@@ -1,1 +0,0 @@
-this is a test
diff --git a/b b/b
new file mode 100644
--- /dev/null
+++ b/b
@@ -0,0 +1,2 @@
+this is a test
+foo
EOF
hg import --no-commit -v -s 1 ../rename.diff
hg st -C
hg revert -a
rm b
hg import --no-commit -v -s 100 ../rename.diff
hg st -C
cd ..
Vsevolod Solovyov
Fix issue1495, corner case of adding empty files via patching
r7971
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 <<EOF
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
cd ..
Patrick Mezard
patch: do not swallow header-like patch first line (issue1859)...
r9573
Brendan Cully
patch: create file even if source is not /dev/null...
r9328 echo '% create file when source is not /dev/null'
cat > create.patch <<EOF
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
hg init oddcreate
cd oddcreate
hg import --no-commit ../create.patch
cat foo
Matt Mackall
Merge with stable
r9576
Patrick Mezard
patch: do not swallow header-like patch first line (issue1859)...
r9573 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 ..