Debian Codegraph @

tests/test-convert-cvs.t

raw
1 #require cvs no-root
2
3 $ cvscall()
4 > {
5 > cvs -f "$@"
6 > }
7 $ hgcat()
8 > {
9 > hg --cwd src-hg cat -r tip "$1"
10 > }
11 $ echo "[extensions]" >> $HGRCPATH
12 $ echo "convert = " >> $HGRCPATH
13 $ cat > cvshooks.py <<EOF
14 > def cvslog(ui, repo, hooktype, log):
15 > ui.write(b'%s hook: %d entries\n' % (hooktype, len(log)))
16 >
17 > def cvschangesets(ui, repo, hooktype, changesets):
18 > ui.write(b'%s hook: %d changesets\n' % (hooktype, len(changesets)))
19 > EOF
20 $ hookpath=`pwd`
21 $ cat <<EOF >> $HGRCPATH
22 > [hooks]
23 > cvslog = python:$hookpath/cvshooks.py:cvslog
24 > cvschangesets = python:$hookpath/cvshooks.py:cvschangesets
25 > EOF
26
27 create cvs repository
28
29 $ mkdir cvsrepo
30 $ cd cvsrepo
31 $ CVSROOT=`pwd`
32 $ export CVSROOT
33 $ CVS_OPTIONS=-f
34 $ export CVS_OPTIONS
35 $ cd ..
36 $ rmdir cvsrepo
37 $ cvscall -q -d "$CVSROOT" init
38
39 create source directory
40
41 $ mkdir src-temp
42 $ cd src-temp
43 $ echo a > a
44 $ mkdir b
45 $ cd b
46 $ echo c > c
47 $ cd ..
48
49 import source directory
50
51 $ cvscall -q import -m import src INITIAL start
52 N src/a
53 N src/b/c
54
55 No conflicts created by this import
56
57 $ cd ..
58
59 checkout source directory
60
61 $ cvscall -q checkout src
62 U src/a
63 U src/b/c
64
65 commit a new revision changing b/c
66
67 $ cd src
68 $ sleep 1
69 $ echo c >> b/c
70 $ cvscall -q commit -mci0 . | grep '<--'
71 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
72 $ cd ..
73
74 convert fresh repo and also check localtimezone option
75
76 NOTE: This doesn't check all time zones -- it merely determines that
77 the configuration option is taking effect.
78
79 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
80 since it does not use DST (unlike other U.S. time zones) and is always
81 a fixed difference from UTC.
82
83 This choice is limited to work on Linux environments. At least on
84 FreeBSD 11 this timezone is not known. A better choice is
85 TZ=Pacific/Johnston. On Linux "US/Hawaii" is just a symlink to this
86 name and also it is known on FreeBSD and on Solaris.
87
88 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
89 initializing destination src-hg repository
90 connecting to $TESTTMP/cvsrepo
91 scanning source...
92 collecting CVS rlog
93 5 log entries
94 cvslog hook: 5 entries
95 creating changesets
96 3 changeset entries
97 cvschangesets hook: 3 changesets
98 sorting...
99 converting...
100 2 Initial revision
101 1 ci0
102 0 import
103 updating tags
104 $ hgcat a
105 a
106 $ hgcat b/c
107 c
108 c
109
110 convert fresh repo with --filemap
111
112 $ echo include b/c > filemap
113 $ hg convert --filemap filemap src src-filemap
114 initializing destination src-filemap repository
115 connecting to $TESTTMP/cvsrepo
116 scanning source...
117 collecting CVS rlog
118 5 log entries
119 cvslog hook: 5 entries
120 creating changesets
121 3 changeset entries
122 cvschangesets hook: 3 changesets
123 sorting...
124 converting...
125 2 Initial revision
126 1 ci0
127 0 import
128 filtering out empty revision
129 repository tip rolled back to revision 1 (undo convert)
130 updating tags
131 $ hgcat b/c
132 c
133 c
134 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
135 2 update tags files: .hgtags
136 1 ci0 files: b/c
137 0 Initial revision files: b/c
138
139 convert full repository (issue1649)
140
141 $ cvscall -q -d "$CVSROOT" checkout -d srcfull "." | grep -v CVSROOT
142 U srcfull/src/a
143 U srcfull/src/b/c
144 $ ls srcfull
145 CVS
146 CVSROOT
147 src
148 $ hg convert srcfull srcfull-hg \
149 > | grep -v 'log entries' | grep -v 'hook:' \
150 > | grep -v '^[0-3] .*' # filter instable changeset order
151 initializing destination srcfull-hg repository
152 connecting to $TESTTMP/cvsrepo
153 scanning source...
154 collecting CVS rlog
155 creating changesets
156 4 changeset entries
157 sorting...
158 converting...
159 updating tags
160 $ hg cat -r tip --cwd srcfull-hg src/a
161 a
162 $ hg cat -r tip --cwd srcfull-hg src/b/c
163 c
164 c
165
166 commit new file revisions
167
168 $ cd src
169 $ echo a >> a
170 $ echo c >> b/c
171 $ cvscall -q commit -mci1 . | grep '<--'
172 $TESTTMP/cvsrepo/src/a,v <-- a
173 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
174 $ cd ..
175
176 convert again
177
178 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
179 connecting to $TESTTMP/cvsrepo
180 scanning source...
181 collecting CVS rlog
182 7 log entries
183 cvslog hook: 7 entries
184 creating changesets
185 4 changeset entries
186 cvschangesets hook: 4 changesets
187 sorting...
188 converting...
189 0 ci1
190 $ hgcat a
191 a
192 a
193 $ hgcat b/c
194 c
195 c
196 c
197
198 convert again with --filemap
199
200 $ hg convert --filemap filemap src src-filemap
201 connecting to $TESTTMP/cvsrepo
202 scanning source...
203 collecting CVS rlog
204 7 log entries
205 cvslog hook: 7 entries
206 creating changesets
207 4 changeset entries
208 cvschangesets hook: 4 changesets
209 sorting...
210 converting...
211 0 ci1
212 $ hgcat b/c
213 c
214 c
215 c
216 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
217 3 ci1 files: b/c
218 2 update tags files: .hgtags
219 1 ci0 files: b/c
220 0 Initial revision files: b/c
221
222 commit branch
223
224 $ cd src
225 $ cvs -q update -r1.1 b/c
226 U b/c
227 $ cvs -q tag -b branch
228 T a
229 T b/c
230 $ cvs -q update -r branch > /dev/null
231 $ sleep 1
232 $ echo d >> b/c
233 $ cvs -q commit -mci2 . | grep '<--'
234 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
235 $ cd ..
236
237 convert again
238
239 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True src src-hg
240 connecting to $TESTTMP/cvsrepo
241 scanning source...
242 collecting CVS rlog
243 8 log entries
244 cvslog hook: 8 entries
245 creating changesets
246 5 changeset entries
247 cvschangesets hook: 5 changesets
248 sorting...
249 converting...
250 0 ci2
251 $ hgcat b/c
252 c
253 d
254
255 convert again with --filemap
256
257 $ TZ=Pacific/Johnston hg convert --config convert.localtimezone=True --filemap filemap src src-filemap
258 connecting to $TESTTMP/cvsrepo
259 scanning source...
260 collecting CVS rlog
261 8 log entries
262 cvslog hook: 8 entries
263 creating changesets
264 5 changeset entries
265 cvschangesets hook: 5 changesets
266 sorting...
267 converting...
268 0 ci2
269 $ hgcat b/c
270 c
271 d
272 $ hg -R src-filemap log --template '{rev} {desc} files: {files}\n'
273 4 ci2 files: b/c
274 3 ci1 files: b/c
275 2 update tags files: .hgtags
276 1 ci0 files: b/c
277 0 Initial revision files: b/c
278
279 commit a new revision with funny log message
280
281 $ cd src
282 $ sleep 1
283 $ echo e >> a
284 $ cvscall -q commit -m'funny
285 > ----------------------------
286 > log message' . | grep '<--' |\
287 > sed -e 's:.*src/\(.*\),v.*:checking in src/\1,v:g'
288 checking in src/a,v
289
290 commit new file revisions with some fuzz
291
292 $ sleep 1
293 $ echo f >> a
294 $ cvscall -q commit -mfuzzy . | grep '<--'
295 $TESTTMP/cvsrepo/src/a,v <-- a
296 $ sleep 4 # the two changes will be split if fuzz < 4
297 $ echo g >> b/c
298 $ cvscall -q commit -mfuzzy . | grep '<--'
299 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
300 $ cd ..
301
302 convert again
303
304 $ TZ=Pacific/Johnston hg convert --config convert.cvsps.fuzz=2 --config convert.localtimezone=True src src-hg
305 connecting to $TESTTMP/cvsrepo
306 scanning source...
307 collecting CVS rlog
308 11 log entries
309 cvslog hook: 11 entries
310 creating changesets
311 8 changeset entries
312 cvschangesets hook: 8 changesets
313 sorting...
314 converting...
315 2 funny
316 1 fuzzy
317 0 fuzzy
318 $ hg -R src-hg log -G --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
319 o 8 (branch) fuzzy date: * -1000 files: b/c (glob)
320 |
321 o 7 (branch) fuzzy date: * -1000 files: a (glob)
322 |
323 o 6 (branch) funny
324 | ----------------------------
325 | log message date: * -1000 files: a (glob)
326 o 5 (branch) ci2 date: * -1000 files: b/c (glob)
327
328 o 4 () ci1 date: * -1000 files: a b/c (glob)
329 |
330 o 3 () update tags date: * +0000 files: .hgtags (glob)
331 |
332 | o 2 (INITIAL) import date: * -1000 files: (glob)
333 | |
334 o | 1 () ci0 date: * -1000 files: b/c (glob)
335 |/
336 o 0 () Initial revision date: * -1000 files: a b/c (glob)
337
338
339 testing debugcvsps
340
341 $ cd src
342 $ hg debugcvsps --fuzz=2 -x >/dev/null
343
344 commit a new revision changing a and removing b/c
345
346 $ cvscall -q update -A
347 U a
348 U b/c
349 $ sleep 1
350 $ echo h >> a
351 $ cvscall -Q remove -f b/c
352 $ cvscall -q commit -mci | grep '<--'
353 $TESTTMP/cvsrepo/src/a,v <-- a
354 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
355
356 update and verify the cvsps cache
357
358 $ hg debugcvsps --fuzz=2 -u
359 collecting CVS rlog
360 13 log entries
361 cvslog hook: 13 entries
362 creating changesets
363 11 changeset entries
364 cvschangesets hook: 11 changesets
365 ---------------------
366 PatchSet 1
367 Date: * (glob)
368 Author: * (glob)
369 Branch: HEAD
370 Tag: (none)
371 Branchpoints: INITIAL
372 Log:
373 Initial revision
374
375 Members:
376 a:INITIAL->1.1
377
378 ---------------------
379 PatchSet 2
380 Date: * (glob)
381 Author: * (glob)
382 Branch: HEAD
383 Tag: (none)
384 Branchpoints: INITIAL, branch
385 Log:
386 Initial revision
387
388 Members:
389 b/c:INITIAL->1.1
390
391 ---------------------
392 PatchSet 3
393 Date: * (glob)
394 Author: * (glob)
395 Branch: INITIAL
396 Tag: start
397 Log:
398 import
399
400 Members:
401 a:1.1->1.1.1.1
402 b/c:1.1->1.1.1.1
403
404 ---------------------
405 PatchSet 4
406 Date: * (glob)
407 Author: * (glob)
408 Branch: HEAD
409 Tag: (none)
410 Log:
411 ci0
412
413 Members:
414 b/c:1.1->1.2
415
416 ---------------------
417 PatchSet 5
418 Date: * (glob)
419 Author: * (glob)
420 Branch: HEAD
421 Tag: (none)
422 Branchpoints: branch
423 Log:
424 ci1
425
426 Members:
427 a:1.1->1.2
428
429 ---------------------
430 PatchSet 6
431 Date: * (glob)
432 Author: * (glob)
433 Branch: HEAD
434 Tag: (none)
435 Log:
436 ci1
437
438 Members:
439 b/c:1.2->1.3
440
441 ---------------------
442 PatchSet 7
443 Date: * (glob)
444 Author: * (glob)
445 Branch: branch
446 Tag: (none)
447 Log:
448 ci2
449
450 Members:
451 b/c:1.1->1.1.2.1
452
453 ---------------------
454 PatchSet 8
455 Date: * (glob)
456 Author: * (glob)
457 Branch: branch
458 Tag: (none)
459 Log:
460 funny
461 ----------------------------
462 log message
463
464 Members:
465 a:1.2->1.2.2.1
466
467 ---------------------
468 PatchSet 9
469 Date: * (glob)
470 Author: * (glob)
471 Branch: branch
472 Tag: (none)
473 Log:
474 fuzzy
475
476 Members:
477 a:1.2.2.1->1.2.2.2
478
479 ---------------------
480 PatchSet 10
481 Date: * (glob)
482 Author: * (glob)
483 Branch: branch
484 Tag: (none)
485 Log:
486 fuzzy
487
488 Members:
489 b/c:1.1.2.1->1.1.2.2
490
491 ---------------------
492 PatchSet 11
493 Date: * (glob)
494 Author: * (glob)
495 Branch: HEAD
496 Tag: (none)
497 Log:
498 ci
499
500 Members:
501 a:1.2->1.3
502 b/c:1.3->1.4(DEAD)
503
504
505 $ cd ..
506
507 Test transcoding CVS log messages (issue5597)
508 =============================================
509
510 To emulate commit messages in (non-ascii) multiple encodings portably,
511 this test scenario writes CVS history file (*,v file) directly via
512 python code.
513
514 Commit messages of version 1.2 - 1.4 use u3042 in 3 encodings below.
515
516 |encoding |byte sequence | decodable as: |
517 | | | utf-8 euc-jp cp932 |
518 +----------+--------------+--------------------+
519 |utf-8 |\xe3\x81\x82 | o x x |
520 |euc-jp |\xa4\xa2 | x o o |
521 |cp932 |\x82\xa0 | x x o |
522
523 $ mkdir -p cvsrepo/transcoding
524 $ "$PYTHON" <<EOF
525 > fp = open('cvsrepo/transcoding/file,v', 'wb')
526 > fp.write((b'''
527 > head 1.4;
528 > access;
529 > symbols
530 > start:1.1.1.1 INITIAL:1.1.1;
531 > locks; strict;
532 > comment @# @;
533 >
534 >
535 > 1.4
536 > date 2017.07.10.00.00.04; author nobody; state Exp;
537 > branches;
538 > next 1.3;
539 > commitid 10059635D016A510FFA;
540 >
541 > 1.3
542 > date 2017.07.10.00.00.03; author nobody; state Exp;
543 > branches;
544 > next 1.2;
545 > commitid 10059635CFF6A4FF34E;
546 >
547 > 1.2
548 > date 2017.07.10.00.00.02; author nobody; state Exp;
549 > branches;
550 > next 1.1;
551 > commitid 10059635CFD6A4D5095;
552 >
553 > 1.1
554 > date 2017.07.10.00.00.01; author nobody; state Exp;
555 > branches
556 > 1.1.1.1;
557 > next ;
558 > commitid 10059635CFB6A4A3C33;
559 >
560 > 1.1.1.1
561 > date 2017.07.10.00.00.01; author nobody; state Exp;
562 > branches;
563 > next ;
564 > commitid 10059635CFB6A4A3C33;
565 >
566 >
567 > desc
568 > @@
569 >
570 >
571 > 1.4
572 > log
573 > @''' + u'\u3042'.encode('cp932') + b''' (cp932)
574 > @
575 > text
576 > @1
577 > 2
578 > 3
579 > 4
580 > @
581 >
582 >
583 > 1.3
584 > log
585 > @''' + u'\u3042'.encode('euc-jp') + b''' (euc-jp)
586 > @
587 > text
588 > @d4 1
589 > @
590 >
591 >
592 > 1.2
593 > log
594 > @''' + u'\u3042'.encode('utf-8') + b''' (utf-8)
595 > @
596 > text
597 > @d3 1
598 > @
599 >
600 >
601 > 1.1
602 > log
603 > @Initial revision
604 > @
605 > text
606 > @d2 1
607 > @
608 >
609 >
610 > 1.1.1.1
611 > log
612 > @import
613 > @
614 > text
615 > @@
616 > ''').lstrip())
617 > EOF
618
619 $ cvscall -q checkout transcoding
620 U transcoding/file
621
622 Test converting in normal case
623 ------------------------------
624
625 (filtering by grep in order to check only form of debug messages)
626
627 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp,cp932 -q --debug transcoding transcoding-hg | grep 'transcoding by'
628 transcoding by utf-8: 1.1 of file
629 transcoding by utf-8: 1.1.1.1 of file
630 transcoding by utf-8: 1.2 of file
631 transcoding by euc-jp: 1.3 of file
632 transcoding by cp932: 1.4 of file
633 $ hg -R transcoding-hg --encoding utf-8 log -T "{rev}: {desc}\n"
634 5: update tags
635 4: import
636 3: \xe3\x81\x82 (cp932) (esc)
637 2: \xe3\x81\x82 (euc-jp) (esc)
638 1: \xe3\x81\x82 (utf-8) (esc)
639 0: Initial revision
640 $ rm -rf transcoding-hg
641
642 Test converting in error cases
643 ------------------------------
644
645 unknown encoding in convert.cvsps.logencoding
646
647 $ hg convert --config convert.cvsps.logencoding=foobar -q transcoding transcoding-hg
648 abort: unknown encoding: foobar
649 (check convert.cvsps.logencoding configuration)
650 [255]
651 $ rm -rf transcoding-hg
652
653 no acceptable encoding in convert.cvsps.logencoding
654
655 $ hg convert --config convert.cvsps.logencoding=utf-8,euc-jp -q transcoding transcoding-hg
656 abort: no encoding can transcode CVS log message for 1.4 of file
657 (check convert.cvsps.logencoding configuration)
658 [255]
659 $ rm -rf transcoding-hg