##// END OF EJS Templates
test-convert-git.t: add a test of convert progress bars for git...
Augie Fackler -
r22412:dde99b82 default
parent child Browse files
Show More
@@ -1,407 +1,443
1 1 #require git
2 2
3 3 $ echo "[core]" >> $HOME/.gitconfig
4 4 $ echo "autocrlf = false" >> $HOME/.gitconfig
5 5 $ echo "[core]" >> $HOME/.gitconfig
6 6 $ echo "autocrlf = false" >> $HOME/.gitconfig
7 7 $ echo "[extensions]" >> $HGRCPATH
8 8 $ echo "convert=" >> $HGRCPATH
9 9 $ GIT_AUTHOR_NAME='test'; export GIT_AUTHOR_NAME
10 10 $ GIT_AUTHOR_EMAIL='test@example.org'; export GIT_AUTHOR_EMAIL
11 11 $ GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0000"; export GIT_AUTHOR_DATE
12 12 $ GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME"; export GIT_COMMITTER_NAME
13 13 $ GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"; export GIT_COMMITTER_EMAIL
14 14 $ GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"; export GIT_COMMITTER_DATE
15 15 $ INVALIDID1=afd12345af
16 16 $ INVALIDID2=28173x36ddd1e67bf7098d541130558ef5534a86
17 17 $ VALIDID1=39b3d83f9a69a9ba4ebb111461071a0af0027357
18 18 $ VALIDID2=8dd6476bd09d9c7776355dc454dafe38efaec5da
19 19 $ count=10
20 20 $ commit()
21 21 > {
22 22 > GIT_AUTHOR_DATE="2007-01-01 00:00:$count +0000"
23 23 > GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE"
24 24 > git commit "$@" >/dev/null 2>/dev/null || echo "git commit error"
25 25 > count=`expr $count + 1`
26 26 > }
27 27 $ mkdir git-repo
28 28 $ cd git-repo
29 29 $ git init-db >/dev/null 2>/dev/null
30 30 $ echo a > a
31 31 $ mkdir d
32 32 $ echo b > d/b
33 33 $ git add a d
34 34 $ commit -a -m t1
35 35
36 36 Remove the directory, then try to replace it with a file (issue754)
37 37
38 38 $ git rm -f d/b
39 39 rm 'd/b'
40 40 $ commit -m t2
41 41 $ echo d > d
42 42 $ git add d
43 43 $ commit -m t3
44 44 $ echo b >> a
45 45 $ commit -a -m t4.1
46 46 $ git checkout -b other HEAD~ >/dev/null 2>/dev/null
47 47 $ echo c > a
48 48 $ echo a >> a
49 49 $ commit -a -m t4.2
50 50 $ git checkout master >/dev/null 2>/dev/null
51 51 $ git pull --no-commit . other > /dev/null 2>/dev/null
52 52 $ commit -m 'Merge branch other'
53 53 $ cd ..
54 $ hg convert --datesort git-repo
54 $ hg convert --config extensions.progress= --config progress.assume-tty=1 \
55 > --config progress.delay=0 --config progress.changedelay=0 \
56 > --config progress.refresh=0 --config progress.width=60 \
57 > --datesort git-repo
58 \r (no-eol) (esc)
59 scanning [ <=> ] 1\r (no-eol) (esc)
60 scanning [ <=> ] 2\r (no-eol) (esc)
61 scanning [ <=> ] 3\r (no-eol) (esc)
62 scanning [ <=> ] 4\r (no-eol) (esc)
63 scanning [ <=> ] 5\r (no-eol) (esc)
64 scanning [ <=> ] 6\r (no-eol) (esc)
65 \r (no-eol) (esc)
66 \r (no-eol) (esc)
67 converting [ ] 0/6\r (no-eol) (esc)
68 getting files [==================> ] 1/2\r (no-eol) (esc)
69 getting files [======================================>] 2/2\r (no-eol) (esc)
70 \r (no-eol) (esc)
71 \r (no-eol) (esc)
72 converting [======> ] 1/6\r (no-eol) (esc)
73 getting files [======================================>] 1/1\r (no-eol) (esc)
74 \r (no-eol) (esc)
75 \r (no-eol) (esc)
76 converting [=============> ] 2/6\r (no-eol) (esc)
77 getting files [======================================>] 1/1\r (no-eol) (esc)
78 \r (no-eol) (esc)
79 \r (no-eol) (esc)
80 converting [====================> ] 3/6\r (no-eol) (esc)
81 getting files [======================================>] 1/1\r (no-eol) (esc)
82 \r (no-eol) (esc)
83 \r (no-eol) (esc)
84 converting [===========================> ] 4/6\r (no-eol) (esc)
85 getting files [======================================>] 1/1\r (no-eol) (esc)
86 \r (no-eol) (esc)
87 \r (no-eol) (esc)
88 converting [==================================> ] 5/6\r (no-eol) (esc)
89 getting files [======================================>] 1/1\r (no-eol) (esc)
90 \r (no-eol) (esc)
55 91 assuming destination git-repo-hg
56 92 initializing destination git-repo-hg repository
57 93 scanning source...
58 94 sorting...
59 95 converting...
60 96 5 t1
61 97 4 t2
62 98 3 t3
63 99 2 t4.1
64 100 1 t4.2
65 101 0 Merge branch other
66 102 updating bookmarks
67 103 $ hg up -q -R git-repo-hg
68 104 $ hg -R git-repo-hg tip -v
69 105 changeset: 5:c78094926be2
70 106 bookmark: master
71 107 tag: tip
72 108 parent: 3:f5f5cb45432b
73 109 parent: 4:4e174f80c67c
74 110 user: test <test@example.org>
75 111 date: Mon Jan 01 00:00:15 2007 +0000
76 112 files: a
77 113 description:
78 114 Merge branch other
79 115
80 116
81 117 $ count=10
82 118 $ mkdir git-repo2
83 119 $ cd git-repo2
84 120 $ git init-db >/dev/null 2>/dev/null
85 121 $ echo foo > foo
86 122 $ git add foo
87 123 $ commit -a -m 'add foo'
88 124 $ echo >> foo
89 125 $ commit -a -m 'change foo'
90 126 $ git checkout -b Bar HEAD~ >/dev/null 2>/dev/null
91 127 $ echo quux >> quux
92 128 $ git add quux
93 129 $ commit -a -m 'add quux'
94 130 $ echo bar > bar
95 131 $ git add bar
96 132 $ commit -a -m 'add bar'
97 133 $ git checkout -b Baz HEAD~ >/dev/null 2>/dev/null
98 134 $ echo baz > baz
99 135 $ git add baz
100 136 $ commit -a -m 'add baz'
101 137 $ git checkout master >/dev/null 2>/dev/null
102 138 $ git pull --no-commit . Bar Baz > /dev/null 2>/dev/null
103 139 $ commit -m 'Octopus merge'
104 140 $ echo bar >> bar
105 141 $ commit -a -m 'change bar'
106 142 $ git checkout -b Foo HEAD~ >/dev/null 2>/dev/null
107 143 $ echo >> foo
108 144 $ commit -a -m 'change foo'
109 145 $ git checkout master >/dev/null 2>/dev/null
110 146 $ git pull --no-commit -s ours . Foo > /dev/null 2>/dev/null
111 147 $ commit -m 'Discard change to foo'
112 148 $ cd ..
113 149 $ glog()
114 150 > {
115 151 > hg log -G --template '{rev} "{desc|firstline}" files: {files}\n' "$@"
116 152 > }
117 153 $ splitrepo()
118 154 > {
119 155 > msg="$1"
120 156 > files="$2"
121 157 > opts=$3
122 158 > echo "% $files: $msg"
123 159 > prefix=`echo "$files" | sed -e 's/ /-/g'`
124 160 > fmap="$prefix.fmap"
125 161 > repo="$prefix.repo"
126 162 > for i in $files; do
127 163 > echo "include $i" >> "$fmap"
128 164 > done
129 165 > hg -q convert $opts --filemap "$fmap" --datesort git-repo2 "$repo"
130 166 > hg up -q -R "$repo"
131 167 > glog -R "$repo"
132 168 > hg -R "$repo" manifest --debug
133 169 > }
134 170
135 171 full conversion
136 172
137 173 $ hg -q convert --datesort git-repo2 fullrepo
138 174 $ hg up -q -R fullrepo
139 175 $ glog -R fullrepo
140 176 @ 9 "Discard change to foo" files: foo
141 177 |\
142 178 | o 8 "change foo" files: foo
143 179 | |
144 180 o | 7 "change bar" files: bar
145 181 |/
146 182 o 6 "(octopus merge fixup)" files:
147 183 |\
148 184 | o 5 "Octopus merge" files: baz
149 185 | |\
150 186 o | | 4 "add baz" files: baz
151 187 | | |
152 188 +---o 3 "add bar" files: bar
153 189 | |
154 190 o | 2 "add quux" files: quux
155 191 | |
156 192 | o 1 "change foo" files: foo
157 193 |/
158 194 o 0 "add foo" files: foo
159 195
160 196 $ hg -R fullrepo manifest --debug
161 197 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
162 198 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
163 199 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
164 200 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
165 201 $ splitrepo 'octopus merge' 'foo bar baz'
166 202 % foo bar baz: octopus merge
167 203 @ 8 "Discard change to foo" files: foo
168 204 |\
169 205 | o 7 "change foo" files: foo
170 206 | |
171 207 o | 6 "change bar" files: bar
172 208 |/
173 209 o 5 "(octopus merge fixup)" files:
174 210 |\
175 211 | o 4 "Octopus merge" files: baz
176 212 | |\
177 213 o | | 3 "add baz" files: baz
178 214 | | |
179 215 +---o 2 "add bar" files: bar
180 216 | |
181 217 | o 1 "change foo" files: foo
182 218 |/
183 219 o 0 "add foo" files: foo
184 220
185 221 245a3b8bc653999c2b22cdabd517ccb47aecafdf 644 bar
186 222 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
187 223 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
188 224 $ splitrepo 'only some parents of an octopus merge; "discard" a head' 'foo baz quux'
189 225 % foo baz quux: only some parents of an octopus merge; "discard" a head
190 226 @ 6 "Discard change to foo" files: foo
191 227 |
192 228 o 5 "change foo" files: foo
193 229 |
194 230 o 4 "Octopus merge" files:
195 231 |\
196 232 | o 3 "add baz" files: baz
197 233 | |
198 234 | o 2 "add quux" files: quux
199 235 | |
200 236 o | 1 "change foo" files: foo
201 237 |/
202 238 o 0 "add foo" files: foo
203 239
204 240 354ae8da6e890359ef49ade27b68bbc361f3ca88 644 baz
205 241 9277c9cc8dd4576fc01a17939b4351e5ada93466 644 foo
206 242 88dfeab657e8cf2cef3dec67b914f49791ae76b1 644 quux
207 243
208 244 test binary conversion (issue1359)
209 245
210 246 $ mkdir git-repo3
211 247 $ cd git-repo3
212 248 $ git init-db >/dev/null 2>/dev/null
213 249 $ python -c 'file("b", "wb").write("".join([chr(i) for i in range(256)])*16)'
214 250 $ git add b
215 251 $ commit -a -m addbinary
216 252 $ cd ..
217 253
218 254 convert binary file
219 255
220 256 $ hg convert git-repo3 git-repo3-hg
221 257 initializing destination git-repo3-hg repository
222 258 scanning source...
223 259 sorting...
224 260 converting...
225 261 0 addbinary
226 262 updating bookmarks
227 263 $ cd git-repo3-hg
228 264 $ hg up -C
229 265 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
230 266 $ python -c 'print len(file("b", "rb").read())'
231 267 4096
232 268 $ cd ..
233 269
234 270 test author vs committer
235 271
236 272 $ mkdir git-repo4
237 273 $ cd git-repo4
238 274 $ git init-db >/dev/null 2>/dev/null
239 275 $ echo >> foo
240 276 $ git add foo
241 277 $ commit -a -m addfoo
242 278 $ echo >> foo
243 279 $ GIT_AUTHOR_NAME="nottest"
244 280 $ commit -a -m addfoo2
245 281 $ cd ..
246 282
247 283 convert author committer
248 284
249 285 $ hg convert git-repo4 git-repo4-hg
250 286 initializing destination git-repo4-hg repository
251 287 scanning source...
252 288 sorting...
253 289 converting...
254 290 1 addfoo
255 291 0 addfoo2
256 292 updating bookmarks
257 293 $ hg -R git-repo4-hg log -v
258 294 changeset: 1:d63e967f93da
259 295 bookmark: master
260 296 tag: tip
261 297 user: nottest <test@example.org>
262 298 date: Mon Jan 01 00:00:21 2007 +0000
263 299 files: foo
264 300 description:
265 301 addfoo2
266 302
267 303 committer: test <test@example.org>
268 304
269 305
270 306 changeset: 0:0735477b0224
271 307 user: test <test@example.org>
272 308 date: Mon Jan 01 00:00:20 2007 +0000
273 309 files: foo
274 310 description:
275 311 addfoo
276 312
277 313
278 314
279 315 --sourceorder should fail
280 316
281 317 $ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
282 318 initializing destination git-repo4-sourcesort-hg repository
283 319 abort: --sourcesort is not supported by this data source
284 320 [255]
285 321
286 322 test sub modules
287 323
288 324 $ mkdir git-repo5
289 325 $ cd git-repo5
290 326 $ git init-db >/dev/null 2>/dev/null
291 327 $ echo 'sub' >> foo
292 328 $ git add foo
293 329 $ commit -a -m 'addfoo'
294 330 $ BASE=`pwd`
295 331 $ cd ..
296 332 $ mkdir git-repo6
297 333 $ cd git-repo6
298 334 $ git init-db >/dev/null 2>/dev/null
299 335 $ git submodule add ${BASE} >/dev/null 2>/dev/null
300 336 $ commit -a -m 'addsubmodule' >/dev/null 2>/dev/null
301 337 $ cd ..
302 338
303 339 test invalid splicemap1
304 340
305 341 $ cat > splicemap <<EOF
306 342 > $VALIDID1
307 343 > EOF
308 344 $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap1-hg
309 345 initializing destination git-repo2-splicemap1-hg repository
310 346 abort: syntax error in splicemap(1): child parent1[,parent2] expected
311 347 [255]
312 348
313 349 test invalid splicemap2
314 350
315 351 $ cat > splicemap <<EOF
316 352 > $VALIDID1 $VALIDID2, $VALIDID2, $VALIDID2
317 353 > EOF
318 354 $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap2-hg
319 355 initializing destination git-repo2-splicemap2-hg repository
320 356 abort: syntax error in splicemap(1): child parent1[,parent2] expected
321 357 [255]
322 358
323 359 test invalid splicemap3
324 360
325 361 $ cat > splicemap <<EOF
326 362 > $INVALIDID1 $INVALIDID2
327 363 > EOF
328 364 $ hg convert --splicemap splicemap git-repo2 git-repo2-splicemap3-hg
329 365 initializing destination git-repo2-splicemap3-hg repository
330 366 abort: splicemap entry afd12345af is not a valid revision identifier
331 367 [255]
332 368
333 369 convert sub modules
334 370 $ hg convert git-repo6 git-repo6-hg
335 371 initializing destination git-repo6-hg repository
336 372 scanning source...
337 373 sorting...
338 374 converting...
339 375 0 addsubmodule
340 376 updating bookmarks
341 377 $ hg -R git-repo6-hg log -v
342 378 changeset: 0:* (glob)
343 379 bookmark: master
344 380 tag: tip
345 381 user: nottest <test@example.org>
346 382 date: Mon Jan 01 00:00:23 2007 +0000
347 383 files: .hgsub .hgsubstate
348 384 description:
349 385 addsubmodule
350 386
351 387 committer: test <test@example.org>
352 388
353 389
354 390
355 391 $ cd git-repo6-hg
356 392 $ hg up >/dev/null 2>/dev/null
357 393 $ cat .hgsubstate
358 394 * git-repo5 (glob)
359 395 $ cd git-repo5
360 396 $ cat foo
361 397 sub
362 398
363 399 $ cd ../..
364 400
365 401 convert the revision removing '.gitmodules' itself (and related
366 402 submodules)
367 403
368 404 $ cd git-repo6
369 405 $ git rm .gitmodules
370 406 rm '.gitmodules'
371 407 $ git rm --cached git-repo5
372 408 rm 'git-repo5'
373 409 $ commit -a -m 'remove .gitmodules and submodule git-repo5'
374 410 $ cd ..
375 411
376 412 $ hg convert -q git-repo6 git-repo6-hg
377 413 $ hg -R git-repo6-hg tip -T "{desc|firstline}\n"
378 414 remove .gitmodules and submodule git-repo5
379 415 $ hg -R git-repo6-hg tip -T "{file_dels}\n"
380 416 .hgsub .hgsubstate
381 417
382 418 damaged git repository tests:
383 419 In case the hard-coded hashes change, the following commands can be used to
384 420 list the hashes and their corresponding types in the repository:
385 421 cd git-repo4/.git/objects
386 422 find . -type f | cut -c 3- | sed 's_/__' | xargs -n 1 -t git cat-file -t
387 423 cd ../../..
388 424
389 425 damage git repository by renaming a commit object
390 426 $ COMMIT_OBJ=1c/0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd
391 427 $ mv git-repo4/.git/objects/$COMMIT_OBJ git-repo4/.git/objects/$COMMIT_OBJ.tmp
392 428 $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:'
393 429 abort: cannot read tags from git-repo4/.git
394 430 $ mv git-repo4/.git/objects/$COMMIT_OBJ.tmp git-repo4/.git/objects/$COMMIT_OBJ
395 431 damage git repository by renaming a blob object
396 432
397 433 $ BLOB_OBJ=8b/137891791fe96927ad78e64b0aad7bded08bdc
398 434 $ mv git-repo4/.git/objects/$BLOB_OBJ git-repo4/.git/objects/$BLOB_OBJ.tmp
399 435 $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:'
400 436 abort: cannot read 'blob' object at 8b137891791fe96927ad78e64b0aad7bded08bdc
401 437 $ mv git-repo4/.git/objects/$BLOB_OBJ.tmp git-repo4/.git/objects/$BLOB_OBJ
402 438 damage git repository by renaming a tree object
403 439
404 440 $ TREE_OBJ=72/49f083d2a63a41cc737764a86981eb5f3e4635
405 441 $ mv git-repo4/.git/objects/$TREE_OBJ git-repo4/.git/objects/$TREE_OBJ.tmp
406 442 $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:'
407 443 abort: cannot read changes in 1c0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd
General Comments 0
You need to be logged in to leave comments. Login now