#!/bin/sh # --- SDE-COPYRIGHT-NOTE-BEGIN --- # This copyright note is auto-generated by ./scripts/Create-CopyPatch. # # Filename: lib/sde-commit.in # Copyright (C) 2006 - 2007 The OpenSDE Project # Copyright (C) 2004 - 2006 The T2 SDE Project # # More information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. A copy of the # GNU General Public License can be found in the file COPYING. # --- SDE-COPYRIGHT-NOTE-END --- #Description: Commits into svn the changes on the given locations #Alias: ci set -e [ -n "$SDEROOT" ] || export SDEROOT=$( cd "${0%/*}/.."; pwd -P ) . $SDEROOT/lib/libsde.in # svn or svk ? # if [ -d $SDEROOT/.svn/ ]; then SVN=svn else SVN=svk fi locations= x= y= logfile= tmpfile=$SDEROOT/tmp/$$ mkdir -p "$SDEROOT/tmp" if [ "$1" == "--file" ]; then logfile="`readlink -f $2 2> /dev/null`"; shift; shift; fi # validate locations # for x; do if [ -z "$x" ]; then continue elif [ -e "$x" ]; then # exists, normalize y="$( readlink -f $x )" if [ "$y" == "${y#$SDEROOT}" ]; then echo_warning "'$COLOR_MESSAGE$x$COLOR_NORMAL'" \ "is out of the tree, skipping." continue fi x="${y#$SDEROOT/}" elif [ -e "$SDEROOT/$x" ]; then # root relative true elif [ -d "$( echo "$SDEROOT/package/"*"/$x" )" ]; then # package from this tree x="$( cd "$SDEROOT"; echo "package/"*"/$x" )" elif [ -n "$( $SVN st "$x" 2> /dev/null )" ]; then # oh, it use was deleted y="$PWD/$x" y="$( readlink -f ${y%/*} )" if [ "$y" == "${y#$SDEROOT}" ]; then echo_warning "'$COLOR_MESSAGE$x$COLOR_NORMAL'" \ "is out of the tree, skipping." continue fi x="${y#$SDEROOT/}/${x##*/}" else echo_warning "'$COLOR_MESSAGE$x$COLOR_NORMAL' not found, skipping." continue fi locations="$locations $x" done if [ -z "$( echo $locations )" ]; then echo_abort 1 "No locations, bye." fi if [ -n "$logfile" -a ! -r "$logfile" ]; then echo_abort 2 "File '$logfile' not found." fi # and here we go # trap 'echo_error "Got SIGINT (Crtl-C)." ; rm $tmpfile.status $tmpfile.diff ; [ $logfile != $tmpfile.log ] || rm $logfile; exit 1' INT cd "$SDEROOT" ( $SVN st $locations | tee $tmpfile.status | grep '^\(A\|M\)' | tr -s ' ' | cut -d' ' -f2- | while read f; do f=${f#+ } if [ -f "$f" ]; then $SDEROOT/lib/sde-package/patch-copyright.sh "$f" fi done | patch -p0 2> /dev/null || true ) echo_msg "Changes:" $SVN diff $locations | tee $tmpfile.diff if [ -z "$logfile" ]; then logfile=$tmpfile.log # the grep -v === is a hack - somehow the svn === lines confuse awk ... ?!? grep -v === $tmpfile.diff | awk -f $SDEROOT/lib/sde-commit/commit-message.awk > $logfile fi echo_msg "Status:" cat $tmpfile.status if [ -s $tmpfile.diff ] || grep -q '^A' $tmpfile.status; then quit=0 until [ $quit -ne 0 ]; do echo_msg "Commit Message:" if [ -s $logfile ]; then cat $logfile commit=",${COLOR_MESSAGE}c${COLOR_NORMAL}:commit" else echo_warning "\tEmpty Log File!" commit= fi echo -en "\n${COLOR_MESSAGE}Is the message ok?${COLOR_NORMAL}" echo -en " (${COLOR_MESSAGE}q${COLOR_NORMAL}:quit,${COLOR_MESSAGE}e${COLOR_NORMAL}:edit,${COLOR_MESSAGE}d${COLOR_NORMAL}:diff,${COLOR_MESSAGE}s${COLOR_NORMAL}:status$commit)${COLOR_MESSAGE}:${COLOR_NORMAL} " read opt case "$opt" in c*) if [ -n "$commit" ]; then $SVN commit $locations --file $logfile && rm "$logfile" ; quit=1 fi ;; d*) less $tmpfile.diff ;; s*) cat $tmpfile.status ;; e*) ${EDITOR:-vi} $logfile ;; q*) quit=1 ;; *) echo "Excuse me?" esac done else echo_warning "No changes detected at:$locations" fi rm -f $tmpfile.status $tmpfile.diff [ "$logfile" != "$tmpfile.log" ] || rm -f "$logfile"