blob: 84379daf836c327431929a3d3613c789b0f75bea (
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
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
|
#!/usr/bin/env kmk_ash
# $Id$
## @file
# Script for merging a backport from trunk.
#
#
# Copyright (C) 2020-2023 Oracle and/or its affiliates.
#
# This file is part of VirtualBox base platform packages, as
# available from https://www.virtualbox.org.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, in version 3 of the
# License.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses>.
#
# SPDX-License-Identifier: GPL-3.0-only
#
#
# Determin script dir so we can source the common bits.
#
MY_SED=kmk_sed
MY_SCRIPT_DIR=`echo "$0" | "${MY_SED}" -e 's|\\\|/|g' -e 's|^\(.*\)/[^/][^/]*$|\1|'` # \ -> / is for windows.
if test "${MY_SCRIPT_DIR}" = "$0"; then
MY_SCRIPT_DIR=`pwd -L`
else
MY_SCRIPT_DIR=`cd "${MY_SCRIPT_DIR}"; pwd -L` # pwd is built into kmk_ash.
fi
#
# This does a lot.
#
MY_SCRIPT_NAME="backport-merge.sh"
. "${MY_SCRIPT_DIR}/backport-common.sh"
#
# Check that the branch is clean if first revision.
#
if test -n "${MY_FIRST_REV}"; then
MY_STATUS=`"${MY_SVN}" status -q "${MY_BRANCH_DIR}"`
if test -n "${MY_STATUS}"; then
echo "error: Branch already has changes pending..."
"${MY_SVN}" status -q "${MY_BRANCH_DIR}"
exit 1;
fi
test -z "${MY_DEBUG}" || echo "debug: Found no pending changes on branch."
fi
#
# Update branch if requested.
#
if test -n "${MY_UPDATE_FIRST}"; then
if ! "${MY_SVN}" update "${MY_BRANCH_DIR}" --ignore-externals; then
echo "error: branch updating failed..."
exit 1;
fi
test -z "${MY_DEBUG}" || echo "debug: Updated the branch."
fi
#
# Do the merging.
#
MY_DONE_REVS=
MY_FAILED_REV=
MY_TODO_REVS=
test -n "${MY_DEBUG}" && echo "MY_REVISIONS=${MY_REVISIONS}"
for MY_REV in ${MY_REVISIONS};
do
MY_MERGE_ARGS=
if test -z "${MY_FAILED_REV}"; then
echo "***"
echo "*** Merging r${MY_REV} ..."
echo "***"
if [ -n "${MY_FORCE}" ]; then
MY_MERGE_ARGS="$MY_MERGE_ARGS --ignore-ancestry"
fi
if "${MY_SVN}" merge ${MY_MERGE_ARGS} "${MY_TRUNK_DIR}" "${MY_BRANCH_DIR}" -c ${MY_REV}; then
# Check for conflict.
MY_CONFLICTS=`"${MY_SVN}" status "${MY_BRANCH_DIR}" | "${MY_SED}" -n -e '/^C/p'`
if test -z "${MY_CONFLICTS}"; then
if test -z "${MY_DONE_REVS}"; then
MY_DONE_REVS=${MY_REV}
else
MY_DONE_REVS="${MY_DONE_REVS} ${MY_REV}"
fi
else
echo '!!!'" Have conflicts after merging ${MY_REV}."
MY_FAILED_REV=${MY_REV}
fi
else
echo '!!!'" Failed merging r${MY_REV}."
MY_FAILED_REV=${MY_REV}
fi
else
if test -z "${MY_TODO_REVS}"; then
MY_TODO_REVS=${MY_REV}
else
MY_TODO_REVS="${MY_TODO_REVS} ${MY_REV}"
fi
fi
done
if test -z "${MY_FAILED_REV}"; then
echo "* Successfully merged all revision (${MY_DONE_REVS})."
exit 0;
fi
if test -n "${MY_DONE_REVS}"; then
echo "* Successfully merged: ${MY_DONE_REVS}"
fi
if test -n "${MY_TODO_REVS}"; then
echo "* Revisions left todo: ${MY_TODO_REVS}"
fi
exit 1;
|