Ajout script hg-update-subrepos
[hvutilities.git] / scripts / hg-update-subrepos
diff --git a/scripts/hg-update-subrepos b/scripts/hg-update-subrepos
new file mode 100755 (executable)
index 0000000..d42b321
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+set -o errexit
+
+# Uncomment to have verbose debug output
+debug=1
+
+print_usage()
+{
+    echo "$(basename $0) -- Update HG subrepositories to latest version"
+    echo "Usage: $(basename $0) [OPTIONS...]"
+}
+
+if [ "x${1}" = "x--help" ]; then
+    print_usage
+    exit 1
+fi
+
+if [ ! -f .hgsub ]; then
+    echo "No Mercurial subrepositories found"
+    exit 1
+fi
+
+# Arg 1: repository path
+update_repos()
+{
+    local repo="${1}"
+
+    pushd "${repo}"
+    hg pull
+    hg update
+    popd
+}
+
+# Tabarnacle d'espaces à marde!!!
+OIFS="$IFS"
+IFS=$'\n'
+for d in $(find . -maxdepth 1 -type d \( \
+    -name . -o \
+    -name S\* -o \
+    -name _S\* \
+    \) ); do
+    update_repos "${d}"
+done
+IFS="$OIFS"