Newer
Older
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
#!/bin/sh -e
CONFLICTS=cvs-merge-conflicts
CVS="cvs -z3"
if [ -f .mergeinfo ] ; then
echo ".mergeinfo exists - clean up first"
exit
fi
if [ -f $CONFLICTS ] ; then
echo "$CONFLICTS exists - clean up first"
exit
fi
if [ $# -lt 2 -o $# -gt 3 ]; then
echo "This is phase 1 of merging branches. Usage: $0 parent child [dir]"
exit
fi
parent=$1
PARENT=`echo $parent | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
child=$2
CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
date=`date +%Y%m%d_%H%M`
dir=${3:-.}
module=$(<$dir/CVS/Repository)
if [ "$module" = "lustre" ] ; then
echo >&2 "${progname}: You probably want to branch lustre or portals, not the whole tree."
echo >&2 "${progname}: Try using ${0} $parent $child lustre"
exit 1
fi
case $parent in
HEAD) : ;;
b_*|b[1-4]*) : ;;
*) parent="b_$parent" ;;
esac
case $child in
HEAD) : ;;
b_*|b[1-4]*) : ;;
*) child="b_$child"
esac
if [ "$child" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$child" ]; then
echo "This script must be run within the $child branch"
exit 1
fi
TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter?
check_tag() {
[ -z "$1" ] && echo "check_tag() missing arg" && exit3
[ "$1" = "HEAD" ] && return
$CVS log $dir/$TEST_FILE 2> /dev/null | grep -q " $1: " && return
echo "$0: tag $1 not found in $dir/$TEST_FILE"
exit 2
}
check_tag $parent
check_tag ${CHILD}_BASE
cat << EOF > .mergeinfo
parent=$parent
PARENT=$PARENT
child=$child
CHILD=$CHILD
date=$date
dir=$dir
module=$module
CONFLICTS=$CONFLICTS
OPERATION=Merge
OPERWHERE=from
EOF
echo PARENT: $PARENT parent: $parent CHILD: $CHILD child: $child date: $date
echo -n "tagging $parent as '${PARENT}_${CHILD}_UPDATE_PARENT_$date' ...."
$CVS rtag -r $parent ${PARENT}_${CHILD}_UPDATE_PARENT_$date $module
echo "done"
echo -n "tagging $child as '${PARENT}_${CHILD}_UPDATE_CHILD_$date' ...."
$CVS rtag -r $child ${PARENT}_${CHILD}_UPDATE_CHILD_$date $module
echo "done"
# Apply all of the changes to your local tree:
echo "Updating: -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date ...."
$CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date -dP $dir
echo "done"
echo -n "Recording conflicts in $CONFLICTS ..."
$CVS update | awk '/^C/ { print $2 }' > $CONFLICTS
if [ -s $CONFLICTS ] ; then
echo "Conflicts found, fix before committing."
cat $CONFLICTS
else
echo "No conflicts found"
rm -f $CONFLICTS
fi
echo "done"
echo "Build, test, commit and then run merge2.sh (no arguments)"