get_source.sh

changeset 1146
406ecd8cce66
parent 615
8dd61906da5f
child 1147
ec58dd8b23b6
     1.1 --- a/get_source.sh	Tue May 06 13:24:51 2014 -0700
     1.2 +++ b/get_source.sh	Tue Jun 24 15:21:47 2014 -0700
     1.3 @@ -1,7 +1,7 @@
     1.4  #!/bin/sh
     1.5  
     1.6  #
     1.7 -# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
     1.8 +# Copyright (c) 2010, 2014, 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 @@ -25,9 +25,48 @@
    1.13  # questions.
    1.14  #
    1.15  
    1.16 -# Get clones of all nested repositories
    1.17 -sh ./common/bin/hgforest.sh clone "$@" || exit 1
    1.18 +# Version check
    1.19 +
    1.20 +# required
    1.21 +reqdmajor=1
    1.22 +reqdminor=5
    1.23 +reqdrev=0
    1.24 +
    1.25 +# requested
    1.26 +rqstmajor=2
    1.27 +rqstminor=6
    1.28 +rqstrev=3
    1.29 +
    1.30 +# installed
    1.31 +hgwhere="`which hg 2> /dev/null | grep -v '^no hg in '`"
    1.32 +if [ "x$hgwhere" = "x" ]; then
    1.33 +  echo "ERROR: Could not locate Mercurial command" >&2
    1.34 +  exit 126
    1.35 +fi
    1.36 +
    1.37 +hgversion="`hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \(.*\))\$@\1@p'`"
    1.38 +if [ "x${hgversion}" = "x" ] ; then
    1.39 +  echo "ERROR: Could not determine Mercurial version" >&2
    1.40 +  exit 126
    1.41 +fi
    1.42 +
    1.43 +hgmajor="`echo $hgversion | cut -f 1 -d .`"
    1.44 +hgminor="`echo $hgversion | cut -f 2 -d .`"
    1.45 +hgrev="`echo $hgversion.0 | cut -f 3 -d .`" # rev is omitted for minor and major releases
    1.46 +
    1.47 +# Require
    1.48 +if [ $hgmajor -lt $reqdmajor -o \( $hgmajor -eq $reqdmajor -a $hgminor -lt $reqdminor \) -o \( $hgmajor -eq $reqdmajor -a $hgminor -eq $reqdminor -a $hgrev -lt $reqdrev \) ] ; then
    1.49 +  echo "ERROR: Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion" >&2
    1.50 +  exit 126
    1.51 +fi
    1.52 +
    1.53 +# Request
    1.54 +if [ $hgmajor -lt $rqstmajor -o \( $hgmajor -eq $rqstmajor -a $hgminor -lt $rqstminor \) -o \( $hgmajor -eq $rqstmajor -a $hgminor -eq $rqstminor -a $hgrev -lt $rqstrev \) ] ; then
    1.55 +  echo "WARNING: Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion" >&2
    1.56 +fi
    1.57 +
    1.58 +# Get clones of all absent nested repositories (harmless if already exist)
    1.59 +sh ./common/bin/hgforest.sh clone "$@" || exit $?
    1.60  
    1.61  # Update all existing repositories to the latest sources
    1.62  sh ./common/bin/hgforest.sh pull -u
    1.63 -

mercurial