common/bin/hgforest.sh
changeset 23436 90d12e975106
parent 23427 abbf38fbeb4c
child 23989 da174d121fd3
equal deleted inserted replaced
23435:098340eccdcb 23436:90d12e975106
    27 
    27 
    28 global_opts=""
    28 global_opts=""
    29 status_output="/dev/stdout"
    29 status_output="/dev/stdout"
    30 qflag="false"
    30 qflag="false"
    31 vflag="false"
    31 vflag="false"
       
    32 sflag="false"
    32 while [ $# -gt 0 ]
    33 while [ $# -gt 0 ]
    33 do
    34 do
    34   case $1 in
    35   case $1 in
    35     -q | --quiet )
    36     -q | --quiet )
    36       qflag="true"
    37       qflag="true"
    41     -v | --verbose )
    42     -v | --verbose )
    42       vflag="true"
    43       vflag="true"
    43       global_opts="${global_opts} -v"
    44       global_opts="${global_opts} -v"
    44       ;;
    45       ;;
    45 
    46 
       
    47     -s | --sequential )
       
    48       sflag="true"
       
    49       ;;
       
    50 
    46     '--' ) # no more options
    51     '--' ) # no more options
    47       shift; break
    52       shift; break
    48       ;;
    53       ;;
    49 
    54 
    50     -*)  # bad option
    55     -*)  # bad option
    61 
    66 
    62 command="$1"; shift
    67 command="$1"; shift
    63 command_args="$@"
    68 command_args="$@"
    64 
    69 
    65 usage() {
    70 usage() {
    66       echo "usage: $0 [-q|--quiet] [-v|--verbose] [--] <command> [commands...]" > ${status_output}
    71       echo "usage: $0 [-q|--quiet] [-v|--verbose] [-s|--sequential] [--] <command> [commands...]" > ${status_output}
    67       exit 1
    72       exit 1
    68 }
    73 }
    69 
    74 
    70 
    75 
    71 if [ "x" = "x$command" ] ; then
    76 if [ "x" = "x$command" ] ; then
   241 
   246 
   242         echo $! > ${tmp}/${repopidfile}.pid
   247         echo $! > ${tmp}/${repopidfile}.pid
   243       ) 2>&1 | sed -e "s@^@${reponame}:   @" > ${status_output}
   248       ) 2>&1 | sed -e "s@^@${reponame}:   @" > ${status_output}
   244     ) &
   249     ) &
   245 
   250 
   246     if [ `expr ${n} '%' ${at_a_time}` -eq 0 ] ; then
   251     if [ `expr ${n} '%' ${at_a_time}` -eq 0 -a "${sflag}" = "false" ] ; then
   247       sleep 2
   252       sleep 2
   248       echo "Waiting 5 secs before spawning next background command." > ${status_output}
   253       echo "Waiting 5 secs before spawning next background command." > ${status_output}
   249       sleep 3
   254       sleep 3
       
   255     fi
       
   256 
       
   257     if [ "${sflag}" = "true" ] ; then
       
   258         wait
   250     fi
   259     fi
   251   done
   260   done
   252 fi
   261 fi
   253 
   262 
   254 # Wait for all hg commands to complete
   263 # Wait for all hg commands to complete