This repository has been archived by the owner on Sep 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
helper-one-svn-one-git.sh
139 lines (133 loc) · 4.07 KB
/
helper-one-svn-one-git.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
addpacketifneeded svn subversion &&
addpacketifneeded svnadmin subversion &&
(
if ! test -d $localSVNmirror; then
mkdir -p $localSVNmirror
fi &&
cd $localSVNmirror && {
if ! test -f format; then
cmd=$(echo svnadmin create $PWD)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval $cmd 2>&1
echo "#!/bin/sh" >hooks/pre-revprop-change &&
echo "exit 0" >>hooks/pre-revprop-change &&
chmod ugo+rx hooks/pre-revprop-change
cmd=$(echo svnsync initialize file://$PWD $SVN)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval $cmd 2>&1
fi
} &&
(
cd $localSVNmirror && {
srcuuid=$(svn info "$SVN" | grep "Repository UUID" | sed -e "s/Repository UUID: //g") &&
echo srcuuid=$srcuuid &&
dstuuid=$(svn info file://$PWD | grep "Repository UUID" | sed -e "s/Repository UUID: //g") &&
echo dstuuid=$dstuuid &&
if test $srcuuid != $dstuuid; then
cmd=$(echo svnadmin setuuid $PWD $srcuuid) &&
echo LINENO=$LINENO PWD=$PWD cmd=$cmd &&
eval "$cmd"
fi &&
cmd=$(echo svnsync sync file://$PWD $SVN)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval $cmd 2>&1 || {
cmd=$(echo svnsync sync file://$PWD)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval $cmd 2>&1
}
}
)
)
#### git clone via local suberversion mirror
(
mkdir -p "$homeepicsgit" &&
cd $homeepicsgit || {
echo >&2 cd $homeepicsgit failed
exit 1
}
dir1=$PWD/../svn/${projectX}AllInOne
if test -d "$dir1"; then
if test $(echo dir1/*) = "dir1/*"; then
echo PWD=$PWD dir1=$dir is empty &&
rm -rf "$dir1/.git" && rmdir "$dir1"
fi
fi &&
if ! test -e "$dir1"; then
cmd=$(echo git svn clone file://$localSVNmirror $dir1)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval $cmd 2>&1 || {
addpacketifneeded libsvn-perl
addpacketifneeded git-svn
eval $cmd
}
fi
dir2=${projectX}
echo dir2=$dir2
echo localSVNmirror=$localSVNmirror
mkdir -p $dir2 || {
echo >&2 "Can not create $dir2"
exit 1
}
(
echo dir1=$dir1
cd $dir2 &&
dirs=$(echo $dir1/* | sort)
echo LINENO=$LINENO PWD=$PWD dirs=$dirs
singlesvn=$(echo $dir1/branches $dir1/tags $dir1/trunk)
echo LINENO=$LINENO PWD=$PWD singlesvn=$singlesvn
if test "$dirs" = "$singlesvn"; then
echo LINENO=$LINENO PWD=$PWD singlesvn=dirs
dirs=.
fi
for i in $dirs; do
subdir=$(echo $i | sed -e "s!.*/!!g")
echo LINENO=$LINENO PWD=$PWD subdir=$subdir
if test "$subdir" = "*"; then
echo "PWD=$PWD", can not continue
echo "dir1=$dir1", can not continue
echo "PWD/dir1=$PWD/$dir1", can not continue
echo "subdir=$subdir", can not continue
exit 1
fi &&
locallocalSVNmirror=$(echo $localSVNmirror | sed -e "s%^$HOME%~%") &&
echo locallocalSVNmirror="$locallocalSVNmirror" &&
if ! test -d "$subdir/.git"; then
(
cmd=$(echo git svn init \
-T trunk -b branches -t tags \
--prefix=origin/ \
--rewrite-root="file://.../$dir2" \
file://$localSVNmirror/$subdir $subdir)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval $cmd 2>&1
)
fi || mv "$subdir" $$
if test -d "$subdir"; then
(
cd $subdir &&
cmd=$(echo git svn fetch)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval "$cmd" || exit 1
cmd=$(echo git checkout remotes/origin/trunk)
echo LINENO=$LINENO PWD=$PWD cmd=$cmd
eval "$cmd" || exit 1
) &&
(
pfx=origin/tags/
cd $subdir &&
tags=$(git branch -r | grep $pfx) &&
for rtag in $tags; do
ltag=$(echo $rtag | sed -e "s%$pfx%%g") &&
cmd=$(echo git checkout $rtag) &&
echo LINENO=$LINENO PWD=$PWD cmd=$cmd &&
eval "$cmd" || exit 1
cmd=$(echo git tag -f $ltag) &&
echo LINENO=$LINENO PWD=$PWD cmd=$cmd &&
eval "$cmd" || exit 1
done
git checkout origin/trunk
)
fi
done
)
)