--- /dev/null
+#! /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"