##// END OF EJS Templates
tests: unify test-eol-update
Matt Mackall -
r12424:1aa7ba33 default
parent child Browse files
Show More
@@ -1,83 +1,152
1 #!/bin/sh
1 Test EOL update
2
2
3 cat > $HGRCPATH <<EOF
3 $ cat > $HGRCPATH <<EOF
4 [diff]
4 > [diff]
5 git = 1
5 > git = 1
6 EOF
6 > EOF
7
7
8 seteol () {
8 $ seteol () {
9 if [ $1 = "LF" ]; then
9 > if [ $1 = "LF" ]; then
10 EOL='\n'
10 > EOL='\n'
11 else
11 > else
12 EOL='\r\n'
12 > EOL='\r\n'
13 fi
13 > fi
14 }
14 > }
15
15
16 makerepo () {
16 $ makerepo () {
17 echo
17 > echo
18 echo "# ==== setup repository ===="
18 > echo "# ==== setup repository ===="
19 echo '% hg init'
19 > echo '% hg init'
20 hg init repo
20 > hg init repo
21 cd repo
21 > cd repo
22
22 >
23 cat > .hgeol <<EOF
23 > cat > .hgeol <<EOF
24 [patterns]
24 > [patterns]
25 **.txt = LF
25 > **.txt = LF
26 EOF
26 > EOF
27
27 >
28 printf "first\nsecond\nthird\n" > a.txt
28 > printf "first\nsecond\nthird\n" > a.txt
29 hg commit --addremove -m 'LF commit'
29 > hg commit --addremove -m 'LF commit'
30
30 >
31 cat > .hgeol <<EOF
31 > cat > .hgeol <<EOF
32 [patterns]
32 > [patterns]
33 **.txt = CRLF
33 > **.txt = CRLF
34 EOF
34 > EOF
35
35 >
36 printf "first\r\nsecond\r\nthird\r\n" > a.txt
36 > printf "first\r\nsecond\r\nthird\r\n" > a.txt
37 hg commit -m 'CRLF commit'
37 > hg commit -m 'CRLF commit'
38
38 >
39 cd ..
39 > cd ..
40 }
40 > }
41
41
42 dotest () {
42 $ dotest () {
43 seteol $1
43 > seteol $1
44
44 >
45 echo
45 > echo
46 echo "% hg clone repo repo-$1"
46 > echo "% hg clone repo repo-$1"
47 hg clone --noupdate repo repo-$1
47 > hg clone --noupdate repo repo-$1
48 cd repo-$1
48 > cd repo-$1
49 >
50 > cat > .hg/hgrc <<EOF
51 > [extensions]
52 > eol =
53 > EOF
54 >
55 > hg update
56 >
57 > echo '% printrepr.py a.txt (before)'
58 > python $TESTDIR/printrepr.py < a.txt
59 >
60 > printf "first${EOL}third${EOL}" > a.txt
61 >
62 > echo '% printrepr.py a.txt (after)'
63 > python $TESTDIR/printrepr.py < a.txt
64 > echo '% hg diff'
65 > hg diff | python $TESTDIR/printrepr.py
66 >
67 > echo '% hg update 0'
68 > hg update 0
69 >
70 > echo '% printrepr.py a.txt'
71 > python $TESTDIR/printrepr.py < a.txt
72 > echo '% hg diff'
73 > hg diff | python $TESTDIR/printrepr.py
74 >
75 >
76 > cd ..
77 > rm -r repo-$1
78 > }
49
79
50 cat > .hg/hgrc <<EOF
80 $ makerepo
51 [extensions]
52 eol =
53 EOF
54
81
55 hg update
82 # ==== setup repository ====
56
83 % hg init
57 echo '% printrepr.py a.txt (before)'
84 adding .hgeol
58 python $TESTDIR/printrepr.py < a.txt
85 adding a.txt
59
86 $ dotest LF
60 printf "first${EOL}third${EOL}" > a.txt
61
87
62 echo '% printrepr.py a.txt (after)'
88 % hg clone repo repo-LF
63 python $TESTDIR/printrepr.py < a.txt
89 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
64 echo '% hg diff'
90 % printrepr.py a.txt (before)
65 hg diff | python $TESTDIR/printrepr.py
91 first\r
66
92 second\r
67 echo '% hg update 0'
93 third\r
68 hg update 0
94 % printrepr.py a.txt (after)
95 first
96 third
97 % hg diff
98 diff --git a/a.txt b/a.txt
99 --- a/a.txt
100 +++ b/a.txt
101 @@ -1,3 +1,2 @@
102 first\r
103 -second\r
104 third\r
105 % hg update 0
106 merging a.txt
107 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
108 % printrepr.py a.txt
109 first
110 third
111 % hg diff
112 diff --git a/a.txt b/a.txt
113 --- a/a.txt
114 +++ b/a.txt
115 @@ -1,3 +1,2 @@
116 first
117 -second
118 third
119 $ dotest CRLF
69
120
70 echo '% printrepr.py a.txt'
121 % hg clone repo repo-CRLF
71 python $TESTDIR/printrepr.py < a.txt
122 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
72 echo '% hg diff'
123 % printrepr.py a.txt (before)
73 hg diff | python $TESTDIR/printrepr.py
124 first\r
74
125 second\r
75
126 third\r
76 cd ..
127 % printrepr.py a.txt (after)
77 rm -r repo-$1
128 first\r
78 }
129 third\r
79
130 % hg diff
80 makerepo
131 diff --git a/a.txt b/a.txt
81 dotest LF
132 --- a/a.txt
82 dotest CRLF
133 +++ b/a.txt
83 rm -r repo
134 @@ -1,3 +1,2 @@
135 first\r
136 -second\r
137 third\r
138 % hg update 0
139 merging a.txt
140 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
141 % printrepr.py a.txt
142 first
143 third
144 % hg diff
145 diff --git a/a.txt b/a.txt
146 --- a/a.txt
147 +++ b/a.txt
148 @@ -1,3 +1,2 @@
149 first
150 -second
151 third
152 $ rm -r repo
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now