Debian Codegraph @

tests/test-convert-hg-sink.t

raw
1
2 $ cat >> $HGRCPATH <<EOF
3 > [extensions]
4 > convert=
5 > [convert]
6 > hg.saverev=False
7 > EOF
8 $ hg init orig
9 $ cd orig
10 $ echo foo > foo
11 $ echo bar > bar
12 $ hg ci -qAm 'add foo and bar'
13 $ hg rm foo
14 $ hg ci -m 'remove foo'
15 $ mkdir foo
16 $ echo file > foo/file
17 $ hg ci -qAm 'add foo/file'
18 $ hg tag some-tag
19 $ hg tag -l local-tag
20 $ echo '1234567890123456789012345678901234567890 missing_tag' >> .hgtags
21 $ hg ci -m 'add a missing tag'
22 $ hg log
23 changeset: 4:3fb95ee23a66
24 tag: tip
25 user: test
26 date: Thu Jan 01 00:00:00 1970 +0000
27 summary: add a missing tag
28
29 changeset: 3:593cbf6fb2b4
30 tag: local-tag
31 user: test
32 date: Thu Jan 01 00:00:00 1970 +0000
33 summary: Added tag some-tag for changeset ad681a868e44
34
35 changeset: 2:ad681a868e44
36 tag: some-tag
37 user: test
38 date: Thu Jan 01 00:00:00 1970 +0000
39 summary: add foo/file
40
41 changeset: 1:cbba8ecc03b7
42 user: test
43 date: Thu Jan 01 00:00:00 1970 +0000
44 summary: remove foo
45
46 changeset: 0:327daa9251fa
47 user: test
48 date: Thu Jan 01 00:00:00 1970 +0000
49 summary: add foo and bar
50
51 $ hg phase --public -r tip
52 $ cd ..
53 $ hg convert orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
54 initializing destination new repository
55 scanning source...
56 sorting...
57 converting...
58 4 add foo and bar
59 3 remove foo
60 2 add foo/file
61 1 Added tag some-tag for changeset ad681a868e44
62 0 add a missing tag
63 missing tag entry: "1234567890123456789012345678901234567890 missing_tag"
64 $ cd new
65 $ hg log -G --template '{rev} {node|short} ({phase}) "{desc}"\n'
66 o 4 3fb95ee23a66 (public) "add a missing tag"
67 |
68 o 3 593cbf6fb2b4 (public) "Added tag some-tag for changeset ad681a868e44"
69 |
70 o 2 ad681a868e44 (public) "add foo/file"
71 |
72 o 1 cbba8ecc03b7 (public) "remove foo"
73 |
74 o 0 327daa9251fa (public) "add foo and bar"
75
76
77 $ hg out ../orig
78 comparing with ../orig
79 searching for changes
80 no changes found
81 [1]
82
83 dirstate should be empty:
84
85 $ hg debugstate
86 $ hg parents -q
87 $ hg up -C
88 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
89 $ hg copy bar baz
90
91 put something in the dirstate:
92
93 $ hg debugstate > debugstate
94 $ grep baz debugstate
95 a 0 -1 unset baz
96 copy: bar -> baz
97
98 add a new revision in the original repo
99
100 $ cd ../orig
101 $ echo baz > baz
102 $ hg ci -qAm 'add baz'
103 $ cd ..
104 $ hg convert orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
105 scanning source...
106 sorting...
107 converting...
108 0 add baz
109 $ cd new
110 $ hg out ../orig
111 comparing with ../orig
112 searching for changes
113 no changes found
114 [1]
115
116 dirstate should be the same (no output below):
117
118 $ hg debugstate > new-debugstate
119 $ diff debugstate new-debugstate
120
121 no copies
122
123 $ hg up -C
124 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
125 $ hg debugrename baz
126 baz not renamed
127 $ cd ..
128
129 test tag rewriting
130
131 $ cat > filemap <<EOF
132 > exclude foo
133 > EOF
134 $ hg convert --filemap filemap orig new-filemap 2>&1 | grep -v 'subversion python bindings could not be loaded'
135 initializing destination new-filemap repository
136 scanning source...
137 sorting...
138 converting...
139 5 add foo and bar
140 4 remove foo
141 3 add foo/file
142 2 Added tag some-tag for changeset ad681a868e44
143 1 add a missing tag
144 missing tag entry: "1234567890123456789012345678901234567890 missing_tag"
145 0 add baz
146 $ cd new-filemap
147 $ hg tags
148 tip 3:7bb553f2c68a
149 some-tag 0:ba8636729451
150 $ cd ..
151
152
153 Test cases for hg-hg roundtrip
154
155 Helper
156
157 $ glog()
158 > {
159 > hg log -G --template '{rev} {node|short} ({phase}) "{desc}" files: {files}\n' $*
160 > }
161
162 Create a tricky source repo
163
164 $ hg init source
165 $ cd source
166
167 $ echo 0 > 0
168 $ hg ci -Aqm '0: add 0'
169 $ echo a > a
170 $ mkdir dir
171 $ echo b > dir/b
172 $ hg ci -qAm '1: add a and dir/b'
173 $ echo c > dir/c
174 $ hg ci -qAm '2: add dir/c'
175 $ hg copy a e
176 $ echo b >> b
177 $ hg ci -qAm '3: copy a to e, change b'
178 $ hg up -qr -3
179 $ echo a >> a
180 $ hg ci -qAm '4: change a'
181 $ hg merge
182 merging a and e to e
183 2 files updated, 1 files merged, 0 files removed, 0 files unresolved
184 (branch merge, don't forget to commit)
185 $ hg copy b dir/d
186 $ hg ci -qAm '5: merge 2 and 3, copy b to dir/d'
187 $ echo a >> a
188 $ hg ci -qAm '6: change a'
189
190 $ hg mani
191 0
192 a
193 b
194 dir/b
195 dir/c
196 dir/d
197 e
198 $ hg phase --public -r tip
199 $ glog
200 @ 6 0613c8e59a3d (public) "6: change a" files: a
201 |
202 o 5 717e9b37cdb7 (public) "5: merge 2 and 3, copy b to dir/d" files: dir/d e
203 |\
204 | o 4 86a55cb968d5 (public) "4: change a" files: a
205 | |
206 o | 3 0e6e235919dd (public) "3: copy a to e, change b" files: b e
207 | |
208 o | 2 0394b0d5e4f7 (public) "2: add dir/c" files: dir/c
209 |/
210 o 1 333546584845 (public) "1: add a and dir/b" files: a dir/b
211 |
212 o 0 d1a24e2ebd23 (public) "0: add 0" files: 0
213
214 $ cd ..
215
216 Convert excluding rev 0 and dir/ (and thus rev2):
217
218 $ cat << EOF > filemap
219 > exclude dir
220 > EOF
221
222 $ hg convert --filemap filemap source dest --config convert.hg.revs=1::
223 initializing destination dest repository
224 scanning source...
225 sorting...
226 converting...
227 5 1: add a and dir/b
228 4 2: add dir/c
229 3 3: copy a to e, change b
230 2 4: change a
231 1 5: merge 2 and 3, copy b to dir/d
232 0 6: change a
233
234 Verify that conversion skipped rev 2:
235
236 $ glog -R dest
237 o 4 78814e84a217 (draft) "6: change a" files: a
238 |
239 o 3 f7cff662c5e5 (draft) "5: merge 2 and 3, copy b to dir/d" files: e
240 |\
241 | o 2 ab40a95b0072 (draft) "4: change a" files: a
242 | |
243 o | 1 bd51f17597bf (draft) "3: copy a to e, change b" files: b e
244 |/
245 o 0 a4a1dae0fe35 (draft) "1: add a and dir/b" files: 0 a
246
247
248 Verify mapping correct in both directions:
249
250 $ cat source/.hg/shamap
251 a4a1dae0fe3514cefd9b8541b7abbc8f44f946d5 333546584845f70c4cfecb992341aaef0e708166
252 bd51f17597bf32268e68a560b206898c3960cda2 0e6e235919dd8e9285ba8eb5adf703af9ad99378
253 ab40a95b00725307e79c2fd271000aa8af9759f4 86a55cb968d51770cba2a1630d6cc637b574580a
254 f7cff662c5e581e6f3f1a85ffdd2bcb35825f6ba 717e9b37cdb7eb9917ca8e30aa3f986e6d5b177d
255 78814e84a217894517c2de392b903ed05e6871a4 0613c8e59a3ddb9789072ef52f1ed13496489bb4
256 $ cat dest/.hg/shamap
257 333546584845f70c4cfecb992341aaef0e708166 a4a1dae0fe3514cefd9b8541b7abbc8f44f946d5
258 0394b0d5e4f761ced559fd0bbdc6afc16cb3f7d1 a4a1dae0fe3514cefd9b8541b7abbc8f44f946d5
259 0e6e235919dd8e9285ba8eb5adf703af9ad99378 bd51f17597bf32268e68a560b206898c3960cda2
260 86a55cb968d51770cba2a1630d6cc637b574580a ab40a95b00725307e79c2fd271000aa8af9759f4
261 717e9b37cdb7eb9917ca8e30aa3f986e6d5b177d f7cff662c5e581e6f3f1a85ffdd2bcb35825f6ba
262 0613c8e59a3ddb9789072ef52f1ed13496489bb4 78814e84a217894517c2de392b903ed05e6871a4
263
264 Verify meta data converted correctly:
265
266 $ hg -R dest log -r 1 --debug -p --git
267 changeset: 1:bd51f17597bf32268e68a560b206898c3960cda2
268 phase: draft
269 parent: 0:a4a1dae0fe3514cefd9b8541b7abbc8f44f946d5
270 parent: -1:0000000000000000000000000000000000000000
271 manifest: 1:040c72ed9b101773c24ac314776bfc846943781f
272 user: test
273 date: Thu Jan 01 00:00:00 1970 +0000
274 files+: b e
275 extra: branch=default
276 description:
277 3: copy a to e, change b
278
279
280 diff --git a/b b/b
281 new file mode 100644
282 --- /dev/null
283 +++ b/b
284 @@ -0,0 +1,1 @@
285 +b
286 diff --git a/a b/e
287 copy from a
288 copy to e
289
290 Verify files included and excluded correctly:
291
292 $ hg -R dest manifest -r tip
293 0
294 a
295 b
296 e
297
298
299 Make changes in dest and convert back:
300
301 $ hg -R dest up -q
302 $ echo dest > dest/dest
303 $ hg -R dest ci -Aqm 'change in dest'
304 $ hg -R dest tip
305 changeset: 5:a2e0e3cc6d1d
306 tag: tip
307 user: test
308 date: Thu Jan 01 00:00:00 1970 +0000
309 summary: change in dest
310
311
312 (converting merges back after using a filemap will probably cause chaos so we
313 exclude merges.)
314
315 $ hg convert dest source --config convert.hg.revs='!merge()'
316 scanning source...
317 sorting...
318 converting...
319 0 change in dest
320
321 Verify the conversion back:
322
323 $ hg -R source log --debug -r tip
324 changeset: 7:e6d364a69ff1248b2099e603b0c145504cade6f0
325 tag: tip
326 phase: draft
327 parent: 6:0613c8e59a3ddb9789072ef52f1ed13496489bb4
328 parent: -1:0000000000000000000000000000000000000000
329 manifest: 7:aa3e9542f3b76d4f1f1b2e9c7ce9dbb48b6a95ec
330 user: test
331 date: Thu Jan 01 00:00:00 1970 +0000
332 files+: dest
333 extra: branch=default
334 description:
335 change in dest
336
337
338 Files that had been excluded are still present:
339
340 $ hg -R source manifest -r tip
341 0
342 a
343 b
344 dest
345 dir/b
346 dir/c
347 dir/d
348 e
349
350 More source changes
351
352 $ cd source
353 $ echo 1 >> a
354 $ hg ci -m '8: source first branch'
355 created new head
356 $ hg up -qr -2
357 $ echo 2 >> a
358 $ hg ci -m '9: source second branch'
359 $ hg merge -q --tool internal:local
360 $ hg ci -m '10: source merge'
361 $ echo >> a
362 $ hg ci -m '11: source change'
363
364 $ hg mani
365 0
366 a
367 b
368 dest
369 dir/b
370 dir/c
371 dir/d
372 e
373
374 $ glog -r 6:
375 @ 11 0c8927d1f7f4 (draft) "11: source change" files: a
376 |
377 o 10 9ccb7ee8d261 (draft) "10: source merge" files: a
378 |\
379 | o 9 f131b1518dba (draft) "9: source second branch" files: a
380 | |
381 o | 8 669cf0e74b50 (draft) "8: source first branch" files: a
382 | |
383 | o 7 e6d364a69ff1 (draft) "change in dest" files: dest
384 |/
385 o 6 0613c8e59a3d (public) "6: change a" files: a
386 |
387 ~
388 $ cd ..
389
390 $ hg convert --filemap filemap source dest --config convert.hg.revs=3:
391 scanning source...
392 sorting...
393 converting...
394 3 8: source first branch
395 2 9: source second branch
396 1 10: source merge
397 0 11: source change
398
399 $ glog -R dest
400 o 9 8432d597b263 (draft) "11: source change" files: a
401 |
402 o 8 632ffacdcd6f (draft) "10: source merge" files: a
403 |\
404 | o 7 049cfee90ee6 (draft) "9: source second branch" files: a
405 | |
406 o | 6 9b6845e036e5 (draft) "8: source first branch" files: a
407 | |
408 | @ 5 a2e0e3cc6d1d (draft) "change in dest" files: dest
409 |/
410 o 4 78814e84a217 (draft) "6: change a" files: a
411 |
412 o 3 f7cff662c5e5 (draft) "5: merge 2 and 3, copy b to dir/d" files: e
413 |\
414 | o 2 ab40a95b0072 (draft) "4: change a" files: a
415 | |
416 o | 1 bd51f17597bf (draft) "3: copy a to e, change b" files: b e
417 |/
418 o 0 a4a1dae0fe35 (draft) "1: add a and dir/b" files: 0 a
419
420 $ cd ..
421
422 Two way tests
423
424 $ hg init 0
425 $ echo f > 0/f
426 $ echo a > 0/a-only
427 $ echo b > 0/b-only
428 $ hg -R 0 ci -Aqm0
429
430 $ cat << EOF > filemap-a
431 > exclude b-only
432 > EOF
433 $ cat << EOF > filemap-b
434 > exclude a-only
435 > EOF
436 $ hg convert --filemap filemap-a 0 a
437 initializing destination a repository
438 scanning source...
439 sorting...
440 converting...
441 0 0
442 $ hg -R a up -q
443 $ echo a > a/f
444 $ hg -R a ci -ma
445
446 $ hg convert --filemap filemap-b 0 b
447 initializing destination b repository
448 scanning source...
449 sorting...
450 converting...
451 0 0
452 $ hg -R b up -q
453 $ echo b > b/f
454 $ hg -R b ci -mb
455
456 $ tail 0/.hg/shamap
457 86f3f774ffb682bffb5dc3c1d3b3da637cb9a0d6 8a028c7c77f6c7bd6d63bc3f02ca9f779eabf16a
458 dd9f218eb91fb857f2a62fe023e1d64a4e7812fe 8a028c7c77f6c7bd6d63bc3f02ca9f779eabf16a
459 $ tail a/.hg/shamap
460 8a028c7c77f6c7bd6d63bc3f02ca9f779eabf16a 86f3f774ffb682bffb5dc3c1d3b3da637cb9a0d6
461 $ tail b/.hg/shamap
462 8a028c7c77f6c7bd6d63bc3f02ca9f779eabf16a dd9f218eb91fb857f2a62fe023e1d64a4e7812fe
463
464 $ hg convert a 0
465 scanning source...
466 sorting...
467 converting...
468 0 a
469
470 $ hg convert b 0
471 scanning source...
472 sorting...
473 converting...
474 0 b
475
476 $ hg -R 0 log -G
477 o changeset: 2:637fbbbe96b6
478 | tag: tip
479 | parent: 0:8a028c7c77f6
480 | user: test
481 | date: Thu Jan 01 00:00:00 1970 +0000
482 | summary: b
483 |
484 | o changeset: 1:ec7b9c96e692
485 |/ user: test
486 | date: Thu Jan 01 00:00:00 1970 +0000
487 | summary: a
488 |
489 @ changeset: 0:8a028c7c77f6
490 user: test
491 date: Thu Jan 01 00:00:00 1970 +0000
492 summary: 0
493
494 $ hg convert --filemap filemap-b 0 a --config convert.hg.revs=1::
495 scanning source...
496 sorting...
497 converting...
498
499 $ hg -R 0 up -r1
500 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
501 $ echo f >> 0/f
502 $ hg -R 0 ci -mx
503
504 $ hg convert --filemap filemap-b 0 a --config convert.hg.revs=1::
505 scanning source...
506 sorting...
507 converting...
508 0 x
509
510 $ hg -R a log -G -T '{rev} {desc|firstline} ({files})\n'
511 o 2 x (f)
512 |
513 @ 1 a (f)
514 |
515 o 0 0 (a-only f)
516
517 $ hg -R a mani -r tip
518 a-only
519 f
520
521 An additional round, demonstrating that unchanged files don't get converted
522
523 $ echo f >> 0/f
524 $ echo f >> 0/a-only
525 $ hg -R 0 ci -m "extra f+a-only change"
526
527 $ hg convert --filemap filemap-b 0 a --config convert.hg.revs=1::
528 scanning source...
529 sorting...
530 converting...
531 0 extra f+a-only change
532
533 $ hg -R a log -G -T '{rev} {desc|firstline} ({files})\n'
534 o 3 extra f+a-only change (f)
535 |
536 o 2 x (f)
537 |
538 @ 1 a (f)
539 |
540 o 0 0 (a-only f)
541
542
543 Conversion after rollback
544
545 $ hg -R a rollback -f
546 repository tip rolled back to revision 2 (undo convert)
547
548 $ hg convert --filemap filemap-b 0 a --config convert.hg.revs=1::
549 scanning source...
550 sorting...
551 converting...
552 0 extra f+a-only change
553
554 $ hg -R a log -G -T '{rev} {desc|firstline} ({files})\n'
555 o 3 extra f+a-only change (f)
556 |
557 o 2 x (f)
558 |
559 @ 1 a (f)
560 |
561 o 0 0 (a-only f)
562
563 Convert with --full adds and removes files that didn't change
564
565 $ echo f >> 0/f
566 $ hg -R 0 ci -m "f"
567 $ hg convert --filemap filemap-b --full 0 a --config convert.hg.revs=1::
568 scanning source...
569 sorting...
570 converting...
571 0 f
572 $ hg -R a status --change tip
573 M f
574 A b-only
575 R a-only
576
577 Recorded {files} list does not get confused about flags on merge commits
578
579 #if execbit
580 $ cd ..
581 $ hg init merge-flags-orig
582 $ cd merge-flags-orig
583 $ echo 0 > 0
584 $ hg ci -Aqm 'add 0'
585 $ echo a > a
586 $ chmod +x a
587 $ hg ci -qAm 'add executable file'
588 $ hg co -q 0
589 $ echo b > b
590 $ hg ci -qAm 'add file'
591 $ hg merge -q
592 $ hg ci -m 'merge'
593 $ hg log -G -T '{rev} {desc}\n'
594 @ 3 merge
595 |\
596 | o 2 add file
597 | |
598 o | 1 add executable file
599 |/
600 o 0 add 0
601
602
603 # No files changed
604 $ hg log -r 3 -T '{files}\n'
605
606
607 $ cd ..
608 $ hg convert merge-flags-orig merge-flags-new -q
609 $ cd merge-flags-new
610 $ hg log -G -T '{rev} {desc}\n'
611 o 3 merge
612 |\
613 | o 2 add file
614 | |
615 o | 1 add executable file
616 |/
617 o 0 add 0
618
619
620 # Still no files
621 $ hg log -r 3 -T '{files}\n'
622
623
624 #endif