[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

RE: Problem with deleting locked file using http: scheme

From: Giulio Troccoli <Giulio.Troccoli_at_uk.linedata.com>
Date: Fri, 28 Nov 2008 12:14:18 +0000

>

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

-----Original Message-----

> From: Bert Huijben [mailto:b.huijben_at_competence.biz]
> Sent: 28 November 2008 10:50
> To: Giulio Troccoli; users_at_subversion.tigris.org
> Subject: RE: Problem with deleting locked file using http: scheme
>
> > -----Original Message-----
> > From: Giulio Troccoli [mailto:Giulio.Troccoli_at_uk.linedata.com]
> > Sent: vrijdag 28 november 2008 10:53
> > To: Giulio Troccoli; users_at_subversion.tigris.org
> > Subject: RE: Problem with deleting locked file using http: scheme
> >
>
>
> > I don't usual do this, but it's been few days now and I'm surprise that
> > nobody has even tried to replicate my problem (given I posted a nice
> > script to do so). So maybe my email has just gone unnoticed.
>
> This mail (with the script) you forwarded now, didn't reach me via this
> list.
>
> Maybe some of the moderators can answer why it didn't appear?
>
> Bert

Thanks for letting me know Bert. Maybe it was because I attached the scripts. Anyway, here is the original email and the scripts (not attached this time).

Hi everybody.

We have a repository that contains a lot of Word and Excel documents. I have therefore implemented a locking process and instructed my user to lock, modify and then commit.

As recommended I have also written a pre-commit hook that checks whether the files being committed are Word or Excel document and in that case whether they are locked (by the same user) or not.

One of my users came back to me the other day saying she was trying to delete a Word document but the pre-commit hook rejected the commit because the file was not locked. The file had been locked however.

After some research I found out before the pre-commit hook was executed the lock has disappeared. I was trying to replicate the error but behold, it worked!! Finally, today I find out that it worked because I was using the file: protocol. So, I modified the script I used to use the http: protocol (and I have modified the Apache configuration too) and I have successfully reproduced the error.

I know this is not strictly a Subversion issue, but could anybody help me. I'm not an expert in Apache and I don't really now how to read the log file.

I am using Subversion 1.4.4 and Apache 2.0 on a RHEL4 server.

I have attached the script I used (svn-lock-test.ksh) and the pre-commit hook (lock-test-pre-commit). You will need to comment/uncomment the checkout line to use either the file: or http: protocol. The pre-commit hook is actually an extract of the real pre-commit hook, but I have deleted all the bits related to other projects we have in the same repository

####
# svn-lock-test.ksh
####
#!/bin/ksh

set -x

SVNADMIN=/usr/bin/svnadmin
SVNLOOK=/usr/bin/svnlook
SVN=/usr/bin/svn
CP=/bin/cp
RM=/bin/rm
CHMOD=/bin/chmod

HOME=/home/svn
REPO_PATH=$HOME/lock-test-repo
REPO_URL=localhost/lock-test-repo
WC=$HOME/lock-test-wc

$RM -rf $REPO_PATH $WC

$SVNADMIN create $REPO_PATH

#$SVN co file:///$REPO_PATH $WC
$SVN co http://$REPO_URL $WC

$SVN info $WC > $WC/test.txt
$SVN add $WC/test.txt
$SVN ci $WC -m"add"

$SVN up $WC

$SVN lock $WC/test.txt
$SVN rm $WC/test.txt

$CP $HOME/lock-test-pre-commit $REPO_PATH/hooks/pre-commit $CHMOD u+x $REPO_PATH/hooks/pre-commit

$SVN st $WC
$SVNLOOK lock $REPO_PATH test.txt

$SVN ci $WC -m"delete"
$SVN st $WC
$SVNADMIN lslocks $REPO_PATH

####
#lock-test-pre-commit
####
#!/bin/ksh

REPOS="$1"
TXN="$2"
REPOS_PATH=$REPOS
TRANSACTION=$TXN

# Make sure that the log message contains some text.
SVNLOOK=/usr/bin/svnlook
SVN=/usr/bin/svn
AWK=/bin/awk
SED=/bin/sed
GREP=/bin/grep
HEAD=/usr/bin/head
TAIL=/usr/bin/tail
CUT=/bin/cut
ECHO=/bin/echo
TR=/usr/bin/tr
MAIL=/bin/mail
CAT=/bin/cat
MKTEMP=/bin/mktemp

DOC_XLS_FILES=`$MKTEMP`
$SVNLOOK changed --transaction $TRANSACTION $REPOS_PATH | $CUT -c1,5- > $DOC_XLS_FILES

$CAT $DOC_XLS_FILES > /dev/stderr
for line in `$CAT $DOC_XLS_FILES`; do
   status=`$ECHO $line | $CUT -c1`
   file=`$ECHO $line | $CUT -c2-`

         # Check that the file is locked (Only for not new files)
         if [ "$status" != "A" ]; then
            # The quotes around $file are necessary as it can contain spaces which will screw the svnlook command
            LOCK_OWNER=`$SVNLOOK lock $REPOS_PATH "$file" | $GREP '^Owner: ' | $SED 's/Owner: //'`
            if [ "$LOCK_OWNER" = "" ]; then
               $ECHO "" > /dev/stderr
               $ECHO "*****************************************************************" > /dev/stderr
               $ECHO "ERROR: All .doc and .xls files need to be locked to be committed." > /dev/stderr
               $ECHO " The following file is not:" > /dev/stderr
               $ECHO " - "$file > /dev/stderr
               $ECHO "*****************************************************************" > /dev/stderr
               exit 1
            fi
         fi

         # Check if svn:needs-lock is set (Only for files that we are not deleting)
         if [ "$status" != "D" ]; then
            # The quotes around $file are necessary as it can contain spaces which will screw the svnlook command
            needslock=`$SVNLOOK proplist --transaction $TRANSACTION $REPOS_PATH "$file" | $GREP svn:needs-lock`
            if [ "$needslock" = "" ]; then
               $ECHO "" > /dev/stderr
               $ECHO "***************************************************************" > /dev/stderr
               $ECHO "ERROR: All .doc. and .xls files need to have the svn:needs-lock" > /dev/stderr
               $ECHO " property set. At least the following file has not:" > /dev/stderr
               $ECHO " - "$file > /dev/stderr
               $ECHO "***************************************************************" > /dev/stderr
               exit 1
            fi
         fi

done

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_subversion.tigris.org
For additional commands, e-mail: users-help_at_subversion.tigris.org
Received on 2008-11-28 13:14:53 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.