X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~cjwatson/git?p=bin.git;a=blobdiff_plain;f=baz-update-config;h=71588857cf05a071aa174c184359ebe5e9f722b2;hp=e992cf93f5a38b7d5f58a7006a8b4c85a53b355d;hb=cdb79bca0737bc6c9e39cad2076d392387bc0ff0;hpb=66785e5dcef209c1b0890c169a11dc0a9e241728 diff --git a/baz-update-config b/baz-update-config index e992cf9..7158885 100755 --- a/baz-update-config +++ b/baz-update-config @@ -12,20 +12,62 @@ NEWLINE=' IFS_SAVE="$IFS" IFS="$NEWLINE" -for line in $(baz cat-config "$1"); do +for line in $(baz cat-config "$1" 2>/dev/null || cat "$1"); do IFS="$IFS_SAVE" set -- $line DIR="$1" VERSION="$2" - if [ -d "$DIR" ]; then - OLDVERSION="$(baz tree-version -d "$DIR")" - if [ "$VERSION" != "$OLDVERSION" ]; then - baz switch -d "$DIR" "$VERSION" - else - baz update -d "$DIR" "$VERSION" - fi - else - baz get "$VERSION" "$DIR" - fi + echo "Updating $DIR ($VERSION) ..." + + case $VERSION in + bzr+ssh://*|http://*|sftp://*) + if [ -d "$DIR" ]; then + if [ ! -d "$DIR/.bzr" ]; then + echo "$DIR is not a bzr checkout; cannot update" >&2 + continue + elif [ -f "$DIR/.bzr/branch/bound" ]; then + bzr update "$DIR" + else + (cd "$DIR" && bzr pull "$VERSION") + fi + else + case $VERSION in + bzr+ssh://*|sftp://*) + bzr checkout "$VERSION" "$DIR" + ;; + *) + bzr get "$VERSION" "$DIR" + ;; + esac + fi + ;; + git://*|git+*://*) + if [ -d "$DIR" ]; then + if [ ! -d "$DIR/.git" ]; then + echo "$DIR is not a git checkout; cannot update" >&2 + continue + fi + (cd "$DIR" && git pull "$VERSION") + else + git clone "$VERSION" "$DIR" + fi + ;; + *) + if [ -d "$DIR" ]; then + if [ ! -d "$DIR/{arch}" ]; then + echo "$DIR is not an arch checkout; cannot update" >&2 + continue + fi + OLDVERSION="$(baz tree-version -d "$DIR")" + if [ "$VERSION" != "$OLDVERSION" ]; then + baz switch -d "$DIR" "$VERSION" + else + baz update -d "$DIR" "$VERSION" + fi + else + baz get "$VERSION" "$DIR" + fi + ;; + esac done