3 LOG_FILE="../merge.log"
6 build_dir="/scratch/sfr/next"
7 build_cmd="bin/build_next"
11 [ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
12 [ "$NEXT_BUILD_DIR" ] && build_host="$NEXT_BUILD_DIR"
21 [ -z "$start_from" ] && {
22 echo "-s requires a start tree" 1>&2
38 echo "$@" | tee -a $LOG_FILE
44 $@ 2>&1 | tee -a $LOG_FILE
45 return ${PIPESTATUS[0]}
53 rbid=$(git rev-parse $2/$rbase)
54 rtid=$(git rev-parse $2/$rtop)
55 [ "$rbid" = "$rtid" ] && {
59 [ "$(git rev-list HEAD..$2/$rtop)" ] || {
63 execute git clone -s -l -n -q . ../rebase-tmp || {
64 echo Clone failed 1>&2
67 log '$' cd ../rebase-tmp
69 execute git fetch --no-tags ../next refs/remotes/$2/$rtop:$2/$rtop || {
70 echo Fetch of top failed 1>&2
73 execute git fetch --no-tags ../next refs/remotes/$2/$rbase:$2/$rbase || {
74 echo Fetch of base failed 1>&2
77 execute git checkout $2/$rtop || {
78 echo Checkout of top failed 1>&2
81 execute git rebase --onto master $2/$rbase || {
82 echo Rebase failed 1>&2
87 execute git pull -f ../rebase-tmp $2/$rtop || {
89 echo $h >>../merge.debug
90 git diff >>../merge.debug 2>&1
91 git diff 2>&1 | egrep -q '<<<<<|^\*' && {
95 execute rm -rf ../rebase-tmp
98 [ -n "$start_from" ] || {
99 cp /dev/null $LOG_FILE
101 execute git checkout master
102 execute git reset --hard stable
103 printf 'Name\t\tSHA1\n----\t\t----\n' > $SHA1_FILE
107 heads=$(grep -v '^#' ../real_control | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }')
114 [ -n "$start_from" ] && {
115 if [ "$tree" = "$start_from" ]; then
122 hlog=$(git log -1 --oneline ${h/\/*://}) 2>/dev/null
123 log Merging $h "($hlog)"
124 old_head=$(git rev-parse HEAD)
125 [ -x "../pre-merge/$tree" ] && {
126 "../pre-merge/$tree" || bash -i || exit
133 execute git merge $h || {
134 echo Merge failed 1>&2
135 echo $h >>../merge.debug
136 git diff >>../merge.debug 2>&1
137 git diff 2>&1 | egrep -q '<<<<<|^\*' && {
140 GIT_EDITOR=: execute git commit -v -a
141 execute git diff -M --stat --summary 'HEAD^..'
145 [ -f "../merge-fixes/$tree" ] && {
146 for p in $(cat "../merge-fixes/$tree"); do
147 $(dirname $0)/merge_fix -n "$p" || {
153 [ $(echo "$tree" | wc -c) -le 8 ] && tab="\t\t"
154 printf "%s$tab%s\n" $tree $(git show-ref --hash "${h/\/*://}") >> $SHA1_FILE
155 [ -x "../pre-build/$tree" ] && {
156 "../pre-build/$tree" || bash -i || exit
158 $no_build && continue
160 # See if we need to build after merging this tree
161 new_head=$(git rev-parse HEAD)
162 [ "$old_head" = "$new_head" ] ||
163 [ "$(git diff ${old_head}.. | wc -c)" -eq 0 ] ||
168 do_build=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'$tree'" { print $6; }')
169 [ "$do_build" = "yes" ] ||
171 git push -f "$build_host":"$build_dir" master:refs/heads/next || {
172 echo git push failed 1>&2
175 ssh "$build_host" "$build_cmd" || {
176 echo Build failed 1>&2