visit_svn_helper 4.33 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

##
##
## Check to make sure that environment variables are set
##
##

if [[ "$SVN_NERSC_NAME" == "" ]] ; then
   echo "You must define the environment variable SVN_NERSC_NAME to use these scripts."
   echo "This should be your username on svn.nersc.gov"
   exit 1
fi


##
##
## Set up environment variables for other scripts
##
##

VISIT_SVN_REPO=svn+ssh://${SVN_NERSC_NAME}@svn.nersc.gov/svn/visit
VISIT_SVN_BRANCHES=${VISIT_SVN_REPO}/branches
VISIT_SVN_TRUNK=${VISIT_SVN_REPO}/trunk
VISIT_SVN_TAGS=${VISIT_SVN_REPO}/tags


##
##
## Define utility functions
##
##

33 34 35 36 37
function get_latest_rev
{
    # This assumes a certain format for SVN log.  It gets the second line,
    # which has "r<REV> | ...", and then strips off the "| ...", and then 
    # strips off the 'r'.
38 39 40 41
    # first check for old non posix tail command
    if [ $(uname -s) != "SunOS" ] ; then
    REV=$(svn log $VISIT_SVN_REPO --revision HEAD | head -n 2 | tail -n 1 | cut -d'|' -f1 | sed 's/r//g')
    else
42
    REV=$(svn log $VISIT_SVN_REPO --revision HEAD | head -2 | tail -1 | cut -d'|' -f1 | sed 's/r//g')
43
    fi
44 45 46 47 48 49 50 51 52 53
    if (( REV < 950 )) ; then
       echo "An error occurred in getting revision!!" >&2
       echo "Pursue this problem with a VisIt-SVN guru" >&2
       echo "1000000"
    else
       echo $REV
    fi
}


54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
# Note that the is_version_string test would fail for numbers bigger than 9,
# such as 1.6.10.  If this ever comes up, it should be easy to fix.
function is_version_string
{
    if [[ ${#1} == 3 ]] ; then
       is_two_digit_version_string $1
       return $?
    elif [[ ${#1} == 5 ]] ; then
       is_three_digit_version_string $1
       return $?
    fi

    return 0
}

function is_two_digit_version_string
{
    if [[ ${#1} != 3 ]] ; then
        return 0
    fi

    typeset X
    typeset -L1 X=$1
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    typeset -L2 X=$1
    typeset -R1 X
    if [[ "$X" != "." ]] ; then
        return 0
    fi

    typeset -L3 X=$1
    typeset -R1 X
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    return 1
}

function is_three_digit_version_string
{
    if [[ ${#1} != 5 ]] ; then
        return 0
    fi

    typeset X
    typeset -L1 X=$1
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    typeset -L2 X=$1
    typeset -R1 X
    if [[ "$X" != "." ]] ; then
        return 0
    fi

    typeset -L3 X=$1
    typeset -R1 X
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    typeset -L4 X=$1
    typeset -R1 X
    if [[ "$X" != "." ]] ; then
        return 0
    fi

    typeset -L5 X=$1
    typeset -R1 X
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    return 1
}

function is_four_digit_version_string
{
    if [[ ${#1} != 7 ]] ; then
        return 0
    fi

    typeset X
    typeset -L1 X=$1
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    typeset -L2 X=$1
    typeset -R1 X
    if [[ "$X" != "." ]] ; then
        return 0
    fi

    typeset -L3 X=$1
    typeset -R1 X
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    typeset -L4 X=$1
    typeset -R1 X
    if [[ "$X" != "." ]] ; then
        return 0
    fi

    typeset -L5 X=$1
    typeset -R1 X
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    typeset -L6 X=$1
    typeset -R1 X
    if [[ "$X" != "." ]] ; then
        return 0
    fi

    typeset -L7 X=$1
    typeset -R1 X
    if [[ "$X" != [0-9] ]] ; then
        return 0
    fi

    return 1
}


function svn_cp_dir
{
   SRC=$1
   DEST=$2

   # Confirm presence of $SRC
   svn ls $SRC 2>/dev/null > /dev/null
   if [[ $? != 0 ]] ; then
      echo "Cannot locate release candidate ($SRC) for copying.  Aborting!"
hrchilds's avatar
hrchilds committed
196
      echo "(Try using ls_branches to locate the directory.)"
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
      exit 1
   fi

   # Confirm that $DEST does not already exist
   svn ls $DEST 2>/dev/null > /dev/null
   if [[ $? == 0 ]] ; then
      echo "Destination ($DEST) already exists.  Aborting!"
      exit 1
   fi

   echo "Creating ${DEST}...."
   svn copy $SRC $DEST -m "Making copy of $SRC as $DEST"
   if [[ $? == 0 ]] ; then
      echo "Successful."
   else
      echo "Not successful."
      exit 1
   fi
}


function svn_rm_dir
{
   DIR=$1
   # Confirm presence of $DIR
   svn ls $DIR 2>/dev/null > /dev/null
   if [[ $? != 0 ]] ; then
      echo "Cannot locate release candidate ($DIR) for deleting.  Aborting!"
      exit 1
   fi

   svn delete $DIR -m "Removing directory $DIR"
   return $?
}