| 60 |
60 |
|
| 61 |
61 |
success=""
|
| 62 |
62 |
|
|
63 |
# If we have a record of the last successfully updated remote repo
|
|
64 |
# URL, check it against our current remote URL: if it has changed, we
|
|
65 |
# will need to start again with a new clone rather than pulling
|
|
66 |
# updates into the existing local mirror
|
|
67 |
|
|
68 |
successfile="$project_mirror/last_successful_url"
|
|
69 |
if [ -f "$successfile" ]; then
|
|
70 |
last=$(cat "$successfile")
|
|
71 |
if [ x"$last" = x"$remote_repo" ]; then
|
|
72 |
echo "$$: Remote URL is unchanged from last successful update"
|
|
73 |
else
|
|
74 |
echo "$$: Remote URL has changed since last successful update:"
|
|
75 |
echo "$$: Last URL was $last, current is $remote_repo"
|
|
76 |
suffix="$$.$(date +%s)"
|
|
77 |
echo "$$: Moving existing repos to $suffix suffix and starting afresh"
|
|
78 |
mv "$project_repo_mirror" "$project_repo_mirror"."$suffix"
|
|
79 |
mv "$local_repo" "$local_repo"."$suffix"
|
|
80 |
mv "$successfile" "$successfile"."$suffix"
|
|
81 |
touch "$project_mirror/url_changed"
|
|
82 |
fi
|
|
83 |
fi
|
|
84 |
|
| 63 |
85 |
if [ -d "$project_repo_mirror" ]; then
|
| 64 |
86 |
|
| 65 |
87 |
# Repo mirror exists: update it
|
| ... | ... | |
| 96 |
118 |
|
| 97 |
119 |
if [ -n "$success" ]; then
|
| 98 |
120 |
echo "$$: Update successful, pulling into local repo at $local_repo"
|
|
121 |
if [ ! -d "$local_repo" ]; then
|
|
122 |
"$hg" init "$local_repo"
|
|
123 |
fi
|
| 99 |
124 |
if [ -d "$project_repo_mirror/.git" ]; then
|
| 100 |
|
if [ ! -d "$local_repo" ]; then
|
| 101 |
|
"$hg" init "$local_repo"
|
| 102 |
|
fi
|
| 103 |
|
( cd "$local_repo" && "$hg" --config extensions.hggit= pull "$project_repo_mirror" )
|
|
125 |
( cd "$local_repo" && "$hg" --config extensions.hggit= pull "$project_repo_mirror" ) && echo "$remote_repo" > "$successfile"
|
| 104 |
126 |
else
|
| 105 |
|
( cd "$local_repo" && "$hg" pull "$project_repo_mirror" )
|
|
127 |
( cd "$local_repo" && "$hg" pull "$project_repo_mirror" ) && echo "$remote_repo" > "$successfile"
|
| 106 |
128 |
fi
|
| 107 |
129 |
fi
|