Re: SVN MOVE don't perform a delete in some case
On Fri, Apr 16, 2010 at 09:40:34AM +0200, Yann Crueghe wrote: > Hi ! Hi! > *Test 1 : Try to rename a directory BRANCHE to BRANCHE_1* > > *Command :* > svn move --message "Rename BRANCHE to BRANCHE_1" > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRANCHE > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRANCHE_1 > > *Hook params :* > D y78amodifier/branches/BRANCHE/ > > *Command result : * A repository hook failed > svn: Commit blocked by pre-commit hook (exit code 1) with output: > It's not allowed to rename or delete a branch. > > > *Test 2 : Try to rename a directory BRANCHE to BRANCH* > > *Command :* > svn move --message "Rename BRANCHE to BR" > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRANCHE > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BR > > *Hook params :* > A y78amodifier/branches/BRANCH/ > > *Command result : * Commit done without error. > > Do you think it's a bug ? I don't know. On the surface this looks like a bug, but we need to find out what the real problem is. For that, you'll need to help others reproduce this problem on their own machines. Can you try to show a list of commands that starts by creating an empty repository, imports some files or folders, installs the hook script, and then runs some svn commands to trigger the problem? Thanks, Stefan
RE: SVN MOVE don't perform a delete in some case
> Linedata Services (UK) Ltd Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB Registered in England and Wales No 3027851VAT Reg No 778499447 -Original Message- > From: Stefan Sperling [mailto:s...@elego.de] > Sent: 16 April 2010 08:52 > To: Yann Crueghe > Cc: users@subversion.apache.org > Subject: Re: SVN MOVE don't perform a delete in some case > > On Fri, Apr 16, 2010 at 09:40:34AM +0200, Yann Crueghe wrote: > > Hi ! > > Hi! > > > *Test 1 : Try to rename a directory BRANCHE to BRANCHE_1* > > > > *Command :* > > svn move --message "Rename BRANCHE to BRANCHE_1" > > > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRAN > > CHE > > > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRAN > > CHE_1 > > > > *Hook params :* > > D y78amodifier/branches/BRANCHE/ > > > > *Command result : * A repository hook failed > > svn: Commit blocked by pre-commit hook (exit code 1) with output: > > It's not allowed to rename or delete a branch. > > > > > > *Test 2 : Try to rename a directory BRANCHE to BRANCH* > > > > *Command :* > > svn move --message "Rename BRANCHE to BR" > > > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRAN > > CHE > > http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BR > > > > *Hook params :* > > A y78amodifier/branches/BRANCH/ > > > > *Command result : * Commit done without error. > > > > Do you think it's a bug ? > > I don't know. On the surface this looks like a bug, but we > need to find out what the real problem is. For that, you'll > need to help others reproduce this problem on their own machines. > > Can you try to show a list of commands that starts by > creating an empty repository, imports some files or folders, > installs the hook script, and then runs some svn commands to > trigger the problem? > I should see the whole pre-commit hook but I think you parse the list of files being committed and rely on some kind of order, e.g. the deletion being the first of the list. I had a similar situation and I found out that (and this is documented) you can not rely on the order of the output of svnlook changed (or any other commands for that matter). So, I think you will have to parse the whole list of files and if there is a delete then exit with an error. Again, this is just hypothetical, as I don't know your pre-commit hook. G
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_branche 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 Giulio Troccoli a écrit : Linedata Services (UK) Ltd Registered Office: Bishopsgate Court, 4-12 Norton Folgate, London, E1 6DB Registered in England and Wales No 3027851VAT Reg No 778499447 -----Original Message----- From: Stefan Sperling [mailto:s...@elego.de] Sent: 16 April 2010 08:52 To: Yann Crueghe Cc: users@subversion.apache.org Subject: Re: SVN MOVE don't perform a delete in some case On Fri, Apr 16, 2010 at 09:40:34AM +0200, Yann Crueghe wrote: Hi ! Hi! *Test 1 : Try to rename a directory BRANCHE to BRANCHE_1* *Command :* svn move --message "Rename BRANCHE to BRANCHE_1" http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRAN CHE http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRAN CHE_1 *Hook params :* D y78amodifier/branches/BRANCHE/ *Command result : * A repository hook failed svn: Commit blocked by pre-commit hook (exit code 1) with output: It's not allowed to rename or delete a branch. *Test 2 : Try to rename a directory BRANCHE to BRANCH* *Command :* svn move --message "Rename BRANCHE to BR" http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BRAN CHE http://tetris.agora.msanet:16060/svn/METIER/y78amodifier/branches/BR *Hook params :* A y78amodifier/branches/BRANCH/ *Command result : * Commit done without error. Do you think it's a bug ? I don't know. On the surface this looks like a bug, but we need to find out what the real problem is. For that, you'll need to help others reproduce this problem on their own machines. Can you try to show a list of commands that starts by creating an empty repository, imports some files or folders, installs the hook script, and then runs some svn commands to trigger the problem? I should see the whole pre-commit hook but I think you parse the list of files being committed and rely on some kind of order, e.g. the deletion being the first of the list. I had a similar situation and I found out that (and this is documented) you can not rely on the order of the output of svnlook changed (or any other commands for that matter). So, I think you will have to parse the whole list of files and if there is a delete then exit with an error. Again, this is just hypothetical, as I don't know your pre-commit hook. G Ce message est protégé par les règles relatives au secret des correspondances. Il est donc établi à destination exclusive de son destinataire. Celui-ci peut donc contenir des informations confidentielles. La divulgation de ces informations est à ce titre rigoureusement interdite. Si vous avez reçu ce message par erreur, merci de
RE: SVN MOVE don't perform a delete in some case
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 3027851VAT Reg No 778499447 From: ext_crueghe.y...@agora.msa.fr [mailto:ext_crueghe.y...@agora.msa.fr] Sent: 16 April 2010 10:17 To: Giulio Troccoli Cc: 'Stefan Sperling'; users@subversion.apache.org 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_branche 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