Commit c1200a85 authored by szager@google.com's avatar szager@google.com

Keep the parallel execution pipes full as much as possible.

Rearrange some of the pipe redirections to avoid crashing on Windows.

TBR=cmp@chromium.org
Review URL: https://codereview.chromium.org/11260036

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@164140 0039d316-1c4b-4281-b951-d872f2087c98
parent 259e4689
#!/bin/bash
if [ -z "$*" ]; then
exit 0
fi
set -o pipefail
dir="$1"
solution="${1%%/*}"
cd "$solution"
if [ "$solution" = "$1" ]; then
shift
$@ | sed "s/^/[$solution] /g" 1>&2
if [ $? -ne 0 ]; then
exit $?
fi
"$GIT_EXE" submodule --quiet sync
"$GIT_EXE" ls-files -s | grep ^160000 | awk '{print $4}' |
sed "s/^/$solution\//g"
status=$?
else
submodule="${1#*/}"
echo "[$solution] updating $submodule ..."
"$GIT_EXE" submodule update --quiet --init "$submodule" |
( grep -v '^Skipping submodule' || true ) | sed "s|^|[$1] |g"
status=$?
if [ "$status" -ne "0" ]; then
echo "[$solution] FAILED to update $submodule"
fi
fi
exit $status
...@@ -7,11 +7,22 @@ ...@@ -7,11 +7,22 @@
# submodule-based checkout. Fetches latest commits for top-level solutions; # submodule-based checkout. Fetches latest commits for top-level solutions;
# updates submodules; and runs post-sync hooks. # updates submodules; and runs post-sync hooks.
j=10 export GIT_MERGE_AUTOEDIT=0
ECHO= ECHO=
pull=pull pull=pull
pull_args= pull_args=
hooks=yes hooks=yes
j=10
crup_runner="crup-runner.sh"
kernel_name=$(uname -s)
if [ "${kernel_name:0:5}" = "MINGW" -o "${kernel_name:0:6}" = "CYGWIN" ]; then
GIT_EXE=git.exe
else
GIT_EXE=git
fi
export GIT_EXE
if ( echo test | xargs --max-lines=1 true 2>/dev/null ); then if ( echo test | xargs --max-lines=1 true 2>/dev/null ); then
max_lines="--max-lines=1" max_lines="--max-lines=1"
...@@ -19,24 +30,31 @@ else ...@@ -19,24 +30,31 @@ else
max_lines="-L 1" max_lines="-L 1"
fi fi
if ( echo test | xargs -I bar true 2>/dev/null ); then
replace_arg="-I replace_arg"
else
replace_arg="-ireplace_arg"
fi
usage() { usage() {
cat <<EOF 1>&2 cat <<EOF
Usage: git-crup [-n|--dry-run] [--fetch] [-j|--jobs [jobs]] Usage: git-crup [-n|--dry-run] [--fetch] [-j|--jobs [jobs]]
[--no-hooks] [<args to git-pull or git-fetch>] [--no-hooks] [<args to git-pull or git-fetch>]
EOF EOF
} }
parallel_update() { serial_update() {
( echo Entering "$1" ( cd "$1"
cd "$1" $GIT_EXE $pull $pull_args -q origin | sed "s/^/[$1] /g"
$ECHO git $pull $pull_args origin if [ $? -ne 0 ]; then
$ECHO git submodule sync return $?
if test "$xargs_parallel" = "yes"; then fi
git ls-files -s | grep ^160000 | awk '{print $4}' | $GIT_EXE submodule --quiet sync
xargs $max_lines -P "$j" $ECHO git submodule update --init $GIT_EXE ls-files -s | grep ^160000 | awk '{print $4}' |
else while read submod; do
$ECHO git submodule update --init $GIT_EXE submodule update --init "$submod" | sed "s|^|[$1/$submod] |g"
fi ) done
)
} }
while test $# -ne 0; do while test $# -ne 0; do
...@@ -68,7 +86,7 @@ while test $# -ne 0; do ...@@ -68,7 +86,7 @@ while test $# -ne 0; do
--fetch) --fetch)
pull=fetch pull=fetch
;; ;;
--no-hooks) --no-hooks|--nohooks)
hooks=no hooks=no
;; ;;
*) *)
...@@ -99,10 +117,27 @@ else ...@@ -99,10 +117,27 @@ else
xargs_parallel=no xargs_parallel=no
fi fi
ls -d */.git | set -o pipefail
while read gitdir; do
parallel_update `dirname $gitdir` if test "$xargs_parallel" = "yes"; then
done ( ls -d */.git | sed 's/\/\.git$//' |
xargs $max_lines $replace_arg -P "$j" \
"$crup_runner" replace_arg $GIT_EXE $pull $pull_args -q origin |
xargs $max_lines -P "$j" "$crup_runner" )
else
ls -d */.git |
while read gitdir; do
serial_update "${gitdir%%/.git}"
done
fi
status=$?
if [ "$hooks" = "yes" -a "$status" -eq 0 ]; then
gclient_spec="solutions=[{'name':'src','url':None,'deps_file':'.DEPS.git'}]"
gclient runhooks --spec="$gclient_spec"
status=$?
fi
gclient_spec="solutions=[{'name':'src','url':None,'deps_file':'.DEPS.git'}]" echo
test "$hooks" = "yes" && gclient runhooks --spec="$gclient_spec" exit $status
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment