aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/merge.sh
blob: a8c356ad30bb21f9dc3e2ae981a17583e7e9d826 (plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
FROM=$1
REVISION=$2
AUTOCOMMIT=$3

if [ "$FROM" = "" ] || [ "$REVISION" = "" ]
then
	echo "Usage: $0 <from version> <changeset> [autocommit]"
	exit 2
fi

localchanges=`svn stat|wc -l`
if [ "$localchanges" != "0" ]
then
	echo "You must have a clean working space copy"
	exit 2
fi

if [ "$SVN_PASS_FILE" != "" ]
then
       SVN_PASS=`cat "$SVN_PASS_FILE"`
fi
       
svn up

currentrepowithoutversion=`svn info|grep URL|sed "s/URL: //"|sed "s/\/[^\/]*$//"`
sourceurl="$currentrepowithoutversion/$FROM"

msg=`svn log $sourceurl -r $REVISION --xml|grep "<msg>"|sed "s/<msg>//"|sed "s/<\/msg>//"`
svn merge $sourceurl . -c $REVISION
if [ "$?" != "0" ]
then
	echo "Merge failed. Conflicts must be resolved manually!"
	exit 3
fi

msg="[merge from $FROM] $msg"
if [ "$AUTOCOMMIT" = "autocommit" ]
then
	echo "Trying to commit..."
	if [ "$SVN_USER" != "" ]
	then
		svn commit -m "$msg" --username $SVN_USER --password $SVN_PASS
	else
		svn commit -m "$msg"
	fi
	
	RET=$?
	if [ "$RET" != "0" ]
	then
		exit 1
	fi
	exit 0
else
	echo "Run the following command to commit..."
	echo svn commit -m \"$msg\"
	exit 1
fi