Whamcloud - gitweb
- landing of b_hd_cleanup_merge to HEAD.
[fs/lustre-release.git] / lustre / scripts / land1.sh
1 #!/bin/sh -e 
2
3 CONFLICTS=cvs-merge-conflicts
4 CVS=cvs
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 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 [ "$parent" != "HEAD" -a "`cat CVS/Tag 2> /dev/null`" != "T$parent" ]; then
40         echo "$0: this script must be run within the $parent 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 $child
54 check_tag ${CHILD}_BASE
55
56 dir=$3
57
58 cat << EOF > .mergeinfo
59 parent=$parent
60 PARENT=$PARENT
61 child=$child
62 CHILD=$CHILD
63 date=$date
64 module=$module
65 dir=$dir
66 CONFLICTS=$CONFLICTS
67 OPERATION=Land
68 OPERWHERE=onto
69 EOF
70
71 echo PARENT $PARENT parent $parent CHILD $CHILD child $child date $date
72
73 # Update your tree to the PARENT branch; HEAD is not really a branch, so you
74 # need to update -A instead of update -r HEAD, or the commit will fail. -p
75 echo -n "Updating to $parent ...."
76 if [ $parent == "HEAD" ]; then
77   $CVS update -AdP $dir
78 else
79   $CVS update -r $parent -dP $dir
80 fi
81 echo "done"
82
83 echo -n "Tagging as ${PARENT}_${CHILD}_LAND_PARENT_$date ..."
84 $CVS tag ${PARENT}_${CHILD}_LAND_PARENT_$date $dir
85 echo "done"
86
87 echo -n "Create land point on ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date ..."
88 $CVS rtag -r ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date $module $dir
89 echo "done"
90
91 echo -n "Preserve old base tag ${CHILD}_BASE as ${CHILD}_BASE_PREV ..."
92 $CVS tag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $dir
93 echo "done"
94
95 # Apply all of the changes to your local tree:
96 echo -n "Updating as -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date ..."
97 $CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date $dir
98 echo "done"
99
100 echo -n "Recording conflicts in $CONFLICTS ..."
101 if $CVS update | grep '^C' > $CONFLICTS; then
102     echo "Conflicts found, fix before committing."
103     cat $CONFLICTS
104 else 
105     echo "No conflicts found"
106     rm -f $CONFLICTS
107 fi
108 echo "done"
109
110 echo "Build, test, commit and then run land2.sh (no arguments)"