Revert r245355 "Release script: correctly symlink clang-tools-extra into the build...
[oota-llvm.git] / utils / release / merge.sh
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
15 set -e
16
17 rev=""
18 proj=""
19 revert="no"
20
21 function usage() {
22     echo "usage: `basename $0` [OPTIONS]"
23     echo "  -proj PROJECT  The project to merge the result into"
24     echo "  -rev NUM       The revision to merge into the project"
25     echo "  -revert        Revert rather than merge the commit"
26 }
27
28 while [ $# -gt 0 ]; do
29     case $1 in
30         -rev | --rev | -r )
31             shift
32             rev=$1
33             ;;
34         -proj | --proj | -project | --project | -p )
35             shift
36             proj=$1
37             ;;
38         -h | -help | --help )
39             usage
40             ;;
41         -revert | --revert )
42             revert="yes"
43             ;;
44         * )
45             echo "unknown option: $1"
46             echo ""
47             usage
48             exit 1
49             ;;
50     esac
51     shift
52 done
53
54 if [ "x$rev" = "x" -o "x$proj" = "x" ]; then
55     echo "error: need to specify project and revision"
56     echo
57     usage
58     exit 1
59 fi
60
61 if ! svn ls http://llvm.org/svn/llvm-project/$proj/trunk > /dev/null 2>&1 ; then
62     echo "error: invalid project: $proj"
63     exit 1
64 fi
65
66 tempfile=`mktemp /tmp/merge.XXXXXX` || exit 1
67
68 if [ $revert = "yes" ]; then
69     echo "Reverting r$rev:" > $tempfile
70 else
71     echo "Merging r$rev:" > $tempfile
72 fi
73 svn log -c $rev http://llvm.org/svn/llvm-project/$proj/trunk >> $tempfile 2>&1
74
75 cd $proj.src
76 echo "# Updating tree"
77 svn up
78
79 if [ $revert = "yes" ]; then
80     echo "# Reverting r$rev in $proj locally"
81     svn merge -c -$rev . || exit 1
82 else
83     echo "# Merging r$rev into $proj locally"
84     svn merge -c $rev https://llvm.org/svn/llvm-project/$proj/trunk . || exit 1
85 fi
86
87 echo
88 echo "# To commit, run the following in $proj.src/:"
89 echo svn commit -F $tempfile
90
91 exit 0