chiark / gitweb /
automate process of transforming a standalone bzr branch into a branch attached to...
authorColin Watson <cjwatson@chiark.greenend.org.uk>
Tue, 7 Apr 2009 09:47:57 +0000 (09:47 +0000)
committerColin Watson <cjwatson@chiark.greenend.org.uk>
Tue, 7 Apr 2009 09:47:57 +0000 (09:47 +0000)
bzr-move-to-repository [new file with mode: 0755]

diff --git a/bzr-move-to-repository b/bzr-move-to-repository
new file mode 100755 (executable)
index 0000000..9dfa288
--- /dev/null
@@ -0,0 +1,36 @@
+#! /bin/sh -e
+
+if [ -z "$1" ]; then
+       echo "Usage: $0 DIRECTORY" >&2
+       exit 1
+fi
+set -- "${1%/}"
+if [ -d "$1.nonrepo" ]; then
+       echo "$1.nonrepo exists; in-flight collision?" >&2
+       exit 1
+fi
+if [ ! -d "$1" ]; then
+       echo "$1 is not a directory!" >&2
+       exit 1
+fi
+if [ ! -d "$1/.bzr" ]; then
+       echo "$1 is not a Bazaar branch!" >&2
+       exit 1
+fi
+if [ ! -d "$1/.bzr/repository" ]; then
+       echo "$1 seems to already be in a repository!" >&2
+       exit 1
+fi
+if [ "$(bzr st "$1")" ]; then
+       echo "$1 has uncommitted changes!" >&2
+       exit 1
+fi
+
+mv -T "$1" "$1.nonrepo"
+bzr get "$1.nonrepo" "$1"
+cp -a "$1.nonrepo/.bzr/branch/branch.conf" "$1/.bzr/branch/branch.conf"
+# oem-config/ubiquity
+if [ -d "$1.nonrepo/d-i/source" ] && [ ! -d "$1/d-i/source" ]; then
+       mv "$1.nonrepo/d-i/source" "$1/d-i/source"
+fi
+rm -rf "$1.nonrepo"