make/scripts/hgforest.sh

changeset 436
955a3e8ed4f0
parent 276
dc9eb519c6ed
child 437
8a4e92c10a9a
     1.1 --- a/make/scripts/hgforest.sh	Wed May 09 16:12:35 2012 -0700
     1.2 +++ b/make/scripts/hgforest.sh	Thu May 10 08:26:26 2012 -0700
     1.3 @@ -1,7 +1,7 @@
     1.4  #!/bin/sh
     1.5  
     1.6  #
     1.7 -# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
     1.8 +# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
     1.9  # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    1.10  #
    1.11  # This code is free software; you can redistribute it and/or modify it
    1.12 @@ -24,6 +24,8 @@
    1.13  #
    1.14  
    1.15  # Shell script for a fast parallel forest command
    1.16 +command="$1"
    1.17 +pull_extra_base="$2"
    1.18  
    1.19  tmp=/tmp/forest.$$
    1.20  rm -f -r ${tmp}
    1.21 @@ -35,40 +37,58 @@
    1.22  
    1.23  # Only look in specific locations for possible forests (avoids long searches)
    1.24  pull_default=""
    1.25 -if [ "$1" = "clone" -o "$1" = "fclone" ] ; then
    1.26 +repos=""
    1.27 +repos_extra=""
    1.28 +if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
    1.29    subrepos="corba jaxp jaxws langtools jdk hotspot"
    1.30    if [ -f .hg/hgrc ] ; then
    1.31      pull_default=`hg paths default`
    1.32 +    if [ "${pull_default}" = "" ] ; then
    1.33 +      echo "ERROR: Need initial clone with 'hg paths default' defined"
    1.34 +      exit 1
    1.35 +    fi
    1.36    fi
    1.37    if [ "${pull_default}" = "" ] ; then
    1.38 -    echo "ERROR: Need initial clone with 'hg paths default' defined"
    1.39 +    echo "ERROR: Need initial repository to use this script"
    1.40      exit 1
    1.41    fi
    1.42 -  repos=""
    1.43    for i in ${subrepos} ; do
    1.44      if [ ! -f ${i}/.hg/hgrc ] ; then
    1.45        repos="${repos} ${i}"
    1.46      fi
    1.47    done
    1.48 +  if [ "${pull_extra_base}" != "" ] ; then
    1.49 +    subrepos_extra="jdk/src/closed jdk/make/closed jdk/test/closed hotspot/src/closed hotspot/test/closed deploy install sponsors pubs"
    1.50 +    pull_default_base=`echo ${pull_default} | sed -e 's@\(^.*://[^/]*\)/.*@\1@'`
    1.51 +    pull_extra=`echo ${pull_default} | sed -e "s@${pull_default_base}@${pull_extra_base}@"`
    1.52 +    for i in ${subrepos_extra} ; do
    1.53 +      if [ ! -f ${i}/.hg/hgrc ] ; then
    1.54 +        repos_extra="${repos_extra} ${i}"
    1.55 +      fi
    1.56 +    done
    1.57 +  fi
    1.58    at_a_time=2
    1.59 +  # Any repos to deal with?
    1.60 +  if [ "${repos}" = "" -a "${repos_extra}" = "" ] ; then
    1.61 +    echo "No repositories to clone."
    1.62 +    exit
    1.63 +  fi
    1.64  else
    1.65    hgdirs=`ls -d ./.hg ./*/.hg ./*/*/.hg ./*/*/*/.hg ./*/*/*/*/.hg 2>/dev/null`
    1.66    # Derive repository names from the .hg directory locations
    1.67 -  repos=""
    1.68    for i in ${hgdirs} ; do
    1.69      repos="${repos} `echo ${i} | sed -e 's@/.hg$@@'`"
    1.70    done
    1.71    at_a_time=8
    1.72 +  # Any repos to deal with?
    1.73 +  if [ "${repos}" = "" ] ; then
    1.74 +    echo "No repositories to process."
    1.75 +    exit
    1.76 +  fi
    1.77  fi
    1.78  
    1.79 -# Any repos to deal with?
    1.80 -if [ "${repos}" = "" ] ; then
    1.81 -  echo "No repositories to process."
    1.82 -  exit
    1.83 -fi
    1.84 -
    1.85 -# Echo out what repositories we will process
    1.86 -echo "# Repos: ${repos}"
    1.87 +# Echo out what repositories we will clone
    1.88 +echo "# Repos: ${repos} ${repos_extra}"
    1.89  
    1.90  # Run the supplied command on all repos in parallel, save output until end
    1.91  n=0
    1.92 @@ -77,8 +97,8 @@
    1.93    n=`expr ${n} '+' 1`
    1.94    (
    1.95      (
    1.96 -      if [ "$1" = "clone" -o "$1" = "fclone" ] ; then
    1.97 -        cline="hg $* ${pull_default}/${i} ${i}"
    1.98 +      if [ "${command}" = "clone" -o "${command}" = "fclone" ] ; then
    1.99 +        cline="hg clone ${pull_default}/${i} ${i}"
   1.100          echo "# ${cline}"
   1.101          ( eval "${cline}" )
   1.102        else
   1.103 @@ -92,6 +112,22 @@
   1.104      sleep 5
   1.105    fi
   1.106  done
   1.107 +if [ "${repos_extra}" != "" ] ; then
   1.108 +  for i in ${repos_extra} ; do
   1.109 +    echo "Starting on ${i}"
   1.110 +    n=`expr ${n} '+' 1`
   1.111 +    (
   1.112 +      (
   1.113 +          cline="hg clone ${pull_extra}/${i} ${i}"
   1.114 +          echo "# ${cline}"
   1.115 +          ( eval "${cline}" )
   1.116 +        echo "# exit code $?"
   1.117 +      ) > ${tmp}/repo.${n} 2>&1 ; cat ${tmp}/repo.${n} ) &
   1.118 +    if [ `expr ${n} '%' ${at_a_time}` -eq 0 ] ; then
   1.119 +      sleep 5
   1.120 +    fi
   1.121 +  done
   1.122 +fi
   1.123  
   1.124  # Wait for all hg commands to complete
   1.125  wait

mercurial