ohair@276: #!/bin/sh ohair@276: ohair@276: # mduigou@1146: # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. ohair@276: # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@276: # ohair@276: # This code is free software; you can redistribute it and/or modify it ohair@276: # under the terms of the GNU General Public License version 2 only, as ohair@276: # published by the Free Software Foundation. Oracle designates this ohair@276: # particular file as subject to the "Classpath" exception as provided ohair@276: # by Oracle in the LICENSE file that accompanied this code. ohair@276: # ohair@276: # This code is distributed in the hope that it will be useful, but WITHOUT ohair@276: # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@276: # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@276: # version 2 for more details (a copy is included in the LICENSE file that ohair@276: # accompanied this code). ohair@276: # ohair@276: # You should have received a copy of the GNU General Public License version ohair@276: # 2 along with this work; if not, write to the Free Software Foundation, ohair@276: # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@276: # ohair@276: # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@276: # or visit www.oracle.com if you need additional information or have any ohair@276: # questions. ohair@276: # ohair@276: mduigou@1147: to_stderr() { mduigou@1147: echo "$@" >&2 mduigou@1147: } mduigou@1147: mduigou@1147: error() { mduigou@1147: to_stderr "ERROR: $1" mduigou@1147: exit ${2:-126} mduigou@1147: } mduigou@1147: mduigou@1147: warning() { mduigou@1147: to_stderr "WARNING: $1" mduigou@1147: } mduigou@1147: mduigou@1147: version_field() { mduigou@1147: # rev is typically omitted for minor and major releases mduigou@1147: field=`echo ${1}.0 | cut -f ${2} -d .` mduigou@1147: if expr 1 + $field >/dev/null 2> /dev/null; then mduigou@1147: echo $field mduigou@1147: else mduigou@1147: echo -1 mduigou@1147: fi mduigou@1147: } mduigou@1147: mduigou@1146: # Version check mduigou@1146: mduigou@1146: # required mduigou@1146: reqdmajor=1 mduigou@1147: reqdminor=4 mduigou@1146: reqdrev=0 mduigou@1146: mduigou@1146: # requested mduigou@1146: rqstmajor=2 mduigou@1146: rqstminor=6 mduigou@1146: rqstrev=3 mduigou@1146: mduigou@1147: mduigou@1146: # installed mduigou@1147: hgwhere="`command -v hg`" mduigou@1146: if [ "x$hgwhere" = "x" ]; then mduigou@1147: error "Could not locate Mercurial command" mduigou@1146: fi mduigou@1146: mduigou@1741: hgversion="`LANGUAGE=en hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`" mduigou@1146: if [ "x${hgversion}" = "x" ] ; then mduigou@1147: error "Could not determine Mercurial version of $hgwhere" mduigou@1146: fi mduigou@1146: mduigou@1147: hgmajor="`version_field $hgversion 1`" mduigou@1147: hgminor="`version_field $hgversion 2`" mduigou@1147: hgrev="`version_field $hgversion 3`" mduigou@1147: mduigou@1147: if [ $hgmajor -eq -1 -o $hgminor -eq -1 -o $hgrev -eq -1 ] ; then mduigou@1147: error "Could not determine Mercurial version of $hgwhere from \"$hgversion\"" mduigou@1147: fi mduigou@1147: mduigou@1146: mduigou@1146: # Require mduigou@1146: 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 mduigou@1147: error "Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion" mduigou@1146: fi mduigou@1146: mduigou@1147: mduigou@1146: # Request mduigou@1146: 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 mduigou@1147: warning "Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion" mduigou@1146: fi mduigou@1146: mduigou@1147: mduigou@1146: # Get clones of all absent nested repositories (harmless if already exist) mduigou@1146: sh ./common/bin/hgforest.sh clone "$@" || exit $? ohair@276: ohair@276: # Update all existing repositories to the latest sources ohrstrom@538: sh ./common/bin/hgforest.sh pull -u