1#!/bin/sh 2#===-- merge.sh - Test the LLVM release candidates -------------------------===# 3# 4# The LLVM Compiler Infrastructure 5# 6# This file is distributed under the University of Illinois Open Source 7# License. 8# 9#===------------------------------------------------------------------------===# 10# 11# Merge a revision into a project. 12# 13#===------------------------------------------------------------------------===# 14 15set -e 16 17rev="" 18proj="" 19revert="no" 20srcdir="" 21 22usage() { 23 echo "usage: `basename $0` [OPTIONS]" 24 echo " -proj PROJECT The project to merge the result into" 25 echo " -rev NUM The revision to merge into the project" 26 echo " -revert Revert rather than merge the commit" 27 echo " -srcdir The root of the project checkout" 28} 29 30while [ $# -gt 0 ]; do 31 case $1 in 32 -rev | --rev | -r ) 33 shift 34 rev=$1 35 ;; 36 -proj | --proj | -project | --project | -p ) 37 shift 38 proj=$1 39 ;; 40 --srcdir | -srcdir | -s) 41 shift 42 srcdir=$1 43 ;; 44 -h | -help | --help ) 45 usage 46 ;; 47 -revert | --revert ) 48 revert="yes" 49 ;; 50 * ) 51 echo "unknown option: $1" 52 echo "" 53 usage 54 exit 1 55 ;; 56 esac 57 shift 58done 59 60if [ -z "$srcdir" ]; then 61 srcdir="$proj.src" 62fi 63 64if [ "x$rev" = "x" -o "x$proj" = "x" ]; then 65 echo "error: need to specify project and revision" 66 echo 67 usage 68 exit 1 69fi 70 71if ! svn ls http://llvm.org/svn/llvm-project/$proj/trunk > /dev/null 2>&1 ; then 72 echo "error: invalid project: $proj" 73 exit 1 74fi 75 76tempfile=`mktemp /tmp/merge.XXXXXX` || exit 1 77 78if [ $revert = "yes" ]; then 79 echo "Reverting r$rev:" > $tempfile 80else 81 echo "Merging r$rev:" > $tempfile 82fi 83svn log -c $rev http://llvm.org/svn/llvm-project/$proj/trunk >> $tempfile 2>&1 84 85cd "$srcdir" 86echo "# Updating tree" 87svn up 88 89if [ $revert = "yes" ]; then 90 echo "# Reverting r$rev in $proj locally" 91 svn merge -c -$rev . || exit 1 92else 93 echo "# Merging r$rev into $proj locally" 94 svn merge -c $rev https://llvm.org/svn/llvm-project/$proj/trunk . || exit 1 95fi 96 97echo 98echo "# To commit, run the following in $srcdir/:" 99echo svn commit -F $tempfile 100 101exit 0 102