tests: do not export several times the same patch/diff in test-import
authorNicolas Dumazet <nicdumz.commits@gmail.com>
Sat, 30 Apr 2011 18:31:28 +0200
changeset 14125 2852843947da
parent 14124 81ecc951f57b
child 14126 fbbe9239574a
tests: do not export several times the same patch/diff in test-import
tests/test-import.t
--- a/tests/test-import.t	Sat Apr 30 17:38:06 2011 +0200
+++ b/tests/test-import.t	Sat Apr 30 18:31:28 2011 +0200
@@ -11,6 +11,12 @@
   $ hg --cwd a ci -u someone -d '1 0' -m'second change'
 
 
+generate patches for the test
+
+  $ hg --cwd a export tip > exported-tip.patch
+  $ hg --cwd a diff -r0:1 > diffed-tip.patch
+
+
 import exported patch
 
   $ hg clone -r0 a b
@@ -20,19 +26,18 @@
   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
+  $ hg --cwd b import ../exported-tip.patch
+  applying ../exported-tip.patch
 
-message should be same
+message and committer should be same
 
-  $ hg --cwd b tip | grep 'second change'
+  $ hg --cwd b tip
+  changeset:   1:1d4bd90af0e4
+  tag:         tip
+  user:        someone
+  date:        Thu Jan 01 00:00:01 1970 +0000
   summary:     second change
-
-committer should be same
-
-  $ hg --cwd b tip | grep someone
-  user:        someone
+  
   $ rm -r b
 
 
@@ -50,9 +55,8 @@
   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
+  $ hg --config ui.patch='python ../dummypatch.py' --cwd b import ../exported-tip.patch
+  applying ../exported-tip.patch
   $ cat b/a
   line2
   $ rm -r b
@@ -67,9 +71,8 @@
   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
+  $ hg --cwd b import ../diffed-tip.patch
+  applying ../diffed-tip.patch
   abort: empty commit message
   [255]
   $ rm -r b
@@ -84,9 +87,8 @@
   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
+  $ hg --cwd b import -mpatch ../diffed-tip.patch
+  applying ../diffed-tip.patch
   $ rm -r b
 
 
@@ -99,9 +101,8 @@
   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 --cwd b import -mpatch -d '1 0' -u 'user@nowhere.net' ../diffed-tip.patch
+  applying ../diffed-tip.patch
   $ hg -R b tip -pv
   changeset:   1:ca68f19f3a40
   tag:         tip
@@ -131,9 +132,8 @@
   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 import --no-commit ../diffed-tip.patch
+  applying ../diffed-tip.patch
   $ hg --cwd b diff --nodates
   diff -r 80971e65b431 a
   --- a/a
@@ -153,8 +153,7 @@
   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
-  $ sed 's/1,1/foo/' < tip.patch > broken.patch
+  $ sed 's/1,1/foo/' < diffed-tip.patch > broken.patch
   $ hg --cwd b import -mpatch ../broken.patch
   applying ../broken.patch
   abort: bad hunk #1
@@ -174,10 +173,9 @@
   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
+  $ hg -R b import ../exported-tip.patch
+  applying ../exported-tip.patch
   $ cd ..
   $ rm -r dir
 
@@ -191,7 +189,7 @@
   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 -
+  $ hg --cwd b import - < exported-tip.patch
   applying patch from stdin
   $ rm -r b
 
@@ -218,7 +216,7 @@
   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' -
+  $ hg --cwd b import -m 'override' - < exported-tip.patch
   applying patch from stdin
   $ hg --cwd b tip | grep override
   summary:     override
@@ -227,7 +225,8 @@
   $ cat > mkmsg.py <<EOF
   > import email.Message, sys
   > msg = email.Message.Message()
-  > msg.set_payload('email commit message\n' + open('tip.patch', 'rb').read())
+  > patch = open(sys.argv[1], 'rb').read()
+  > msg.set_payload('email commit message\n' + patch)
   > msg['Subject'] = 'email patch'
   > msg['From'] = 'email patcher'
   > sys.stdout.write(msg.as_string())
@@ -243,8 +242,7 @@
   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
-  $ python mkmsg.py > msg.patch
+  $ python mkmsg.py diffed-tip.patch > msg.patch
   $ hg --cwd b import ../msg.patch
   applying ../msg.patch
   $ hg --cwd b tip | grep email
@@ -306,8 +304,7 @@
   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 -
+  $ python mkmsg.py exported-tip.patch | hg --cwd b import -
   applying patch from stdin
   $ hg --cwd b tip | grep second
   summary:     second change
@@ -320,7 +317,8 @@
   $ cat > mkmsg2.py <<EOF
   > import email.Message, sys
   > msg = email.Message.Message()
-  > msg.set_payload('email patch\n\nnext line\n---\n' + open('tip.patch').read())
+  > patch = open(sys.argv[1], 'rb').read()
+  > msg.set_payload('email patch\n\nnext line\n---\n' + patch)
   > msg['Subject'] = '[PATCH] email patch'
   > msg['From'] = 'email patcher'
   > sys.stdout.write(msg.as_string())
@@ -336,8 +334,7 @@
   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
-  $ python mkmsg2.py | hg --cwd b import -
+  $ python mkmsg2.py diffed-tip.patch | hg --cwd b import -
   applying patch from stdin
   $ hg --cwd b tip --template '{desc}\n'
   email patch
@@ -386,22 +383,23 @@
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg --cwd a export tip > tmp
-  $ sed -e 's/d1\/d2\///' < tmp > tip.patch
+  $ sed -e 's/d1\/d2\///' < tmp > subdir-tip.patch
   $ dir=`pwd`
   $ cd b/d1/d2 2>&1 > /dev/null
-  $ hg import  ../../../tip.patch
-  applying ../../../tip.patch
+  $ hg import  ../../../subdir-tip.patch
+  applying ../../../subdir-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
+  $ hg --cwd b tip
+  changeset:   1:3577f5aea227
+  tag:         tip
   user:        someoneelse
+  date:        Thu Jan 01 00:00:01 1970 +0000
+  summary:     subdir change
+  
 
 should be empty
 
@@ -422,7 +420,7 @@
   $ echo line0 >> a
   $ echo line3 >> a
   $ hg ci -m change a
-  $ hg export tip > tip.patch
+  $ hg export tip > fuzzy-tip.patch
   $ hg up -C 0
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ echo line1 > a
@@ -431,8 +429,8 @@
   $ echo line0 >> a
   $ hg ci -m brancha
   created new head
-  $ hg import --no-commit -v tip.patch
-  applying tip.patch
+  $ hg import --no-commit -v fuzzy-tip.patch
+  applying fuzzy-tip.patch
   patching file a
   Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
   $ hg revert -a
@@ -447,8 +445,8 @@
 
 test fuzziness with eol=auto
 
-  $ hg --config patch.eol=auto import --no-commit -v tip.patch
-  applying tip.patch
+  $ hg --config patch.eol=auto import --no-commit -v fuzzy-tip.patch
+  applying fuzzy-tip.patch
   patching file a
   Hunk #1 succeeded at 1 with fuzz 2 (offset -2 lines).
   $ cd ..