-
Notifications
You must be signed in to change notification settings - Fork 6
/
incrementalClone.sh
executable file
·65 lines (63 loc) · 1.46 KB
/
incrementalClone.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
#!/bin/bash
#
# iDempiere contribution
# Author: Carlos Antonio Ruiz Gomez - globalqss
# Incremental clone for slow bandwidth
# Based on idea from Coenraad Loubser, Capetown, South Africa ( http://wiki.idempiere.org/en/Hg_clone_idempiere_over_broken_line )
#
cut_increment_by_half() {
INCREMENT=`expr $INCREMENT / 2`
if [ $INCREMENT -eq 0 ]
then
INCREMENT=1
fi
}
if [ $# -gt 1 ]
then
echo "Usage: $0 [repository_url]"
echo "Example:"
echo " $0 https://bitbucket.org/idempiere/idempiere"
exit 1
fi
if [ $# -eq 1 ]
then
echo "Cloning rev 1 from $1 ... "
hg -q clone -r 1 $1
cd `basename $1`
fi
INCREMENT=100
PREVREV=0
while true
do
ACTUALREV=`hg identify -n`
REV=$(( $ACTUALREV + $INCREMENT ))
echo -n "Pulling $REV ... "
ERROR=`hg -v pull -r $REV -u 2>&1`
result=$?
echo "result=$result"
echo $ERROR
if [ $result -eq 255 ]
then
MATCH=`expr "$ERROR" : ".*unknown revision*"`
if [ $MATCH -ne 0 ]
then
if [ $INCREMENT -ne 1 ]
then
cut_increment_by_half
echo "error: $ERROR ... retrying with increment $INCREMENT"
continue
fi
echo "error: $ERROR ... exit"
break
fi
cut_increment_by_half
echo "error: $ERROR ... retrying with increment $INCREMENT ... CTRL-C to break"
continue
fi
if [ $PREVREV -eq $REV ]
then
cut_increment_by_half
echo "error: not advancing ... changing increment to $INCREMENT"
fi
PREVREV=$REV
done