Whamcloud - gitweb
- landing of b_hd_cleanup_merge to HEAD.
[fs/lustre-release.git] / lustre / scripts / 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 [ $# != 2 ]; then
17     echo "This is phase 1 of merging branches. Usage: $0 parent child"
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 module=lustre
27
28 case $parent in
29   HEAD) : ;;
30   b_*|b[1-4]*) : ;;
31   *) parent="b_$parent" ;;
32 esac
33 case $child in
34   HEAD) : ;;
35   b_*|b[1-4]*) : ;;
36   *) child="b_$child"
37 esac
38
39 if [ "$child" != "HEAD" -a "`cat CVS/Tag 2> /dev/null`" != "T$child" ]; then
40         echo "This script must be run within the $child branch"
41         exit 1
42 fi
43
44 TEST_FILE=${TEST_FILE:-ChangeLog} # does this need to be smarter?
45 check_tag() {
46         [ -z "$1" ] && echo "check_tag() missing arg" && exit3
47         [ "$1" = "HEAD" ] && return
48         $CVS log $TEST_FILE 2> /dev/null | grep -q "    $1: " && return
49         echo "$0: tag $1 not found in $TEST_FILE"
50         exit 2
51 }
52
53 check_tag $parent
54 check_tag ${CHILD}_BASE
55
56 cat << EOF > .mergeinfo
57 parent=$parent
58 PARENT=$PARENT
59 child=$child
60 CHILD=$CHILD
61 date=$date
62 module=$module
63 CONFLICTS=$CONFLICTS
64 OPERATION=Update
65 OPERWHERE=from
66 EOF
67
68 echo PARENT: $PARENT parent: $parent CHILD: $CHILD child: $child date: $date
69
70 echo -n "tagging $parent as '${PARENT}_${CHILD}_UPDATE_PARENT_$date' ...."
71 $CVS rtag -r $parent ${PARENT}_${CHILD}_UPDATE_PARENT_$date $module
72 echo "done"
73 echo -n "tagging $child as '${PARENT}_${CHILD}_UPDATE_CHILD_$date' ...."
74 $CVS rtag -r $child ${PARENT}_${CHILD}_UPDATE_CHILD_$date $module
75 echo "done"
76
77 # Apply all of the changes to your local tree:
78 echo "Updating: -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date ...."
79 $CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_UPDATE_PARENT_$date -dP
80 echo "done"
81
82 echo -n "Recording conflicts in $CONFLICTS ..."
83 if $CVS update | awk '/^C/ { print $2 }' > $CONFLICTS; then
84     echo "Conflicts found, fix before committing."
85     cat $CONFLICTS
86 else 
87     echo "No conflicts found"
88     rm -f $CONFLICTS
89 fi
90 echo "done"
91
92 echo "Build, test, commit and then run merge2.sh (no arguments)"