@@ -55,11 +55,13 @@ arg_split_annotate=
55
55
arg_addmerge_squash=
56
56
arg_addmerge_message=
57
57
58
+ indent=0
59
+
58
60
# Usage: debug [MSG...]
59
61
debug () {
60
62
if test -n " $arg_debug "
61
63
then
62
- printf " %s \n" " $* " >&2
64
+ printf " %$(( $indent * 2 )) s%s \n" ' ' " $* " >&2
63
65
fi
64
66
}
65
67
@@ -251,17 +253,17 @@ cache_miss () {
251
253
done
252
254
}
253
255
254
- # Usage: check_parents PARENTS_EXPR INDENT
256
+ # Usage: check_parents PARENTS_EXPR
255
257
check_parents () {
256
- assert test $# = 2
258
+ assert test $# = 1
257
259
missed=$( cache_miss " $1 " ) || exit $?
258
- local indent=$(( $2 + 1 ))
260
+ local indent=$(( $indent + 1 ))
259
261
for miss in $missed
260
262
do
261
263
if ! test -r " $cachedir /notree/$miss "
262
264
then
263
- debug " incorrect order: $miss "
264
- process_split_commit " $miss " " " " $indent "
265
+ debug " incorrect order: $miss "
266
+ process_split_commit " $miss " " "
265
267
fi
266
268
done
267
269
}
@@ -314,6 +316,8 @@ try_remove_previous () {
314
316
find_latest_squash () {
315
317
assert test $# = 1
316
318
debug " Looking for latest squash ($dir )..."
319
+ local indent=$(( $indent + 1 ))
320
+
317
321
dir=" $1 "
318
322
sq=
319
323
main=
@@ -360,6 +364,8 @@ find_latest_squash () {
360
364
find_existing_splits () {
361
365
assert test $# = 2
362
366
debug " Looking for prior splits..."
367
+ local indent=$(( $indent + 1 ))
368
+
363
369
dir=" $1 "
364
370
rev=" $2 "
365
371
main=
@@ -385,7 +391,7 @@ find_existing_splits () {
385
391
die " could not rev-parse split hash $b from commit $sq "
386
392
;;
387
393
END)
388
- debug " Main is: '$main '"
394
+ debug " Main is: '$main '"
389
395
if test -z " $main " -a -n " $sub "
390
396
then
391
397
# squash commits refer to a subtree
@@ -668,12 +674,11 @@ ensure_valid_ref_format () {
668
674
die " '$1 ' does not look like a ref"
669
675
}
670
676
671
- # Usage: process_split_commit REV PARENTS INDENT
677
+ # Usage: process_split_commit REV PARENTS
672
678
process_split_commit () {
673
- assert test $# = 3
679
+ assert test $# = 2
674
680
local rev=" $1 "
675
681
local parents=" $2 "
676
- local indent=$3
677
682
678
683
if test $indent -eq 0
679
684
then
@@ -688,20 +693,21 @@ process_split_commit () {
688
693
progress " $revcount /$revmax ($createcount ) [$extracount ]"
689
694
690
695
debug " Processing commit: $rev "
696
+ local indent=$(( $indent + 1 ))
691
697
exists=$( cache_get " $rev " ) || exit $?
692
698
if test -n " $exists "
693
699
then
694
- debug " prior: $exists "
700
+ debug " prior: $exists "
695
701
return
696
702
fi
697
703
createcount=$(( $createcount + 1 ))
698
- debug " parents: $parents "
699
- check_parents " $parents " " $indent "
704
+ debug " parents: $parents "
705
+ check_parents " $parents "
700
706
newparents=$( cache_get $parents ) || exit $?
701
- debug " newparents: $newparents "
707
+ debug " newparents: $newparents "
702
708
703
709
tree=$( subtree_for_commit " $rev " " $dir " ) || exit $?
704
- debug " tree is: $tree "
710
+ debug " tree is: $tree "
705
711
706
712
# ugly. is there no better way to tell if this is a subtree
707
713
# vs. a mainline commit? Does it matter?
@@ -716,7 +722,7 @@ process_split_commit () {
716
722
fi
717
723
718
724
newrev=$( copy_or_skip " $rev " " $tree " " $newparents " ) || exit $?
719
- debug " newrev is: $newrev "
725
+ debug " newrev is: $newrev "
720
726
cache_set " $rev " " $newrev "
721
727
cache_set latest_new " $newrev "
722
728
cache_set latest_old " $rev "
@@ -820,7 +826,7 @@ cmd_split () {
820
826
do
821
827
# the 'onto' history is already just the subdir, so
822
828
# any parent we find there can be used verbatim
823
- debug " cache: $rev "
829
+ debug " cache: $rev "
824
830
cache_set " $rev " " $rev "
825
831
done || exit $?
826
832
fi
@@ -838,7 +844,7 @@ cmd_split () {
838
844
eval " $grl " |
839
845
while read rev parents
840
846
do
841
- process_split_commit " $rev " " $parents " 0
847
+ process_split_commit " $rev " " $parents "
842
848
done || exit $?
843
849
844
850
latest_new=$( cache_get latest_new) || exit $?
0 commit comments