[PATCH Version 2] tests: unify test-git-import

Adrian Buehlmann adrian at cadifra.com
Fri Sep 3 12:17:48 CDT 2010


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1283533881 -7200
# Node ID d6974a685b379aa70c26928496e4303d1222378a
# Parent  5b4c2991a2636e8e8cc6b057d91475911cdb10f0
tests: unify test-git-import

diff --git a/tests/test-git-import.out b/tests/test-git-import.out
deleted file mode 100644
--- a/tests/test-git-import.out
+++ /dev/null
@@ -1,82 +0,0 @@
-% new file
-applying patch from stdin
-0:ae3ee40d2079
-% new empty file
-applying patch from stdin
-1:ab199dc869b5
-empty
-% chmod +x
-applying patch from stdin
-2:3a34410f282e
-% copy
-applying patch from stdin
-3:37bacb7ca14d
-a
-a
-% rename
-applying patch from stdin
-4:47b81a94361d
-copyx
-empty
-new
-rename
-% delete
-applying patch from stdin
-5:d9b001d98336
-empty
-new
-rename
-% regular diff
-applying patch from stdin
-6:ebe901e7576b
-% copy and modify
-applying patch from stdin
-7:18f368958ecd
-a
-a
-b
-a
-a
-% rename and modify
-applying patch from stdin
-8:c32b0d7e6f44
-a
-a
-b
-c
-a
-% one file renamed multiple times
-applying patch from stdin
-9:034a6bf95330
-9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
-rename3
-rename3-2
-a
-a
-b
-c
-a
-
-a
-a
-b
-c
-a
-% binary files and regular patch hunks
-applying patch from stdin
-11:c39bce63e786
-foo
-045c85ba38952325e126c70962cc0f9d9077bc67 644   binary
-% many binary files
-applying patch from stdin
-12:30b530085242
-045c85ba38952325e126c70962cc0f9d9077bc67 644   mbinary1
-a874b471193996e7cb034bb301cac7bdaf3e3f46 644   mbinary2
-% filenames with spaces
-applying patch from stdin
-13:04750ef42fb3
-foo
-% copy then modify the original file
-applying patch from stdin
-14:c4cd9cdeaa74
-foo
diff --git a/tests/test-git-import b/tests/test-git-import.t
old mode 100755
new mode 100644
rename from tests/test-git-import
rename to tests/test-git-import.t
--- a/tests/test-git-import
+++ b/tests/test-git-import.t
@@ -1,230 +1,335 @@
-#!/bin/sh
 
-hg init a
-cd a
+  $ hg init
 
-echo % new file
-hg import -d "1000000 0" -mnew - <<EOF
-diff --git a/new b/new
-new file mode 100644
-index 0000000..7898192
---- /dev/null
-+++ b/new
-@@ -0,0 +1 @@
-+a
-EOF
-hg tip -q
+New file:
 
-echo % new empty file
-hg import -d "1000000 0" -mempty - <<EOF
-diff --git a/empty b/empty
-new file mode 100644
-EOF
-hg tip -q
-hg locate empty
+  $ hg import -d "1000000 0" -mnew - <<EOF
+  > diff --git a/new b/new
+  > new file mode 100644
+  > index 0000000..7898192
+  > --- /dev/null
+  > +++ b/new
+  > @@ -0,0 +1 @@
+  > +a
+  > EOF
+  applying patch from stdin
 
-echo % chmod +x
-hg import -d "1000000 0" -msetx - <<EOF
-diff --git a/new b/new
-old mode 100644
-new mode 100755
-EOF
-hg tip -q
+  $ hg tip -q
+  0:ae3ee40d2079
 
-test -x new || echo failed
+New empty file:
 
-echo % copy
-hg import -d "1000000 0" -mcopy - <<EOF
-diff --git a/new b/copy
-old mode 100755
-new mode 100644
-similarity index 100%
-copy from new
-copy to copy
-diff --git a/new b/copyx
-similarity index 100%
-copy from new
-copy to copyx
-EOF
-hg tip -q
+  $ hg import -d "1000000 0" -mempty - <<EOF
+  > diff --git a/empty b/empty
+  > new file mode 100644
+  > EOF
+  applying patch from stdin
 
-if "$TESTDIR/hghave" -q execbit; then
-    test -f copy -a ! -x copy || echo failed
-    test -x copyx || echo failed
-else
-    test -f copy || echo failed
-fi
-cat copy
-hg cat copy
+  $ hg tip -q
+  1:ab199dc869b5
 
-echo % rename
-hg import -d "1000000 0" -mrename - <<EOF
-diff --git a/copy b/rename
-similarity index 100%
-rename from copy
-rename to rename
-EOF
-hg tip -q
+  $ hg locate empty
+  empty
 
-hg locate
+chmod +x:
 
-echo % delete
-hg import -d "1000000 0" -mdelete - <<EOF
-diff --git a/copyx b/copyx
-deleted file mode 100755
-index 7898192..0000000
---- a/copyx
-+++ /dev/null
-@@ -1 +0,0 @@
--a
-EOF
-hg tip -q
+  $ hg import -d "1000000 0" -msetx - <<EOF
+  > diff --git a/new b/new
+  > old mode 100644
+  > new mode 100755
+  > EOF
+  applying patch from stdin
 
-hg locate
-test -f copyx && echo failed || true
+  $ hg tip -q
+  2:3a34410f282e
 
-echo % regular diff
-hg import -d "1000000 0" -mregular - <<EOF
-diff --git a/rename b/rename
-index 7898192..72e1fe3 100644
---- a/rename
-+++ b/rename
-@@ -1 +1,5 @@
- a
-+a
-+a
-+a
-+a
-EOF
-hg tip -q
+  $ test -x new || echo failed
 
-echo % copy and modify
-hg import -d "1000000 0" -mcopymod - <<EOF
-diff --git a/rename b/copy2
-similarity index 80%
-copy from rename
-copy to copy2
-index 72e1fe3..b53c148 100644
---- a/rename
-+++ b/copy2
-@@ -1,5 +1,5 @@
- a
- a
--a
-+b
- a
- a
-EOF
-hg tip -q
+Copy:
 
-hg cat copy2
+  $ hg import -d "1000000 0" -mcopy - <<EOF
+  > diff --git a/new b/copy
+  > old mode 100755
+  > new mode 100644
+  > similarity index 100%
+  > copy from new
+  > copy to copy
+  > diff --git a/new b/copyx
+  > similarity index 100%
+  > copy from new
+  > copy to copyx
+  > EOF
+  applying patch from stdin
 
-echo % rename and modify
-hg import -d "1000000 0" -mrenamemod - <<EOF
-diff --git a/copy2 b/rename2
-similarity index 80%
-rename from copy2
-rename to rename2
-index b53c148..8f81e29 100644
---- a/copy2
-+++ b/rename2
-@@ -1,5 +1,5 @@
- a
- a
- b
--a
-+c
- a
-EOF
-hg tip -q
+  $ hg tip -q
+  3:37bacb7ca14d
 
-hg locate copy2
-hg cat rename2
+  $ if "$TESTDIR/hghave" -q execbit; then
+  >     test -f copy -a ! -x copy || echo failed
+  >     test -x copyx || echo failed
+  > else
+  >     test -f copy || echo failed
+  > fi
 
-echo % one file renamed multiple times
-hg import -d "1000000 0" -mmultirenames - <<EOF
-diff --git a/rename2 b/rename3
-rename from rename2
-rename to rename3
-diff --git a/rename2 b/rename3-2
-rename from rename2
-rename to rename3-2
-EOF
-hg tip -q
-hg log -vr. --template '{rev} {files} / {file_copies}\n'
+  $ cat copy
+  a
 
-hg locate rename2 rename3 rename3-2
-hg cat rename3
-echo
-hg cat rename3-2
+  $ hg cat copy
+  a
 
-echo foo > foo
-hg add foo
-hg ci -m 'add foo'
-echo % binary files and regular patch hunks
-hg import -d "1000000 0" -m binaryregular - <<EOF
-diff --git a/binary b/binary
-new file mode 100644
-index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
-GIT binary patch
-literal 4
-Lc\${NkU|;|M00aO5
+Rename:
 
-diff --git a/foo b/foo2
-rename from foo
-rename to foo2
-EOF
-hg tip -q
-cat foo2
-hg manifest --debug | grep binary
+  $ hg import -d "1000000 0" -mrename - <<EOF
+  > diff --git a/copy b/rename
+  > similarity index 100%
+  > rename from copy
+  > rename to rename
+  > EOF
+  applying patch from stdin
 
-echo % many binary files
-hg import -d "1000000 0" -m multibinary - <<EOF
-diff --git a/mbinary1 b/mbinary1
-new file mode 100644
-index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
-GIT binary patch
-literal 4
-Lc\${NkU|;|M00aO5
+  $ hg tip -q
+  4:47b81a94361d
 
-diff --git a/mbinary2 b/mbinary2
-new file mode 100644
-index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490
-GIT binary patch
-literal 5
-Mc\${NkU|\`?^000jF3jhEB
+  $ hg locate
+  copyx
+  empty
+  new
+  rename
 
-EOF
-hg tip -q
-hg manifest --debug | grep mbinary
+Delete:
 
-echo % filenames with spaces
-hg import -d "1000000 0" -m spaces - <<EOF
-diff --git a/foo bar b/foo bar
-new file mode 100644
-index 0000000..257cc56
---- /dev/null
-+++ b/foo bar	
-@@ -0,0 +1 @@
-+foo
-EOF
-hg tip -q
-cat "foo bar"
+  $ hg import -d "1000000 0" -mdelete - <<EOF
+  > diff --git a/copyx b/copyx
+  > deleted file mode 100755
+  > index 7898192..0000000
+  > --- a/copyx
+  > +++ /dev/null
+  > @@ -1 +0,0 @@
+  > -a
+  > EOF
+  applying patch from stdin
 
-echo % copy then modify the original file
-hg import -d "1000000 0" -m copy-mod-orig - <<EOF
-diff --git a/foo2 b/foo2
-index 257cc56..fe08ec6 100644
---- a/foo2
-+++ b/foo2
-@@ -1 +1,2 @@
- foo
-+new line
-diff --git a/foo2 b/foo3
-similarity index 100%
-copy from foo2
-copy to foo3
-EOF
-hg tip -q
+  $ hg tip -q
+  5:d9b001d98336
 
-cat foo3
+  $ hg locate
+  empty
+  new
+  rename
+
+  $ test -f copyx && echo failed || true
+
+Regular diff:
+
+  $ hg import -d "1000000 0" -mregular - <<EOF
+  > diff --git a/rename b/rename
+  > index 7898192..72e1fe3 100644
+  > --- a/rename
+  > +++ b/rename
+  > @@ -1 +1,5 @@
+  >  a
+  > +a
+  > +a
+  > +a
+  > +a
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  6:ebe901e7576b
+
+Copy and modify:
+
+  $ hg import -d "1000000 0" -mcopymod - <<EOF
+  > diff --git a/rename b/copy2
+  > similarity index 80%
+  > copy from rename
+  > copy to copy2
+  > index 72e1fe3..b53c148 100644
+  > --- a/rename
+  > +++ b/copy2
+  > @@ -1,5 +1,5 @@
+  >  a
+  >  a
+  > -a
+  > +b
+  >  a
+  >  a
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  7:18f368958ecd
+
+  $ hg cat copy2
+  a
+  a
+  b
+  a
+  a
+
+Rename and modify:
+
+  $ hg import -d "1000000 0" -mrenamemod - <<EOF
+  > diff --git a/copy2 b/rename2
+  > similarity index 80%
+  > rename from copy2
+  > rename to rename2
+  > index b53c148..8f81e29 100644
+  > --- a/copy2
+  > +++ b/rename2
+  > @@ -1,5 +1,5 @@
+  >  a
+  >  a
+  >  b
+  > -a
+  > +c
+  >  a
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  8:c32b0d7e6f44
+
+  $ hg locate copy2
+  $ hg cat rename2
+  a
+  a
+  b
+  c
+  a
+
+One file renamed multiple times:
+
+  $ hg import -d "1000000 0" -mmultirenames - <<EOF
+  > diff --git a/rename2 b/rename3
+  > rename from rename2
+  > rename to rename3
+  > diff --git a/rename2 b/rename3-2
+  > rename from rename2
+  > rename to rename3-2
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  9:034a6bf95330
+
+  $ hg log -vr. --template '{rev} {files} / {file_copies}\n'
+  9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
+
+  $ hg locate rename2 rename3 rename3-2
+  rename3
+  rename3-2
+
+  $ hg cat rename3
+  a
+  a
+  b
+  c
+  a
+
+  $ hg cat rename3-2
+  a
+  a
+  b
+  c
+  a
+
+  $ echo foo > foo
+  $ hg add foo
+  $ hg ci -m 'add foo'
+
+Binary files and regular patch hunks:
+
+  $ hg import -d "1000000 0" -m binaryregular - <<EOF
+  > diff --git a/binary b/binary
+  > new file mode 100644
+  > index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
+  > GIT binary patch
+  > literal 4
+  > Lc\${NkU|;|M00aO5
+  > 
+  > diff --git a/foo b/foo2
+  > rename from foo
+  > rename to foo2
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  11:c39bce63e786
+
+  $ cat foo2
+  foo
+
+  $ hg manifest --debug | grep binary
+  045c85ba38952325e126c70962cc0f9d9077bc67 644   binary
+
+Multiple binary files:
+
+  $ hg import -d "1000000 0" -m multibinary - <<EOF
+  > diff --git a/mbinary1 b/mbinary1
+  > new file mode 100644
+  > index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
+  > GIT binary patch
+  > literal 4
+  > Lc\${NkU|;|M00aO5
+  > 
+  > diff --git a/mbinary2 b/mbinary2
+  > new file mode 100644
+  > index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490
+  > GIT binary patch
+  > literal 5
+  > Mc\${NkU|\`?^000jF3jhEB
+  > 
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  12:30b530085242
+
+  $ hg manifest --debug | grep mbinary
+  045c85ba38952325e126c70962cc0f9d9077bc67 644   mbinary1
+  a874b471193996e7cb034bb301cac7bdaf3e3f46 644   mbinary2
+
+Filenames with spaces:
+
+  $ hg import -d "1000000 0" -m spaces - <<EOF
+  > diff --git a/foo bar b/foo bar
+  > new file mode 100644
+  > index 0000000..257cc56
+  > --- /dev/null
+  > +++ b/foo bar	
+  > @@ -0,0 +1 @@
+  > +foo
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  13:04750ef42fb3
+
+  $ cat "foo bar"
+  foo
+
+Copy then modify the original file:
+
+  $ hg import -d "1000000 0" -m copy-mod-orig - <<EOF
+  > diff --git a/foo2 b/foo2
+  > index 257cc56..fe08ec6 100644
+  > --- a/foo2
+  > +++ b/foo2
+  > @@ -1 +1,2 @@
+  >  foo
+  > +new line
+  > diff --git a/foo2 b/foo3
+  > similarity index 100%
+  > copy from foo2
+  > copy to foo3
+  > EOF
+  applying patch from stdin
+
+  $ hg tip -q
+  14:c4cd9cdeaa74
+
+  $ cat foo3
+  foo
+


More information about the Mercurial-devel mailing list