]> git.ozlabs.org Git - next-scripts/blobdiff - do_merge
automate deleting of files
[next-scripts] / do_merge
index 13fd3c90c03a5d3b443e7bae3225112ba2424557..b86f527739020e7e5e48a07ce4e9f5203fc3bfd2 100755 (executable)
--- a/do_merge
+++ b/do_merge
@@ -1,13 +1,5 @@
 #!/bin/bash
 
-LOG_FILE="../merge.log"
-SHA1_FILE="../SHA1s"
-build_host="ka2"
-build_dir="/scratch/sfr/next"
-build_cmd="bin/build_next"
-[ "$NEXT_BUILD_HOST" ] && build_host="$NEXT_BUILD_HOST"
-[ "$NEXT_BUILD_DIR" ] && build_dir="$NEXT_BUILD_DIR"
-
 no_build=false
 start_from=""
 
@@ -24,17 +16,8 @@ start_from=""
        }
        shift
 }
-[ -n "$1" ] && {
-       build_host="$1"
-       shift
-}
-[ -n "$1" ] && {
-       build_dir="$1"
-       shift
-}
 
-export NEXT_BUILD_HOST="$build_host"
-export NEXT_BUILD_DIR="$build_dir"
+. "$(dirname $0)/common.sh"
 
 log()
 {
@@ -107,7 +90,7 @@ do_rebase()
 
 }
 
-heads=$(grep -v '^#' ../real_control | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }')
+heads=$(grep -v '^#' $CTRL_FILE | awk -F '\t' '$2=="quilt" || $2=="git" { printf("%s/%s ", $3, $5); }')
 
 need_build=false
 
@@ -123,11 +106,15 @@ for h in $heads; do
        }
 
        hlog=$(git log -1 --oneline ${h/\/*://}) 2>/dev/null
-       log Merging $h "($hlog)"
        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" || {
+                               bash -i || exit
+                       }
+               done
        }
+       log Merging $h "($hlog)"
        case "$h" in
        *:*)
                do_rebase $h $tree
@@ -137,27 +124,32 @@ for h in $heads; do
                        echo Merge failed 1>&2
                        echo $h >>../merge.debug
                        git diff >>../merge.debug 2>&1
+                       um_files=$(git diff 2>&1 | sed -n 's/^\* Unmerged path //p')
+                       [ "$um_files" ] && [ -f "../merge-files/$tree" ] && {
+                               rm_files=$(grep -F "$um_files" "../merge-files/$tree")
+                               [ "$rm_files" ] &&
+                                       "$bin_dir/do_rm" $rm_files
+                       }
                        git diff 2>&1 | egrep -q '<<<<<|^\*' && {
                                bash -i || exit
                        }
-                       GIT_EDITOR=: execute git commit -v -a
-                       execute git diff -M --stat --summary 'HEAD^..'
+#                      [ "$(git status --porcelain)" ] && {
+                               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" || {
                                bash -i || exit
                        }
                done
        }
        tab="\t"
        [ $(echo "$tree" | wc -c) -le 8 ] && tab="\t\t"
-       printf "%s$tab%s\n" $tree $(git show-ref --hash "${h/\/*://}") >> $SHA1_FILE
-       [ -x "../pre-build/$tree" ] && {
-               "../pre-build/$tree" || bash -i || exit
-       }
+       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
@@ -168,14 +160,14 @@ for h in $heads; do
        }
        $need_build ||
                continue
-       do_build=$(grep -v '^#' ../real_control | awk -F '      ' '$3=="'$tree'" { print $6; }')
+       do_build=$(grep -v '^#' $CTRL_FILE | awk -F '   ' '$3=="'$tree'" { print $6; }')
        [ "$do_build" = "yes" ] ||
                continue
        git push -f "$build_host":"$build_dir" master:refs/heads/next || {
                echo git push failed 1>&2
                bash -i || exit
        }
-       ssh "$build_host" "$build_cmd" || {
+       "$bin_dir/do_build" || {
                echo Build failed 1>&2
                bash -i || exit
        }