;;
esac
+mj_init() {
+ pipe=$(mktemp)
+ rm -f "${pipe}"
+ mkfifo "${pipe}"
+ exec {ctlfd}<>"${pipe}"
+ rm -f "${pipe}"
+ jobs=0
+ jobs_max=${1:-$(getconf _NPROCESSORS_ONLN)}
+}
+_mj_child() { echo ${BASHPID} $? >&${ctlfd} ; }
+mj_child() {
+ (
+ "$@"
+ _mj_child
+ ) &
+ mj_post_child
+}
+mj_post_child() {
+ : $(( ++jobs ))
+ if [[ ${jobs} -eq ${jobs_max} ]] ; then
+ read -r -u ${ctlfd} pid ret
+ : $(( --jobs ))
+ fi
+}
+mj_finish() {
+ wait
+}
+
+repo_root() {
+ local root=${PWD}
+ while [[ ! -d ${root}/.repo && ${root} != "/" ]] ; do
+ root=${root%/*}
+ done
+ echo "${root}"
+}
+
case ${acmd:-${cmd}} in
rebase)
if [[ $1 == "all" ]] ; then
shift
if [[ $# -eq 0 ]] ; then
- exec r forall -p -c 'r rb all .' </dev/null
+ root=$(repo_root)
+ mj_init
+ while read -a line ; do
+ dir=${line[0]}
+ proj=${line[2]}
+ cd "${root}/${dir}"
+ (
+ out=$(r rb all . 2>&1)
+ [[ -n ${out} ]] && echo "${out}"
+ _mj_child
+ ) &
+ mj_post_child
+ done < <(r l)
+ mj_finish
+ exit 0
+ #exec r forall -p -c 'r rb all .' </dev/null
fi
branches=$(g b | awk '
eval $(bash-colors --env)
#echo "${GOOD}### ${PWD}${NORMAL}"
for b in ${branches} ; do
- echo " ${HILITE}### $b${NORMAL}"
+ #echo " ${HILITE}### $b${NORMAL}"
g co -q $b || exit 1
- if ! r rb "$@" ; then
+ if ! r rb -q "$@" ; then
g rb-a
fi
done
sb-push)
sync_branch="v"
- root=${PWD}
- while [[ ! -d ${root}/.repo && ${root} != "/" ]] ; do
- root=${root%/*}
- done
+ root=$(repo_root)
cd "${root}" || exit 1
if [[ ! -e .repo/sandbox-url ]] ; then
echo "pushing projects from ${root}"
- pipe=$(mktemp)
- rm -f "${pipe}"
- mkfifo "${pipe}"
- exec {ctlfd}<>"${pipe}"
- rm -f "${pipe}"
- jobs=0
+ # ssh servers do not like it when you hammer them :)
+ # Received disconnect from 74.125.248.80: 7: Too many concurrent connections
+ # fatal: The remote end hung up unexpectedly
+ mj_init 16
rlist=$(r list)
tcnt=$(echo "${rlist}" | wc -l)
${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj}
src="${sync_branch}"
g l -1 ${src} >& /dev/null || src=
- (
- g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null
- echo ${BASHPID} $? >&${ctlfd}
- ) &
-
- # ssh servers do not like it when you hammer them :)
- # Received disconnect from 74.125.248.80: 7: Too many concurrent connections
- # fatal: The remote end hung up unexpectedly
- : $(( ++jobs ))
- if [[ ${jobs} -eq 16 ]] ; then
- read -r -u ${ctlfd} pid ret
- : $(( --jobs ))
- fi
+ mj_child g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null
done < <(r list)
- wait
+ mj_finish
exit 0
;;