X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=do_merge;h=01d7f1c01bbdc1220680286639b0419a2780d264;hb=063e3ebc696de808c6254167104a3ec1c08892c9;hp=0a95322ea54acf6c2ae45afe9c97d3386af267f5;hpb=94d90179933d878799960214b9d9864996a1553a;p=next-scripts diff --git a/do_merge b/do_merge index 0a95322..01d7f1c 100755 --- a/do_merge +++ b/do_merge @@ -1,14 +1,7 @@ #!/bin/bash -LOG_FILE="../merge.log" -build_host="ka2" -build_dir="/scratch/sfr/next" -build_cmd="bin/build_next" - no_build=false start_from="" -[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST" -[ "$NEXT_BUILD_DIR" ] && build_host="$NEXT_BUILD_DIR" [ "$1" = "-n" ] && { shift @@ -23,85 +16,32 @@ start_from="" } shift } -[ -n "$1" ] && { - build_host="$1" - shift -} -[ -n "$1" ] && { - build_dir="$1" - shift -} + +tool_dir=$(dirname "$0") +. "$tool_dir/common.sh" log() { - echo "$@" | tee -a $LOG_FILE + echo "$@" | tee -a "$LOG_FILE" } execute() { - log "$" $@ - $@ 2>&1 | tee -a $LOG_FILE - return ${PIPESTATUS[0]} -} - -do_rebase() -{ - rbase=${1#*/} - rbase=${rbase%%:*} - rtop=${1#*:} - rbid=$(git rev-parse $2/$rbase) - rtid=$(git rev-parse $2/$rtop) - [ "$rbid" = "$rtid" ] && { - echo Empty tree - return - } - [ "$(git rev-list HEAD..$2/$rtop)" ] || { - echo Already merged - return - } - execute git clone -s -l -n -q . ../rebase-tmp || { - echo Clone failed 1>&2 - bash -i || exit - } - log '$' cd ../rebase-tmp - cd ../rebase-tmp - execute git fetch --no-tags ../next refs/remotes/$2/$rtop:$2/$rtop || { - echo Fetch of top failed 1>&2 - bash -i || exit - } - execute git fetch --no-tags ../next refs/remotes/$2/$rbase:$2/$rbase || { - echo Fetch of base failed 1>&2 - bash -i || exit - } - execute git checkout $2/$rtop || { - echo Checkout of top failed 1>&2 - bash -i || exit - } - execute git rebase --onto master $2/$rbase || { - echo Rebase failed 1>&2 - bash -i || exit - } - log '$' cd ../next - cd ../next - execute git pull -f ../rebase-tmp $2/$rtop || { - echo Pull failed 1>&2 - echo $h >>../merge.debug - git diff >>../merge.debug 2>&1 - git diff 2>&1 | egrep -q '<<<<<|^\*' && { - bash -i || exit - } - } - execute rm -rf ../rebase-tmp + log "$" "$@" + "$@" 2>&1 | tee -a "$LOG_FILE" + return "${PIPESTATUS[0]}" } [ -n "$start_from" ] || { - cp /dev/null $LOG_FILE - execute date + cp /dev/null "$LOG_FILE" + execute date -R execute git checkout master execute git reset --hard stable + printf 'Name\t\tSHA1\n----\t\t----\n' > "$SHA1_FILE" + } -heads=$(grep -v '^#' ../real_control | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }') +heads=$(awk -F '\t' '/^#/ { next; } $2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); } $2=="branch" { printf("branch/%s ", $1); }' "$CTRL_FILE") need_build=false @@ -116,39 +56,56 @@ for h in $heads; do fi } - hlog=$(git log -1 --oneline ${h/\/*://}) 2>/dev/null - log Merging $h "($hlog)" + [ "$tree" = "branch" ] && { + git branch -f "${h#branch/}" + continue + } + + hlog=$(git log -1 --oneline "${h/\/*://}") 2>/dev/null old_head=$(git rev-parse HEAD) - [ -x "../pre-merge/$tree" ] && { - "../pre-merge/$tree" || bash -i || exit + [ -f "../pre-merge/$tree" ] && { + for p in $(cat "../pre-merge/$tree"); do + "$bin_dir/do_patch" -n "$p" || { + linux-next-notify "premerge patch failed" + bash -i || exit + } + done } - case "$h" in - *:*) - do_rebase $h $tree - ;; - *) - execute git merge $h || { - echo Merge failed 1>&2 - echo $h >>../merge.debug - git diff >>../merge.debug 2>&1 - git diff 2>&1 | egrep -q '<<<<<|^\*' && { + log Merging "$h" "($hlog)" + execute git merge "$h" || { + echo Merge failed 1>&2 + echo "$h" >>../merge.debug + git diff >>../merge.debug 2>&1 + + check_unmerged_files "$tree" + + git diff 2>&1 | egrep -q '<<<<<|^\*' && { + linux-next-notify "new conflict found merging $tree" + if [ -f "../merge-fixes/$tree" ]; then + echo "Merge fixes exist for this tree:" + cat "../merge-fixes/$tree" + fi + bash -i || exit + } +# [ "$(git status --porcelain)" ] && { + GIT_EDITOR=: execute git commit -v -a || { + linux-next-notify "next commit failed for $tree" bash -i || exit } - GIT_EDITOR=: execute git commit -v -a execute git diff -M --stat --summary 'HEAD^..' - } - ;; - esac +# } + } [ -f "../merge-fixes/$tree" ] && { for p in $(cat "../merge-fixes/$tree"); do - $(dirname $0)/merge_fix -n "$p" || { + "$bin_dir/merge_fix" -n "$p" || { + linux-next-notify "merge fix failed for $tree" bash -i || exit } done } - [ -x "../pre-build/$tree" ] && { - "../pre-build/$tree" || bash -i || exit - } + tab="\t" + [ $(echo "$tree" | wc -c) -le 8 ] && tab="\t\t" + printf "%s$tab%s\n" $tree $(git rev-parse "${h/\/*://}^{}") >> $SHA1_FILE $no_build && continue $need_build || { # See if we need to build after merging this tree @@ -159,17 +116,27 @@ for h in $heads; do } $need_build || continue - do_build=$(grep -v '^#' ../real_control | awk -F ' ' '$3=="'$tree'" { print $6; }') + do_build=$(awk -F '\t' '/^[^#]/ && $3=="'$tree'" { print $6; }' "$CTRL_FILE") [ "$do_build" = "yes" ] || continue - git push -f "$build_host":"$build_dir" master:refs/heads/next || { + git push -f "${build_host}${build_host:+:}${build_dir}" master:refs/heads/next || { echo git push failed 1>&2 + linux-next-notify "push failed for $tree" bash -i || exit } - ssh "$build_host" "$build_cmd" || { + [ -x "../pre-build/$tree" ] && { + "../pre-build/$tree" || { + echo Prebuild script failed 1>&2 + linux-next-notify "pre-build script failed for $tree" + bash -i || exit + } + } + "$bin_dir/do_build" "$tree" || { echo Build failed 1>&2 + linux-next-notify "build failed for $tree" bash -i || exit } + need_build=false done