blob: 698353d691581d9ea2faeb5e0f0ea87a357efe4e [file] [log] [blame]
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +00001#!/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=""
Hans Wennborg2dc8e2a2015-08-04 00:47:58 +000019revert="no"
Joerg Sonnenberger645eab22016-06-01 14:16:00 +000020srcdir=""
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000021
Dimitry Andric307c7142016-01-13 19:48:50 +000022usage() {
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000023 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"
Hans Wennborg2dc8e2a2015-08-04 00:47:58 +000026 echo " -revert Revert rather than merge the commit"
Joerg Sonnenberger645eab22016-06-01 14:16:00 +000027 echo " -srcdir The root of the project checkout"
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000028}
29
30while [ $# -gt 0 ]; do
31 case $1 in
32 -rev | --rev | -r )
33 shift
Hans Wennborg394b6712016-07-18 20:06:27 +000034 rev=$1
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000035 ;;
36 -proj | --proj | -project | --project | -p )
37 shift
38 proj=$1
39 ;;
Joerg Sonnenbergerd7031452016-05-29 22:09:54 +000040 --srcdir | -srcdir | -s)
41 shift
42 srcdir=$1
43 ;;
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000044 -h | -help | --help )
45 usage
46 ;;
Hans Wennborg2dc8e2a2015-08-04 00:47:58 +000047 -revert | --revert )
48 revert="yes"
49 ;;
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000050 * )
51 echo "unknown option: $1"
52 echo ""
53 usage
54 exit 1
55 ;;
56 esac
57 shift
58done
59
Joerg Sonnenbergerd7031452016-05-29 22:09:54 +000060if [ -z "$srcdir" ]; then
61 srcdir="$proj.src"
62fi
63
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000064if [ "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
Hans Wennborg2dc8e2a2015-08-04 00:47:58 +000078if [ $revert = "yes" ]; then
79 echo "Reverting r$rev:" > $tempfile
80else
81 echo "Merging r$rev:" > $tempfile
82fi
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +000083svn log -c $rev http://llvm.org/svn/llvm-project/$proj/trunk >> $tempfile 2>&1
84
Joerg Sonnenbergerd7031452016-05-29 22:09:54 +000085cd "$srcdir"
Bill Wendlingeeb58a72011-10-16 20:59:25 +000086echo "# Updating tree"
87svn up
Hans Wennborg2dc8e2a2015-08-04 00:47:58 +000088
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
Hans Wennborg7472c762015-01-13 00:07:31 +000096
97echo
Richard Trieud085da52016-11-11 23:26:28 +000098echo "# To commit, run the following in $srcdir/:"
Hans Wennborg7472c762015-01-13 00:07:31 +000099echo svn commit -F $tempfile
100
Bill Wendlingf4a4e3a2011-10-16 01:54:03 +0000101exit 0