Please do not top-post or post in HTML
See http://subversion.apache.org/docs/community-guide/mailing-lists.html
Now, scroll down for my response
Linedata Services (UK) Ltd
Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB
Registered in England and Wales No 3027851 VAT Reg No 778499447
________________________________
From: [email protected]
[mailto:[email protected]]
Sent: 16 April 2010 10:17
To: Giulio Troccoli
Cc: 'Stefan Sperling'; [email protected]
Subject: Re: SVN MOVE don't perform a delete in some case
Hi !
Thank you very much for your quick replies !
In fact, the only thing that the hook control is that the user don't
try to delete a directory (he can delete the content) in an other directory
called "branches"
ie : myapp /branches/my_branch/myfile.txt
/trunk/myfile.txt
/tags
The hook must block the user when he want to delete or rename
/branches/my_branch
The user can alter the file /branches/my_branch/myfile.txt
The hook work when i try to delete the directory
The hook work when i try to rename the /branches/my_branch to
/branches/my_brancheeeeeeeeeeeeeeeee
The hook work when i try to rename the /branches/my_branch to
/branches/another_branch
The hook won't work when i try to rename the /branches/my_branch to
/branches/my_bra (no svn delete perform)
Here is a partial copy of the hook (light from the original which
control more things)
I prepare the svn commands to reproduce this comportment ASAP
Thank you very much
# sortie en erreur
function exit_error {
echo "$1" >&2
exit 1
}
# sortie ok
function exit_success {
exit 0
}
# parametres d'appels du hook
SVN_REPO_PATH="$1"
SVN_TXN_ID="$2"
# Binaires et fichiers de configuration du serveur SVN
SVNLOOK=/opt/CollabNet_Subversion/bin/svnlook
# Constantes
STR_BRANCHES="branches"
STR_CODE_SVN_DELETE="D"
# extraction de l'action et de la ressource cible
CHANGED=$($SVNLOOK changed -t "$SVN_TXN_ID" "$SVN_REPO_PATH")
set -- $CHANGED
ACTION=$1
RESSOURCE=$2
# extraction du repertoire impacte par le commit
PATH_VARS=$(echo $RESSOURCE | tr '[:upper:]' '[:lower:]' | awk -F"/"
'{print $1,$2,$3,$4}')
set -- $PATH_VARS
APPLICATION=$1
REPERTOIRE=$2
ELEMENT=$3
CHEMIN=$4
# Securisation des branches
if [[ $REPERTOIRE = $STR_BRANCHES ]]
then
# Suppression sur une branche
if [[ $ACTION = $STR_CODE_SVN_DELETE ]]
then
# Suppression de la branche ou du tag interdite aux dev. metier
et responsables metier
if [[ ! $CHEMIN ]]
then exit_error "La suppression d'une BRANCHE ou d'un TAG est
interdite"
fi
fi
fi
exit_success
This does exacttly what I thought. Svnlook change will return a list of files,
but your 'set' command will set $1 and $2 based on the first. In the case you
report where this pre-commit hook does not work, svnlook return the addition
first, so you set $1 to A and $2 to '/branches/my_bra' and that's why your
script does not work.
You need a loop to go through the output from svnlook. I use something like this
$SVNLOOK changed --revision $REVISION $REPOS_PATH | $AWK '{OFS=";"; print
$1,$2}' > $TMPDIR/changes_list
for line in `$CAT $TMPDIR/changes_list`; do
status=`$ECHO $line | $CUT -d';' -f1`
file=`$ECHO $line | $CUT -d';' -f2`
# If the file is a new file
if [ "$status" == "D" ]; then
# Check it's a branch and not a file
fi
done
G