OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

139 lines
3.7 KiB

#!/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
[ -n "$SDEROOT" ] ||
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
. $SDEROOT/lib/libsde.in
commit_usage() {
local progname=${0##*/}
cat <<EOT
Usage: $progname [--file <message file>] [FILES...]
EOT
}
shortopts='F:'
longopts='file:'
options=$( getopt -o "$shortopts" -l "$longopts" -- "$@" )
if [ $? -ne 0 ]; then
commit_usage
exit -1
fi
# load new arguments list
eval set -- "$options"
logfile=
tmpfile=$SDEROOT/tmp/$$
mkdir -p "$SDEROOT/tmp"
while [ $# -gt 0 ]; do
case "$1" in
-F|--file) logfile="`readlink -f $2 2> /dev/null`"; shift ;;
--) shift; break ;;
*) echo_abort 1 "Unknown argument '$1', aborting."
esac
shift
done
if [ -n "$logfile" -a ! -r "$logfile" ]; then
echo_abort 2 "File '$logfile' not found."
fi
# validate locations
#
[ $# -gt 0 ] || set -- .
# extract roots at root relative paths of the given locations
locations=$( $SDEROOT/bin/sde-list-files --roots "$@" )
# we only accept one root at the time
roots=$( echo "$locations" | cut -d' ' -f1 | sort -u )
root=$( echo "$roots" | head -n 1 )
[ "$root" == "$roots" ] || echo_abort 1 "Locations from multiple repositories given, aborting."
# $root relative locations
locations=$( echo "$locations" | cut -d' ' -f2 )
[ -n "$locations" ] || echo_abort 1 "No locations, aborting."
echo_abort 0 "Not yet reimplemented."
# 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"