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

RE: Re: Need checkout commits...

From: Lieven Govaerts <lgo_at_mobsol.be>
Date: 2005-12-12 19:41:40 CET

Graeme,
>
> Quoting "Thompson, Graeme (AELE)"
> <Graeme.Thompson@smiths-aerospace.com>:
>
> >
> > I have just tried this with a subversion 1.2.3 server on
> SUSE 10 and a
> > TortoiseSVN 1.2.6 client.
> >
> > It does not *Require* you to have a lock in order to commit a file
> > with the svn:needs-lock property. You can simply make the file
> > writable and then do a commit and it will happily go ahead
> and update the repository.
> >
> > Is there any way to get this to be a requirement, e.g. through a
> > pre-commit hook similar to the suggested one to ensure that
> all files
> > have the svn:needs-lock property set?
> >
> > If so then has anyone got any examples of how to do this?
>
> This would be easy to build using "svnlook propget".
> If no one has an example file available I'll create one this evening.

this simple pre-commit script checks if all files in a transaction were
locked
in the repository. It doesn't check if that was your lock ( commit will fail
anyway ), nor does it filter on extensions ( not that difficult to add ).

You might clean it up a bit.

--------------
#!/bin/bash

isFileLocked()
{
        COMMITFILES=`svnlook changed -t $TXN $REPOS`

        #save the current IFS
        OLDIFS=$IFS
        IFS=$'\n'
        
      # iterate over all files in the transaction
        for line in $COMMITFILES; do
          line=`echo $line | cut -c 5-`
            LOCKSET=`svnlook lock $REPOS "/$line" | grep "UUID Token" | wc
-c`
            if [ $LOCKSET = 0 ]; then
              #reset the old IFS
              IFS=$OLDIFS
              REPLY=$line
              return 1
          fi
      done
                
        #return the old IFS
        IFS=$OLDIFS
        REPLY=""
        return 0
}

REPOS="$1"
TXN="$2"
        
isFileLocked

if [ $? = 1 ]; then
        echo "Failed commit because file '$REPLY' wasn't locked before
commit!" >&2
   exit 1
fi

# All checks passed, so allow the commit.
exit 0
-----------------

Hope this helps.

regards,

Lieven.

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.371 / Virus Database: 267.13.13/197 - Release Date: 9/12/2005
 
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Mon Dec 12 19:46:40 2005

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.