|
|
3071b7 |
#!/bin/bash
|
|
|
3071b7 |
#
|
|
|
3071b7 |
# cli_updateRepoChanges.sh -- This function realizes a subversion
|
|
|
3071b7 |
# update command against the working copy in order to bring changes
|
|
|
3071b7 |
# from the central repository into the working copy.
|
|
|
3071b7 |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
3071b7 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
3071b7 |
# General Public License for more details.
|
|
|
3071b7 |
#
|
|
|
3071b7 |
# You should have received a copy of the GNU General Public License
|
|
|
3071b7 |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
3071b7 |
# ----------------------------------------------------------------------
|
|
|
3071b7 |
# $Id$
|
|
|
3071b7 |
# ----------------------------------------------------------------------
|
|
|
3071b7 |
|
|
|
3071b7 |
function cli_updateRepoChanges {
|
|
|
3071b7 |
|
|
|
3071b7 |
# Verify don't commit changes flag.
|
|
|
3071b7 |
if [[ $FLAG_DONT_COMMIT_CHANGES != 'false' ]];then
|
|
|
3071b7 |
return
|
|
|
3071b7 |
fi
|
|
|
3071b7 |
|
|
|
3071b7 |
local -a FILES
|
|
|
3071b7 |
local -a INFO
|
|
|
3071b7 |
local -a FILESNUM
|
|
|
3071b7 |
local COUNT=0
|
|
|
3071b7 |
local UPDATEOUT=''
|
|
|
3071b7 |
local PREDICATE=''
|
|
|
3071b7 |
local CHNGTOTAL=0
|
|
|
3071b7 |
local LOCATIONS=''
|
|
|
3071b7 |
|
|
|
3071b7 |
# Define source location the subversion update action will take
|
|
|
3071b7 |
# place on. If arguments are provided use them as srouce location.
|
|
|
3071b7 |
# Otherwise use action value as default source location.
|
|
|
3071b7 |
if [[ "$@" != '' ]];then
|
|
|
3071b7 |
LOCATIONS="$@"
|
|
|
3071b7 |
else
|
|
|
3071b7 |
LOCATIONS="$ACTIONVAL"
|
|
|
3071b7 |
fi
|
|
|
3071b7 |
|
|
|
3071b7 |
# Verify locations existence. It shoud exist as regular file or
|
|
|
3071b7 |
# directory inside the repository working copy.
|
|
|
efa2a5 |
cli_checkFiles "$LOCATIONS" --working-copy
|
|
|
3071b7 |
|
|
|
3071b7 |
# Update working copy and retrive update output.
|
|
|
f659fa |
cli_printMessage "`gettext "Bringing changes from the repository into the working copy"`" --as-banner-line
|
|
|
3071b7 |
UPDATEOUT=$(svn update ${LOCATIONS})
|
|
|
3071b7 |
|
|
|
3071b7 |
# Define path of files considered recent modifications from
|
|
|
3071b7 |
# central repository to working copy.
|
|
|
3071b7 |
FILES[0]=$(echo "$UPDATEOUT" | egrep "^A.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[1]=$(echo "$UPDATEOUT" | egrep "^D.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[2]=$(echo "$UPDATEOUT" | egrep "^U.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[3]=$(echo "$UPDATEOUT" | egrep "^C.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
FILES[4]=$(echo "$UPDATEOUT" | egrep "^G.+$(cli_getRepoTLDir "${LOCATIONS}").+$" | sed -r "s,^.+($(cli_getRepoTLDir "${LOCATIONS}").+)$,\1,")
|
|
|
3071b7 |
|
|
|
3071b7 |
# Define description of files considered recent modifications from
|
|
|
3071b7 |
# central repository to working copy.
|
|
|
3071b7 |
INFO[0]="`gettext "Added"`"
|
|
|
3071b7 |
INFO[1]="`gettext "Deleted"`"
|
|
|
3071b7 |
INFO[2]="`gettext "Updated"`"
|
|
|
3071b7 |
INFO[3]="`gettext "Conflicted"`"
|
|
|
3071b7 |
INFO[4]="`gettext "Merged"`"
|
|
|
3071b7 |
|
|
|
3071b7 |
while [[ $COUNT -ne ${#FILES[*]} ]];do
|
|
|
3071b7 |
|
|
|
3071b7 |
# Define total number of files. Avoid counting empty line.
|
|
|
3071b7 |
if [[ "${FILES[$COUNT]}" == '' ]];then
|
|
|
3071b7 |
FILESNUM[$COUNT]=0
|
|
|
3071b7 |
else
|
|
|
3071b7 |
FILESNUM[$COUNT]=$(echo "${FILES[$COUNT]}" | wc -l)
|
|
|
3071b7 |
fi
|
|
|
3071b7 |
|
|
|
3071b7 |
# Calculate total amount of changes.
|
|
|
3071b7 |
CHNGTOTAL=$(($CHNGTOTAL + ${FILESNUM[$COUNT]}))
|
|
|
3071b7 |
|
|
|
3071b7 |
# Build report predicate. Use report predicate to show any
|
|
|
3071b7 |
# information specific to the number of files found. For
|
|
|
3071b7 |
# example, you can use this section to show warning messages,
|
|
|
3071b7 |
# notes, and so on. By default we use the word `file' or
|
|
|
3071b7 |
# `files' at ngettext's consideration followed by change
|
|
|
3071b7 |
# direction.
|
|
|
3071b7 |
PREDICATE[$COUNT]=`ngettext "file from the repository" \
|
|
|
3071b7 |
"files from the repository" $((${FILESNUM[$COUNT]} + 1))`
|
|
|
3071b7 |
|
|
|
3071b7 |
# Output report line.
|
|
|
f659fa |
cli_printMessage "${INFO[$COUNT]}: ${FILESNUM[$COUNT]} ${PREDICATE[$COUNT]}"
|
|
|
3071b7 |
|
|
|
3071b7 |
# Increase counter.
|
|
|
3071b7 |
COUNT=$(($COUNT + 1))
|
|
|
3071b7 |
|
|
|
3071b7 |
done
|
|
|
3071b7 |
|
|
|
3071b7 |
}
|