|
|
d627b6 |
#!/bin/bash
|
|
|
d627b6 |
#
|
|
|
4e4549 |
# cli_commitRepoChanges.sh -- This function looks for revision changes
|
|
|
640f58 |
|
|
|
640f58 |
# them up to central repository. Use this function before or after
|
|
|
640f58 |
# whatever function that makes changes to files inside the working
|
|
|
640f58 |
# copy. It is better to commit small changes than long ones.
|
|
|
d627b6 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
d627b6 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
|
|
|
7cd8e9 |
|
|
|
7cd8e9 |
|
|
|
d627b6 |
#
|
|
|
d627b6 |
|
|
|
d627b6 |
|
|
|
d627b6 |
|
|
|
d627b6 |
# General Public License for more details.
|
|
|
d627b6 |
#
|
|
|
d627b6 |
|
|
|
d627b6 |
# along with this program; if not, write to the Free Software
|
|
|
d627b6 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
d627b6 |
# USA.
|
|
|
d627b6 |
#
|
|
|
d627b6 |
# ----------------------------------------------------------------------
|
|
|
d627b6 |
# $Id$
|
|
|
d627b6 |
# ----------------------------------------------------------------------
|
|
|
d627b6 |
|
|
|
d627b6 |
function cli_commitRepoChanges {
|
|
|
d627b6 |
|
|
|
4e4549 |
local -a FILES
|
|
|
4e4549 |
local -a INFO
|
|
|
4e4549 |
local -a FILESNUM
|
|
|
d627b6 |
local COUNT=0
|
|
|
4e4549 |
local UPDATEOUT=''
|
|
|
4e4549 |
local PREDICATE=''
|
|
|
58a639 |
local LOCALFILES=''
|
|
|
58a639 |
local CHNGDIRECTION=''
|
|
|
b3ea32 |
local CHNGTOTAL=0
|
|
|
ae2995 |
local LOCATION=''
|
|
|
d627b6 |
|
|
|
640f58 |
|
|
|
ae2995 |
|
|
|
ae2995 |
|
|
|
ae2995 |
|
|
|
ae2995 |
|
|
|
640f58 |
if [[ -f "$1" || -d "$1" ]];then
|
|
|
ae2995 |
LOCATION="$1"
|
|
|
ae2995 |
else
|
|
|
ae2995 |
LOCATION="$ACTIONVAL"
|
|
|
640f58 |
fi
|
|
|
640f58 |
|
|
|
4e4549 |
|
|
|
4e4549 |
echo '----------------------------------------------------------------------'
|
|
|
58a639 |
cli_printMessage "`gettext "Bringing changes from the repository into the working copy"`" 'AsResponseLine'
|
|
|
ae2995 |
UPDATEOUT=$(svn update ${LOCATION})
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
cli_printMessage "`gettext "Checking changes in the working copy"`" 'AsResponseLine'
|
|
|
ae2995 |
STATUSOUT=$(svn status ${LOCATION})
|
|
|
4e4549 |
echo '----------------------------------------------------------------------'
|
|
|
d627b6 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
4e4549 |
FILES[0]=$(echo "$UPDATEOUT" | egrep '^A' | cut -d' ' -f7)
|
|
|
4e4549 |
FILES[1]=$(echo "$UPDATEOUT" | egrep '^D' | cut -d' ' -f7)
|
|
|
4e4549 |
FILES[2]=$(echo "$UPDATEOUT" | egrep '^U' | cut -d' ' -f7)
|
|
|
4e4549 |
FILES[3]=$(echo "$UPDATEOUT" | egrep '^C' | cut -d' ' -f7)
|
|
|
4e4549 |
FILES[4]=$(echo "$UPDATEOUT" | egrep '^G' | cut -d' ' -f7)
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
FILES[5]=$(echo "$STATUSOUT" | egrep '^M' | cut -d' ' -f7)
|
|
|
58a639 |
FILES[6]=$(echo "$STATUSOUT" | egrep '^\?' | cut -d' ' -f7)
|
|
|
58a639 |
FILES[7]=$(echo "$STATUSOUT" | egrep '^D' | cut -d' ' -f7)
|
|
|
640f58 |
FILES[8]=$(echo "$STATUSOUT" | egrep '^A' | cut -d' ' -f7)
|
|
|
d627b6 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
4e4549 |
INFO[0]="`gettext "Added"`"
|
|
|
4e4549 |
INFO[1]="`gettext "Deleted"`"
|
|
|
4e4549 |
INFO[2]="`gettext "Updated"`"
|
|
|
4e4549 |
INFO[3]="`gettext "Conflicted"`"
|
|
|
4e4549 |
INFO[4]="`gettext "Merged"`"
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
4e4549 |
INFO[5]="`gettext "Modified"`"
|
|
|
640f58 |
INFO[6]="`gettext "Unversioned"`"
|
|
|
58a639 |
INFO[7]=${INFO[1]}
|
|
|
640f58 |
INFO[8]=${INFO[0]}
|
|
|
d627b6 |
|
|
|
4e4549 |
while [[ $COUNT -ne ${#FILES[*]} ]];do
|
|
|
d627b6 |
|
|
|
4e4549 |
# Get total number of files. Avoid counting empty line.
|
|
|
58a639 |
if [[ "${FILES[$COUNT]}" == '' ]];then
|
|
|
4e4549 |
FILESNUM[$COUNT]=0
|
|
|
4e4549 |
else
|
|
|
4e4549 |
FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l)
|
|
|
4e4549 |
fi
|
|
|
4e4549 |
|
|
|
b3ea32 |
|
|
|
b3ea32 |
CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]}))
|
|
|
b3ea32 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
4e4549 |
if [[ ${FILESNUM[$COUNT]} -lt 1 ]];then
|
|
|
58a639 |
PREDICATE[$COUNT]=`gettext "file"`
|
|
|
4e4549 |
else
|
|
|
4e4549 |
PREDICATE[$COUNT]=`ngettext "file" "files" ${FILESNUM[$COUNT]}`
|
|
|
4e4549 |
fi
|
|
|
4e4549 |
|
|
|
58a639 |
|
|
|
58a639 |
if [[ $COUNT -le 4 ]]; then
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
CHNGDIRECTION="`gettext "from the repository."`"
|
|
|
58a639 |
elif [[ $COUNT -gt 4 ]];then
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
CHNGDIRECTION="`gettext "from the working copy."`"
|
|
|
58a639 |
fi
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
PREDICATE[$COUNT]="${PREDICATE[$COUNT]} ${CHNGDIRECTION}"
|
|
|
58a639 |
|
|
|
4e4549 |
# Output report line.
|
|
|
4e4549 |
cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}" 'AsRegularLine'
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
4e4549 |
COUNT=$(($COUNT + 1))
|
|
|
4e4549 |
|
|
|
4e4549 |
done
|
|
|
4e4549 |
|
|
|
4e4549 |
echo '----------------------------------------------------------------------'
|
|
|
4e4549 |
|
|
|
b3ea32 |
|
|
|
b3ea32 |
|
|
|
b3ea32 |
|
|
|
b3ea32 |
if [[ $CHNGTOTAL -eq 0 ]];then
|
|
|
b3ea32 |
return 0
|
|
|
b3ea32 |
fi
|
|
|
b3ea32 |
|
|
|
2ce3a5 |
# In case new unversioned files exist, ask user to add them into
|
|
|
2ce3a5 |
|
|
|
2ce3a5 |
|
|
|
2ce3a5 |
if [[ ${FILESNUM[6]} -gt 0 ]];then
|
|
|
00f591 |
cli_printMessage "`ngettext "The following file is unversioned" \
|
|
|
00f591 |
"The following files are unversioned" ${FILESNUM[6]}`:"
|
|
|
00f591 |
for FILE in ${FILES[6]};do
|
|
|
2ce3a5 |
cli_printMessage $FILE 'AsResponseLine'
|
|
|
2ce3a5 |
done
|
|
|
c4b35f |
cli_printMessage "`ngettext "Do you want to add it now?" \
|
|
|
c4b35f |
"Do you want to add them now?" ${FILESNUM[6]}`" 'AsYesOrNoRequestLine'
|
|
|
52155a |
svn add ${FILES[6]} --quiet
|
|
|
2ce3a5 |
fi
|
|
|
2ce3a5 |
|
|
|
b3ea32 |
|
|
|
b3ea32 |
COUNT=0
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
|
|
|
58a639 |
while [[ $COUNT -ne ${#FILES[*]} ]];do
|
|
|
58a639 |
LOCALFILES="$LOCALFILES ${FILES[$COUNT]}"
|
|
|
58a639 |
COUNT=$(($COUNT + 1 ))
|
|
|
58a639 |
done
|
|
|
58a639 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
4e4549 |
|
|
|
58a639 |
if [[ $LOCALFILES != '' ]];then
|
|
|
d627b6 |
|
|
|
d627b6 |
|
|
|
4e4549 |
cli_printMessage "`gettext "Do you want to see changes now?"`" "AsYesOrNoRequestLine"
|
|
|
58a639 |
svn diff $LOCALFILES | less
|
|
|
d627b6 |
|
|
|
d627b6 |
|
|
|
58a639 |
cli_printMessage "`gettext "Do you want to commit changes now?"`" "AsYesOrNoRequestLine"
|
|
|
58a639 |
svn commit $LOCALFILES
|
|
|
4e4549 |
|
|
|
d627b6 |
fi
|
|
|
d627b6 |
|
|
|
d627b6 |
}
|