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