author Gregory Szorc <>
Wed, 08 Apr 2015 15:33:48 -0700
changeset 360656 8bbac22f6b7c8fafdb86dc956ce51f9af50b2766
parent 358894 1c89dcd5cac53b85073b213efcf69740b540125b
permissions -rwxr-xr-x
deploy: implement deploy driver Ansible commands take just enough arguments that typing them all in is annoying. Let's provide a driver script for automating common deployment tasks.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at

# Imports another hg repository into this one, placing it inside the chosen
# subdirectory, using a splice map to avoid non-linear history.
set -e

err() { echo $1; exit 1; }
prep-repo() {
  [ -n "$(hg qapplied --repository $1)" ] && err "Error: Patches applied in $1"

[ $# -ne 2 ] && err "Usage: $(basename "$0") REPO-TO-IMPORT TARGET-SUBDIRECTORY"

read -p "Import $SOURCE into the subdirectory $SUBDIRECTORY? (y/n)?"
[ "$REPLY" == "y" ] || exit 1

prep-repo "$PWD"
prep-repo "$SOURCE"

# Revisions for the splicemap (avoids having to rebase after import).
TARGET_TIP_REVISION=$(hg log -r default --template '{node}')
SOURCE_BASE_REVISION=$(hg log -r 0 --repository "$SOURCE" --template '{node}')

echo "rename . $SUBDIRECTORY" > ~filemap
hg convert --filemap ~filemap --splicemap ~splicemap "$SOURCE" .
rm ~filemap ~splicemap