comparison tests/test-git-import.t @ 12193:927e1a677267

tests: unify test-git-*
author Adrian Buehlmann <adrian@cadifra.com>
date Fri, 03 Sep 2010 14:29:28 +0200
parents tests/test-git-import@377d879e9d1b
children 4134686b83e1
comparison
equal deleted inserted replaced
12192:968e9057ab8a 12193:927e1a677267
1
2 $ hg init
3
4 New file:
5
6 $ hg import -d "1000000 0" -mnew - <<EOF
7 > diff --git a/new b/new
8 > new file mode 100644
9 > index 0000000..7898192
10 > --- /dev/null
11 > +++ b/new
12 > @@ -0,0 +1 @@
13 > +a
14 > EOF
15 applying patch from stdin
16
17 $ hg tip -q
18 0:ae3ee40d2079
19
20 New empty file:
21
22 $ hg import -d "1000000 0" -mempty - <<EOF
23 > diff --git a/empty b/empty
24 > new file mode 100644
25 > EOF
26 applying patch from stdin
27
28 $ hg tip -q
29 1:ab199dc869b5
30
31 $ hg locate empty
32 empty
33
34 chmod +x:
35
36 $ hg import -d "1000000 0" -msetx - <<EOF
37 > diff --git a/new b/new
38 > old mode 100644
39 > new mode 100755
40 > EOF
41 applying patch from stdin
42
43 $ hg tip -q
44 2:3a34410f282e
45
46 $ test -x new || echo failed
47
48 Copy:
49
50 $ hg import -d "1000000 0" -mcopy - <<EOF
51 > diff --git a/new b/copy
52 > old mode 100755
53 > new mode 100644
54 > similarity index 100%
55 > copy from new
56 > copy to copy
57 > diff --git a/new b/copyx
58 > similarity index 100%
59 > copy from new
60 > copy to copyx
61 > EOF
62 applying patch from stdin
63
64 $ hg tip -q
65 3:37bacb7ca14d
66
67 $ if "$TESTDIR/hghave" -q execbit; then
68 > test -f copy -a ! -x copy || echo failed
69 > test -x copyx || echo failed
70 > else
71 > test -f copy || echo failed
72 > fi
73
74 $ cat copy
75 a
76
77 $ hg cat copy
78 a
79
80 Rename:
81
82 $ hg import -d "1000000 0" -mrename - <<EOF
83 > diff --git a/copy b/rename
84 > similarity index 100%
85 > rename from copy
86 > rename to rename
87 > EOF
88 applying patch from stdin
89
90 $ hg tip -q
91 4:47b81a94361d
92
93 $ hg locate
94 copyx
95 empty
96 new
97 rename
98
99 Delete:
100
101 $ hg import -d "1000000 0" -mdelete - <<EOF
102 > diff --git a/copyx b/copyx
103 > deleted file mode 100755
104 > index 7898192..0000000
105 > --- a/copyx
106 > +++ /dev/null
107 > @@ -1 +0,0 @@
108 > -a
109 > EOF
110 applying patch from stdin
111
112 $ hg tip -q
113 5:d9b001d98336
114
115 $ hg locate
116 empty
117 new
118 rename
119
120 $ test -f copyx && echo failed || true
121
122 Regular diff:
123
124 $ hg import -d "1000000 0" -mregular - <<EOF
125 > diff --git a/rename b/rename
126 > index 7898192..72e1fe3 100644
127 > --- a/rename
128 > +++ b/rename
129 > @@ -1 +1,5 @@
130 > a
131 > +a
132 > +a
133 > +a
134 > +a
135 > EOF
136 applying patch from stdin
137
138 $ hg tip -q
139 6:ebe901e7576b
140
141 Copy and modify:
142
143 $ hg import -d "1000000 0" -mcopymod - <<EOF
144 > diff --git a/rename b/copy2
145 > similarity index 80%
146 > copy from rename
147 > copy to copy2
148 > index 72e1fe3..b53c148 100644
149 > --- a/rename
150 > +++ b/copy2
151 > @@ -1,5 +1,5 @@
152 > a
153 > a
154 > -a
155 > +b
156 > a
157 > a
158 > EOF
159 applying patch from stdin
160
161 $ hg tip -q
162 7:18f368958ecd
163
164 $ hg cat copy2
165 a
166 a
167 b
168 a
169 a
170
171 Rename and modify:
172
173 $ hg import -d "1000000 0" -mrenamemod - <<EOF
174 > diff --git a/copy2 b/rename2
175 > similarity index 80%
176 > rename from copy2
177 > rename to rename2
178 > index b53c148..8f81e29 100644
179 > --- a/copy2
180 > +++ b/rename2
181 > @@ -1,5 +1,5 @@
182 > a
183 > a
184 > b
185 > -a
186 > +c
187 > a
188 > EOF
189 applying patch from stdin
190
191 $ hg tip -q
192 8:c32b0d7e6f44
193
194 $ hg locate copy2
195 $ hg cat rename2
196 a
197 a
198 b
199 c
200 a
201
202 One file renamed multiple times:
203
204 $ hg import -d "1000000 0" -mmultirenames - <<EOF
205 > diff --git a/rename2 b/rename3
206 > rename from rename2
207 > rename to rename3
208 > diff --git a/rename2 b/rename3-2
209 > rename from rename2
210 > rename to rename3-2
211 > EOF
212 applying patch from stdin
213
214 $ hg tip -q
215 9:034a6bf95330
216
217 $ hg log -vr. --template '{rev} {files} / {file_copies}\n'
218 9 rename2 rename3 rename3-2 / rename3 (rename2)rename3-2 (rename2)
219
220 $ hg locate rename2 rename3 rename3-2
221 rename3
222 rename3-2
223
224 $ hg cat rename3
225 a
226 a
227 b
228 c
229 a
230
231 $ hg cat rename3-2
232 a
233 a
234 b
235 c
236 a
237
238 $ echo foo > foo
239 $ hg add foo
240 $ hg ci -m 'add foo'
241
242 Binary files and regular patch hunks:
243
244 $ hg import -d "1000000 0" -m binaryregular - <<EOF
245 > diff --git a/binary b/binary
246 > new file mode 100644
247 > index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
248 > GIT binary patch
249 > literal 4
250 > Lc\${NkU|;|M00aO5
251 >
252 > diff --git a/foo b/foo2
253 > rename from foo
254 > rename to foo2
255 > EOF
256 applying patch from stdin
257
258 $ hg tip -q
259 11:c39bce63e786
260
261 $ cat foo2
262 foo
263
264 $ hg manifest --debug | grep binary
265 045c85ba38952325e126c70962cc0f9d9077bc67 644 binary
266
267 Multiple binary files:
268
269 $ hg import -d "1000000 0" -m multibinary - <<EOF
270 > diff --git a/mbinary1 b/mbinary1
271 > new file mode 100644
272 > index 0000000000000000000000000000000000000000..593f4708db84ac8fd0f5cc47c634f38c013fe9e4
273 > GIT binary patch
274 > literal 4
275 > Lc\${NkU|;|M00aO5
276 >
277 > diff --git a/mbinary2 b/mbinary2
278 > new file mode 100644
279 > index 0000000000000000000000000000000000000000..112363ac1917b417ffbd7f376ca786a1e5fa7490
280 > GIT binary patch
281 > literal 5
282 > Mc\${NkU|\`?^000jF3jhEB
283 >
284 > EOF
285 applying patch from stdin
286
287 $ hg tip -q
288 12:30b530085242
289
290 $ hg manifest --debug | grep mbinary
291 045c85ba38952325e126c70962cc0f9d9077bc67 644 mbinary1
292 a874b471193996e7cb034bb301cac7bdaf3e3f46 644 mbinary2
293
294 Filenames with spaces:
295
296 $ hg import -d "1000000 0" -m spaces - <<EOF
297 > diff --git a/foo bar b/foo bar
298 > new file mode 100644
299 > index 0000000..257cc56
300 > --- /dev/null
301 > +++ b/foo bar
302 > @@ -0,0 +1 @@
303 > +foo
304 > EOF
305 applying patch from stdin
306
307 $ hg tip -q
308 13:04750ef42fb3
309
310 $ cat "foo bar"
311 foo
312
313 Copy then modify the original file:
314
315 $ hg import -d "1000000 0" -m copy-mod-orig - <<EOF
316 > diff --git a/foo2 b/foo2
317 > index 257cc56..fe08ec6 100644
318 > --- a/foo2
319 > +++ b/foo2
320 > @@ -1 +1,2 @@
321 > foo
322 > +new line
323 > diff --git a/foo2 b/foo3
324 > similarity index 100%
325 > copy from foo2
326 > copy to foo3
327 > EOF
328 applying patch from stdin
329
330 $ hg tip -q
331 14:c4cd9cdeaa74
332
333 $ cat foo3
334 foo
335