Kelly O'Hair | 213481a | 2010-12-22 12:25:52 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 4 | # Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. |
Kelly O'Hair | 213481a | 2010-12-22 12:25:52 -0800 | [diff] [blame] | 5 | # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 6 | # |
| 7 | # This code is free software; you can redistribute it and/or modify it |
| 8 | # under the terms of the GNU General Public License version 2 only, as |
| 9 | # published by the Free Software Foundation. Oracle designates this |
| 10 | # particular file as subject to the "Classpath" exception as provided |
| 11 | # by Oracle in the LICENSE file that accompanied this code. |
| 12 | # |
| 13 | # This code is distributed in the hope that it will be useful, but WITHOUT |
| 14 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 16 | # version 2 for more details (a copy is included in the LICENSE file that |
| 17 | # accompanied this code). |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License version |
| 20 | # 2 along with this work; if not, write to the Free Software Foundation, |
| 21 | # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | # |
| 23 | # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 24 | # or visit www.oracle.com if you need additional information or have any |
| 25 | # questions. |
| 26 | # |
| 27 | |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 28 | to_stderr() { |
| 29 | echo "$@" >&2 |
| 30 | } |
| 31 | |
| 32 | error() { |
| 33 | to_stderr "ERROR: $1" |
| 34 | exit ${2:-126} |
| 35 | } |
| 36 | |
| 37 | warning() { |
| 38 | to_stderr "WARNING: $1" |
| 39 | } |
| 40 | |
| 41 | version_field() { |
| 42 | # rev is typically omitted for minor and major releases |
| 43 | field=`echo ${1}.0 | cut -f ${2} -d .` |
| 44 | if expr 1 + $field >/dev/null 2> /dev/null; then |
| 45 | echo $field |
| 46 | else |
| 47 | echo -1 |
| 48 | fi |
| 49 | } |
| 50 | |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 51 | # Version check |
| 52 | |
| 53 | # required |
| 54 | reqdmajor=1 |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 55 | reqdminor=4 |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 56 | reqdrev=0 |
| 57 | |
| 58 | # requested |
| 59 | rqstmajor=2 |
| 60 | rqstminor=6 |
| 61 | rqstrev=3 |
| 62 | |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 63 | |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 64 | # installed |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 65 | hgwhere="`command -v hg`" |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 66 | if [ "x$hgwhere" = "x" ]; then |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 67 | error "Could not locate Mercurial command" |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 68 | fi |
| 69 | |
Shinya Yoshida | dd9ba70 | 2014-08-21 10:22:52 -0700 | [diff] [blame] | 70 | hgversion="`LANGUAGE=en hg --version 2> /dev/null | sed -n -e 's@^Mercurial Distributed SCM (version \([^+]*\).*)\$@\1@p'`" |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 71 | if [ "x${hgversion}" = "x" ] ; then |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 72 | error "Could not determine Mercurial version of $hgwhere" |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 73 | fi |
| 74 | |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 75 | hgmajor="`version_field $hgversion 1`" |
| 76 | hgminor="`version_field $hgversion 2`" |
| 77 | hgrev="`version_field $hgversion 3`" |
| 78 | |
| 79 | if [ $hgmajor -eq -1 -o $hgminor -eq -1 -o $hgrev -eq -1 ] ; then |
| 80 | error "Could not determine Mercurial version of $hgwhere from \"$hgversion\"" |
| 81 | fi |
| 82 | |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 83 | |
| 84 | # Require |
| 85 | 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 |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 86 | error "Mercurial version $reqdmajor.$reqdminor.$reqdrev or later is required. $hgwhere is version $hgversion" |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 87 | fi |
| 88 | |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 89 | |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 90 | # Request |
| 91 | 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 |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 92 | warning "Mercurial version $rqstmajor.$rqstminor.$rqstrev or later is recommended. $hgwhere is version $hgversion" |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 93 | fi |
| 94 | |
Mike Duigou | c785286 | 2014-07-08 11:21:43 -0700 | [diff] [blame] | 95 | |
Mike Duigou | 90e98e4 | 2014-06-24 15:21:47 -0700 | [diff] [blame] | 96 | # Get clones of all absent nested repositories (harmless if already exist) |
| 97 | sh ./common/bin/hgforest.sh clone "$@" || exit $? |
Kelly O'Hair | 213481a | 2010-12-22 12:25:52 -0800 | [diff] [blame] | 98 | |
| 99 | # Update all existing repositories to the latest sources |
Fredrik Öhrström | ccafa0b | 2012-12-18 09:57:01 +0100 | [diff] [blame] | 100 | sh ./common/bin/hgforest.sh pull -u |