comparison extra/soundsoftware/update-external-repo.sh @ 436:4eb486dbf730 bug_169

If the remote repo URL changes, move aside the existing local mirror and start afresh. (Not yet tested: checkpointing this prior to working on a different aspect of the problem)
author Chris Cannam
date Mon, 06 Jun 2011 12:53:06 +0100
parents 7fd72f22a42b
children 102056ec2de9
comparison
equal deleted inserted replaced
435:897979555864 436:4eb486dbf730
58 # we brought in, and test each time whether it matches the last 58 # we brought in, and test each time whether it matches the last
59 # changeset ID actually in the repo 59 # changeset ID actually in the repo
60 60
61 success="" 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 fi
82 fi
83
63 if [ -d "$project_repo_mirror" ]; then 84 if [ -d "$project_repo_mirror" ]; then
64 85
65 # Repo mirror exists: update it 86 # Repo mirror exists: update it
66 echo "$$: Mirror for project $project exists at $project_repo_mirror, updating" 1>&2 87 echo "$$: Mirror for project $project exists at $project_repo_mirror, updating" 1>&2
67 88
94 115
95 echo "Success=$success" 116 echo "Success=$success"
96 117
97 if [ -n "$success" ]; then 118 if [ -n "$success" ]; then
98 echo "$$: Update successful, pulling into local repo at $local_repo" 119 echo "$$: Update successful, pulling into local repo at $local_repo"
120 if [ ! -d "$local_repo" ]; then
121 "$hg" init "$local_repo"
122 fi
99 if [ -d "$project_repo_mirror/.git" ]; then 123 if [ -d "$project_repo_mirror/.git" ]; then
100 if [ ! -d "$local_repo" ]; then 124 ( cd "$local_repo" && "$hg" --config extensions.hggit= pull "$project_repo_mirror" ) && echo "$remote_repo" > "$successfile"
101 "$hg" init "$local_repo"
102 fi
103 ( cd "$local_repo" && "$hg" --config extensions.hggit= pull "$project_repo_mirror" )
104 else 125 else
105 ( cd "$local_repo" && "$hg" pull "$project_repo_mirror" ) 126 ( cd "$local_repo" && "$hg" pull "$project_repo_mirror" ) && echo "$remote_repo" > "$successfile"
106 fi 127 fi
107 fi 128 fi