common/bin/hgforest.sh
Print this page
rev 1005 : 8038435: Some hgforest.sh commands don't receive parameters
Reviewed-by: duke
@@ -1,6 +1,6 @@
-#!/bin/bash
+#!/bin/sh
#
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
@@ -58,14 +58,14 @@
shift
done
command="$1"; shift
-repo_base="$@"
+command_args="$@"
usage() {
- echo "usage: $0 [-q|--quiet] [-v|--verbose] [--] <command> [repo_base_path]" > ${status_output}
+ echo "usage: $0 [-q|--quiet] [-v|--verbose] [--] <command> [commands...]" > ${status_output}
exit 1
}
if [ "x" = "x$command" ] ; then
@@ -112,29 +112,33 @@
# Only look in specific locations for possible forests (avoids long searches)
pull_default=""
repos=""
repos_extra=""
if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
- if [ -f .hg/hgrc ] ; then
+ if [ ! -f .hg/hgrc ] ; then
+ echo "ERROR: Need initial repository to use this script" > ${status_output}
+ exit 1
+ fi
+
pull_default=`hg paths default`
if [ "${pull_default}" = "" ] ; then
echo "ERROR: Need initial clone with 'hg paths default' defined" > ${status_output}
exit 1
fi
- fi
- if [ "${pull_default}" = "" ] ; then
- echo "ERROR: Need initial repository to use this script" > ${status_output}
+ pull_default_tail=`echo ${pull_default} | sed -e 's@^.*://[^/]*/\(.*\)@\1@'`
+ if [ "x${pull_default}" = "x${pull_default_tail}" ] ; then
+ echo "ERROR: Need initial clone from non-local source" > ${status_output}
exit 1
fi
+
for i in ${subrepos} ; do
if [ ! -f ${i}/.hg/hgrc ] ; then
repos="${repos} ${i}"
fi
done
- if [ "${repo_base}" != "" ] ; then
- pull_default_tail=`echo ${pull_default} | sed -e 's@^.*://[^/]*/\(.*\)@\1@'`
- pull_extra="${repo_base}/${pull_default_tail}"
+ if [ "${command_args}" != "" ] ; then
+ pull_extra="${command_args}/${pull_default_tail}"
for i in ${subrepos_extra} ; do
if [ ! -f ${i}/.hg/hgrc ] ; then
repos_extra="${repos_extra} ${i}"
fi
done
@@ -229,12 +233,12 @@
sleep 5
done
fi
(PYTHONUNBUFFERED=true hg${global_opts} clone ${pull_newrepo} ${i}; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
else
- echo "cd ${i} && hg${global_opts} ${command} ${repo_base}" > ${status_output}
- cd ${i} && (PYTHONUNBUFFERED=true hg${global_opts} ${command} ${command_repo}; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
+ echo "cd ${i} && hg${global_opts} ${command} ${command_args}" > ${status_output}
+ cd ${i} && (PYTHONUNBUFFERED=true hg${global_opts} ${command} ${command_args}; echo "$?" > ${tmp}/${repopidfile}.pid.rc ) 2>&1 &
fi
echo $! > ${tmp}/${repopidfile}.pid
) 2>&1 | sed -e "s@^@${reponame}: @" > ${status_output}
) &