Whamcloud - gitweb
b=6277
[fs/lustre-release.git] / build / merge1.sh
1 #!/bin/sh -e 
2
3 CONFLICTS=cvs-merge-conflicts
4 CVS="cvs -z3"
5
6 if [ -f .mergeinfo ] ; then
7     echo ".mergeinfo exists - clean up first"
8     exit 
9 fi
10
11 if [ -f $CONFLICTS ] ; then
12     echo "$CONFLICTS exists - clean up first"
13     exit 
14 fi
15
16 if [ $# -lt 2 -o $# -gt 3 ]; then
17     echo "This is phase 1 of merging branches. Usage: $0 parent child dir"
18     exit
19 fi
20
21 parent=$1
22 PARENT=`echo $parent | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
23 child=$2
24 CHILD=`echo $child | sed -e "s/^b_//" | tr "[a-z]" "[A-Z]"`
25 date=`date +%Y%m%d_%H%M`
26
27 dir=${3:-.}
28 module=$(basename $(<$dir/CVS/Repository))
29
30 if [ "$module" = "lustre" ] ; then
31     echo >&2 "${progname}: You probably want to branch lustre or portals, not the whole tree."
32     echo >&2 "${progname}: Try using ${0} $parent $child lustre"
33     exit 1
34 fi
35
36
37 case $parent in
38   HEAD) : ;;
39   b_*|b[1-4]*) : ;;
40   *) parent="b_$parent" ;;
41 esac
42 case $child in
43   HEAD) : ;;
44   b_*|b[1-4]*) : ;;
45   *) child="b_$child"
46 esac
47
48 if [ "$child" != "HEAD" -a "`cat $dir/CVS/Tag 2> /dev/null`" != "T$child" ]; then
49         echo "This script must be run within the $child branch"
50         exit 1
51 fi
52
53 TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter?
54 check_tag() {
55         [ -z "$1" ] && echo "check_tag() missing arg" && exit3
56         [ "$1" = "HEAD" ] && return
57         $CVS log $dir/$TEST_FILE 2> /dev/null | grep -q "       $1: " && return
58         echo "$0: tag $1 not found in $dir/$TEST_FILE"
59         exit 2
60 }
61
62 check_tag $parent
63 check_tag ${CHILD}_BASE
64
65 cat << EOF > .mergeinfo
66 parent=$parent
67 PARENT=$PARENT
68 child=$child
69 CHILD=$CHILD
70 date=$date
71 dir=$dir
72 module=$module
73 CONFLICTS=$CONFLICTS
74 OPERATION=Merge
75 OPERWHERE=from
76 EOF
77
78 echo PARENT: $PARENT parent: $parent CHILD: $CHILD child: $child date: $date
79
80 echo -n "tagging $parent as '${PARENT}_${CHILD}_UPDATE_PARENT_$date' ...."
81 $CVS rtag -r $parent ${PARENT}_${CHILD}_UPDATE_PARENT_$date $module
82 echo "done"
83 echo -n "tagging $child as '${PARENT}_${CHILD}_UPDATE_CHILD_$date' ...."
84 $CVS rtag -r $child ${PARENT}_${CHILD}_UPDATE_CHILD_$date $module
85 echo "done"
86
87 # Apply all of the changes to your local tree:
88 echo "Updating: -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date ...."
89 $CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date -dP $dir
90 echo "done"
91
92 echo -n "Recording conflicts in $CONFLICTS ..."
93 $CVS update | awk '/^C/ { print $2 }' > $CONFLICTS
94 if [ -s $CONFLICTS ] ; then
95     echo "Conflicts found, fix before committing."
96     cat $CONFLICTS
97 else 
98     echo "No conflicts found"
99     rm -f $CONFLICTS
100 fi
101 echo "done"
102
103 echo "Build, test, commit and then run merge2.sh (no arguments)"