10
11
. ./test-lib.sh
12
13
-if ! test_have_prereq PYTHON; then
13
+if ! test_have_prereq PYTHON
14
+then
15
skip_all='skipping remote-hg tests; python not available'
16
test_done
17
fi
18
18
-if ! python -c 'import mercurial'; then
19
+if ! python -c 'import mercurial'
20
+then
21
skip_all='skipping remote-hg tests; mercurial not available'
22
test_done
23
fi
24
25
check () {
24
- echo $3 > expected &&
25
- git --git-dir=$1/.git log --format='%s' -1 $2 > actual
26
+ echo $3 >expected &&
27
+ git --git-dir=$1/.git log --format='%s' -1 $2 >actual
28
test_cmp expected actual
29
}
30
31
check_branch () {
30
- if [ -n "$3" ]; then
31
- echo $3 > expected &&
32
- hg -R $1 log -r $2 --template '{desc}\n' > actual &&
32
+ if test -n "$3"
33
+ then
34
+ echo $3 >expected &&
35
+ hg -R $1 log -r $2 --template '{desc}\n' >actual &&
36
test_cmp expected actual
37
else
35
- hg -R $1 branches > out &&
38
+ hg -R $1 branches >out &&
39
! grep $2 out
40
fi
41
}
42
43
check_bookmark () {
41
- if [ -n "$3" ]; then
42
- echo $3 > expected &&
43
- hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' > actual &&
44
+ if test -n "$3"
45
+ then
46
+ echo $3 >expected &&
47
+ hg -R $1 log -r "bookmark('$2')" --template '{desc}\n' >actual &&
48
test_cmp expected actual
49
else
46
- hg -R $1 bookmarks > out &&
50
+ hg -R $1 bookmarks >out &&
51
! grep $2 out
52
fi
53
}
56
local expected_ret=$1 ret=0 ref_ret=0 IFS=':'
57
58
shift
55
- git push origin "$@" 2> error
59
+ git push origin "$@" 2>error
60
ret=$?
61
cat error
62
96
echo "username = H G Wells <wells@example.com>"
97
echo "[extensions]"
98
echo "mq ="
95
- ) >> "$HOME"/.hgrc &&
99
+ ) >>"$HOME"/.hgrc &&
100
101
GIT_AUTHOR_DATE="2007-01-01 00:00:00 +0230" &&
102
GIT_COMMITTER_DATE="$GIT_AUTHOR_DATE" &&
111
(
112
hg init hgrepo &&
113
cd hgrepo &&
110
- echo zero > content &&
114
+ echo zero >content &&
115
hg add content &&
116
hg commit -m zero
117
) &&
126
(
127
cd hgrepo &&
128
hg branch next &&
125
- echo next > content &&
129
+ echo next >content &&
130
hg commit -m next
131
) &&
132
141
cd hgrepo &&
142
hg checkout default &&
143
hg bookmark feature-a &&
140
- echo feature-a > content &&
144
+ echo feature-a >content &&
145
hg commit -m feature-a
146
) &&
147
161
git clone "hg::hgrepo" gitrepo &&
162
cd gitrepo &&
163
git checkout --quiet devel &&
160
- echo devel > content &&
164
+ echo devel >content &&
165
git commit -a -m devel &&
166
git push --quiet
167
) &&
176
git clone "hg::hgrepo" gitrepo &&
177
cd gitrepo &&
178
git checkout --quiet -b feature-b &&
175
- echo feature-b > content &&
179
+ echo feature-b >content &&
180
git commit -a -m feature-b &&
181
git push --quiet origin feature-b
182
) &&
188
rm -rf hgrepo
189
190
author_test () {
187
- echo $1 >> content &&
191
+ echo $1 >>content &&
192
hg commit -u "$2" -m "add $1" &&
189
- echo "$3" >> ../expected
193
+ echo "$3" >>../expected
194
}
195
196
test_expect_success 'authors' '
203
touch content &&
204
hg add content &&
205
202
- > ../expected &&
206
+ >../expected &&
207
author_test alpha "" "H G Wells <wells@example.com>" &&
208
author_test beta "test" "test <unknown>" &&
209
author_test beta "test <test@example.com> (comment)" "test <test@example.com>" &&
218
) &&
219
220
git clone "hg::hgrepo" gitrepo &&
217
- git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" > actual &&
221
+ git --git-dir=gitrepo/.git log --reverse --format="%an <%ae>" >actual &&
222
223
test_cmp expected actual
224
'
230
hg init hgrepo &&
231
cd hgrepo &&
232
229
- echo one >> content &&
233
+ echo one >>content &&
234
hg add content &&
235
hg commit -m one &&
236
233
- echo two >> content &&
237
+ echo two >>content &&
238
hg commit -m two
239
) &&
240
244
cd hgrepo &&
245
hg strip 1 &&
246
243
- echo three >> content &&
247
+ echo three >>content &&
248
hg commit -m three &&
249
246
- echo four >> content &&
250
+ echo four >>content &&
251
hg commit -m four
252
) &&
253
254
(
255
cd gitrepo &&
256
git fetch &&
253
- git log --format="%s" origin/master > ../actual
257
+ git log --format="%s" origin/master >../actual
258
) &&
259
256
- hg -R hgrepo log --template "{desc}\n" > expected &&
260
+ hg -R hgrepo log --template "{desc}\n" >expected &&
261
test_cmp actual expected
262
'
263
267
(
268
hg init hgrepo &&
269
cd hgrepo &&
266
- echo zero > content &&
270
+ echo zero >content &&
271
hg add content &&
272
hg commit -m zero &&
273
hg bookmark master &&
270
- echo one > content &&
274
+ echo one >content &&
275
hg commit -m one
276
) &&
277
278
(
279
git clone "hg::hgrepo" gitrepo &&
280
cd gitrepo &&
277
- echo two > content &&
281
+ echo two >content &&
282
git commit -a -m two &&
283
git push
284
) &&
286
check_branch hgrepo default two
287
'
288
285
-cat > expected <<EOF
289
+cat >expected <<\EOF
290
changeset: 0:6e2126489d3d
291
tag: tip
292
user: A U Thor <author@example.com>
304
git init gitrepo &&
305
cd gitrepo &&
306
git remote add origin "hg::../hgrepo" &&
303
- echo one > content &&
307
+ echo one >content &&
308
git add content &&
309
git commit -a -m one &&
310
git push origin master
311
) &&
312
309
- hg -R hgrepo log > actual &&
313
+ hg -R hgrepo log >actual &&
314
cat actual &&
315
test_cmp expected actual &&
316
326
(
327
hg init hgrepo &&
328
cd hgrepo &&
325
- echo zero > content &&
329
+ echo zero >content &&
330
hg add content &&
331
hg commit -m zero
332
) &&
347
git clone "hg::hgrepo" gitrepo &&
348
cd gitrepo &&
349
git checkout --quiet devel &&
346
- echo devel > content &&
350
+ echo devel >content &&
351
git commit -a -m devel &&
352
git push --quiet
353
) &&
362
git clone "hg::hgrepo" gitrepo &&
363
cd gitrepo &&
364
git checkout --quiet -b feature-b &&
361
- echo feature-b > content &&
365
+ echo feature-b >content &&
366
git commit -a -m feature-b &&
367
git push --quiet origin feature-b
368
) &&
378
(
379
cd hgrepo &&
380
hg checkout default &&
377
- echo bump > content &&
381
+ echo bump >content &&
382
hg commit -m bump
383
) &&
384
385
(
386
cd gitrepo &&
383
- echo diverge > content &&
387
+ echo diverge >content &&
388
git commit -a -m diverged &&
385
- check_push 1 <<-EOF
389
+ check_push 1 <<-\EOF
390
master:non-fast-forward
391
EOF
392
) &&
407
408
(
409
cd hgrepo &&
406
- echo "bump bookmark" > content &&
410
+ echo "bump bookmark" >content &&
411
hg commit -m "bump bookmark"
412
) &&
413
414
(
415
cd gitrepo &&
416
git checkout --quiet diverge &&
413
- echo diverge > content &&
417
+ echo diverge >content &&
418
git commit -a -m diverge &&
415
- check_push 1 <<-EOF
419
+ check_push 1 <<-\EOF
420
diverge:fetch-first
421
EOF
422
) &&
431
git clone "hg::hgrepo" gitrepo &&
432
cd gitrepo &&
433
git checkout --quiet -b feature-c HEAD^ &&
430
- echo feature-c > content &&
434
+ echo feature-c >content &&
435
git commit -a -m feature-c &&
436
git push --quiet origin feature-c
437
) &&
446
(
447
hg init hgrepo &&
448
cd hgrepo &&
445
- echo zero > content &&
449
+ echo zero >content &&
450
hg add content &&
451
hg commit -m zero &&
452
hg bookmark bad_bmark1 &&
449
- echo one > content &&
453
+ echo one >content &&
454
hg commit -m one &&
455
hg bookmark bad_bmark2 &&
456
hg bookmark good_bmark &&
457
hg bookmark -i good_bmark &&
458
hg -q branch good_branch &&
455
- echo "good branch" > content &&
459
+ echo "good branch" >content &&
460
hg commit -m "good branch" &&
461
hg -q branch bad_branch &&
458
- echo "bad branch" > content &&
462
+ echo "bad branch" >content &&
463
hg commit -m "bad branch"
464
) &&
465
467
468
(
469
cd gitrepo &&
466
- echo two > content &&
470
+ echo two >content &&
471
git commit -q -a -m two &&
472
473
git checkout -q good_bmark &&
470
- echo three > content &&
474
+ echo three >content &&
475
git commit -q -a -m three &&
476
477
git checkout -q bad_bmark1 &&
478
git reset --hard HEAD^ &&
475
- echo four > content &&
479
+ echo four >content &&
480
git commit -q -a -m four &&
481
482
git checkout -q bad_bmark2 &&
483
git reset --hard HEAD^ &&
480
- echo five > content &&
484
+ echo five >content &&
485
git commit -q -a -m five &&
486
487
git checkout -q -b new_bmark master &&
484
- echo six > content &&
488
+ echo six >content &&
489
git commit -q -a -m six &&
490
491
git checkout -q branches/good_branch &&
488
- echo seven > content &&
492
+ echo seven >content &&
493
git commit -q -a -m seven &&
490
- echo eight > content &&
494
+ echo eight >content &&
495
git commit -q -a -m eight &&
496
497
git checkout -q branches/bad_branch &&
498
git reset --hard HEAD^ &&
495
- echo nine > content &&
499
+ echo nine >content &&
500
git commit -q -a -m nine &&
501
502
git checkout -q -b branches/new_branch master &&
499
- echo ten > content &&
503
+ echo ten >content &&
504
git commit -q -a -m ten
505
)
506
}
513
(
514
cd gitrepo &&
515
512
- check_push 1 --all <<-EOF
516
+ check_push 1 --all <<-\EOF
517
master
518
good_bmark
519
branches/good_branch
541
(
542
hg init hgrepo &&
543
cd hgrepo &&
540
- echo zero > content &&
544
+ echo zero >content &&
545
hg add content &&
546
hg commit -m zero &&
547
hg bookmark bad_bmark &&
548
hg bookmark good_bmark &&
549
hg bookmark -i good_bmark &&
550
hg -q branch good_branch &&
547
- echo "good branch" > content &&
551
+ echo "good branch" >content &&
552
hg commit -m "good branch" &&
553
hg -q branch bad_branch &&
550
- echo "bad branch" > content &&
554
+ echo "bad branch" >content &&
555
hg commit -m "bad branch"
556
) &&
557
560
(
561
cd hgrepo &&
562
hg bookmark -f bad_bmark &&
559
- echo update_bmark > content &&
563
+ echo update_bmark >content &&
564
hg commit -m "update bmark"
565
) &&
566
567
(
568
cd gitrepo &&
565
- echo two > content &&
569
+ echo two >content &&
570
git commit -q -a -m two &&
571
572
git checkout -q good_bmark &&
569
- echo three > content &&
573
+ echo three >content &&
574
git commit -q -a -m three &&
575
576
git checkout -q bad_bmark &&
573
- echo four > content &&
577
+ echo four >content &&
578
git commit -q -a -m four &&
579
580
git checkout -q branches/bad_branch &&
577
- echo five > content &&
581
+ echo five >content &&
582
git commit -q -a -m five &&
583
580
- check_push 1 --all <<-EOF &&
584
+ check_push 1 --all <<-\EOF &&
585
master
586
good_bmark
587
bad_bmark:fetch-first
590
591
git fetch &&
592
589
- check_push 1 --all <<-EOF
593
+ check_push 1 --all <<-\EOF
594
master
595
good_bmark
596
bad_bmark:non-fast-forward
607
(
608
cd gitrepo &&
609
606
- check_push 0 --force --all <<-EOF
610
+ check_push 0 --force --all <<-\EOF
611
master
612
good_bmark
613
branches/good_branch
637
(
638
cd gitrepo &&
639
636
- check_push 1 --dry-run --all <<-EOF &&
640
+ check_push 1 --dry-run --all <<-\EOF &&
641
master
642
good_bmark
643
branches/good_branch
648
branches/bad_branch:non-fast-forward
649
EOF
650
647
- check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-EOF
651
+ check_push 0 --dry-run master good_bmark new_bmark branches/good_branch branches/new_branch <<-\EOF
652
master
653
good_bmark
654
branches/good_branch
673
(
674
hg init hgrepo &&
675
cd hgrepo &&
672
- echo zero > content &&
676
+ echo zero >content &&
677
hg add content &&
678
hg commit -m zero &&
675
- echo one > content &&
679
+ echo one >content &&
680
hg commit -m one
681
) &&
682
684
git clone "hg::hgrepo" gitrepo &&
685
cd gitrepo &&
686
git reset --hard HEAD^ &&
683
- echo two > content &&
687
+ echo two >content &&
688
git commit -a -m two &&
689
test_expect_code 1 git push &&
690
test_expect_code 1 git push