Whamcloud - gitweb
Re-add CVS helper scripts. Not sure how they were lost.
[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 if [ "$parent" != "HEAD" -a "`cat CVS/Tag`" != "T$parent" ]; then
29         echo "This script must be run within the $parent branch"
30         exit 1
31 fi
32
33 dir=$3
34
35 if [ $parent != "HEAD" ]; then
36   parent="b_$parent"
37 fi
38 if [ $child != "HEAD" ]; then
39   child="b_$child"
40 fi
41
42 cat << EOF > .mergeinfo
43 parent=$parent
44 PARENT=$PARENT
45 child=$child
46 CHILD=$CHILD
47 date=$date
48 module=$module
49 dir=$dir
50 CONFLICTS=$CONFLICTS
51 EOF
52
53 echo PARENT $PARENT parent $parent CHILD $CHILD child $child date $date
54
55 # Update your tree to the PARENT branch; HEAD is not really a branch, so you
56 # need to update -A instead of update -r HEAD, or the commit will fail. -p
57 echo -n "Updating to $parent ...."
58 if [ $parent == "HEAD" ]; then
59   $CVS update -AdP $dir
60 else
61   $CVS update -r $parent -dP $dir
62 fi
63 echo "done"
64
65 echo -n "Tagging as ${PARENT}_${CHILD}_LAND_PARENT_$date ..."
66 $CVS tag ${PARENT}_${CHILD}_LAND_PARENT_$date $dir
67 echo "done"
68
69 echo -n "Create land point on ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date ..."
70 $CVS rtag -r ${child} ${PARENT}_${CHILD}_LAND_CHILD_$date $module $dir
71 echo "done"
72
73 echo -n "Preserve old base tag ${CHILD}_BASE as ${CHILD}_BASE_PREV ..."
74 $CVS tag -F -r ${CHILD}_BASE ${CHILD}_BASE_PREV $dir
75 echo "done"
76
77 # Apply all of the changes to your local tree:
78 echo -n "Updating as -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date ..."
79 $CVS update -j ${CHILD}_BASE -j ${PARENT}_${CHILD}_LAND_CHILD_$date $dir
80 echo "done"
81
82 echo -n "Recording conflicts in $CONFLICTS ..."
83 if $CVS update | grep '^C' > $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 "Test, commit and then run land2.sh (no arguments)"
93