You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Phil <pl...@gmail.com> on 2006/11/10 01:01:47 UTC

pre-commit hook script help

I need a hook script that will either check to make sure svn:needs-lock is
set for all files or a hook script that will set svn:needs-lock for all
files.
I have the following hook script that works but only for files WITHOUT
spaces in the file name...

Could someone help me by suggestiong how I can improve the following script
or perhaps they have written one that works that I could modify.

Here is my pre-commit script:
#!/bin/bash

SVNLOOK=/usr/local/bin/svnlook
SED=/bin/sed


# Arguments passed to the script.
REPO="$1"
TXN="$2"

# Get the list of files (but not directories) that were added or whose
properties were modified.
the_files=`$SVNLOOK changed -t "$TXN" "$REPO" | $SED -n
's/^\(A\|.U\)\s*\(.*[^/]\)$/\2/p'`
for a_file in $the_files; do

    # Attempt to get the svn:needs-lock property.
    $SVNLOOK propget -t "$TXN" "$REPO" svn:needs-lock "$a_file" >/dev/null
2>&1

    # Exit and alert if an error occurred doing that.
    if [ $? -ne 0 ]; then
        echo "File $a_file doesn't have the svn:needs-lock property set."
1>&2
        echo "Repository policy dictates that all files must set the
svn:needs-lock property." 1>&2
        exit 1
    fi

done

# If we haven't exited by now, everything must be fine.
exit 0

Re: pre-commit hook script help

Posted by Justin Patrin <pa...@gmail.com>.
On 11/10/06, Phil <pl...@gmail.com> wrote:
> Still no luck...
>
> does anyone have a hook script that checks files for properties upon check
> in that I can modify?
>

My pre-commit hook for checking the mime-type of files....it's in
python but it may still help:
http://pear.reversefold.com/dokuwiki/doku.php?id=svn:pre-commit

>
> On 11/9/06, Gavin Lambert < gavinl@compacsort.com> wrote:
> > Quoth Phil <mailto: plabonte@gmail.com>:
> > > I need a hook script that will either check to make sure
> > > svn:needs-lock is set for all files or a hook script that will set
> > > svn:needs-lock for all files. I have the following hook script that
> > > works but only for files WITHOUT spaces in the file name...
> > >
> > > Could someone help me by suggestiong how I can improve the following
> > > script or perhaps they have written one that works that I could
> > > modify.
> >
> > Wild guess (ie. not tested at all): try changing this line:
> >
> > > the_files=`$SVNLOOK changed -t "$TXN" "$REPO" | $SED -n
> > > 's/^\(A\|.U\)\s*\(.*[^/]\)$/\2/p'`
> >
> > to have double-quotes around the \2.
> >
> > >         echo "File $a_file doesn't have the svn:needs-lock property
> > >         set." 1>&2 echo "Repository policy dictates that all files
> > >         must set the svn:needs-lock property." 1>&2 exit 1
> >
> > Just out of curiosity: why?  Normally needs-lock is only a good idea for
> > binary or otherwise unmergable files.  Having files locked all the time
> > is a major pain in the butt, especially if you have distributed
> > developers.
> >
> >
> >
>
>


-- 
Justin Patrin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: pre-commit hook script help

Posted by Phil <pl...@gmail.com>.
Still no luck...

does anyone have a hook script that checks files for properties upon check
in that I can modify?

On 11/9/06, Gavin Lambert <ga...@compacsort.com> wrote:
>
> Quoth Phil <ma...@gmail.com>:
> > I need a hook script that will either check to make sure
> > svn:needs-lock is set for all files or a hook script that will set
> > svn:needs-lock for all files. I have the following hook script that
> > works but only for files WITHOUT spaces in the file name...
> >
> > Could someone help me by suggestiong how I can improve the following
> > script or perhaps they have written one that works that I could
> > modify.
>
> Wild guess (ie. not tested at all): try changing this line:
>
> > the_files=`$SVNLOOK changed -t "$TXN" "$REPO" | $SED -n
> > 's/^\(A\|.U\)\s*\(.*[^/]\)$/\2/p'`
>
> to have double-quotes around the \2.
>
> >         echo "File $a_file doesn't have the svn:needs-lock property
> >         set." 1>&2 echo "Repository policy dictates that all files
> >         must set the svn:needs-lock property." 1>&2 exit 1
>
> Just out of curiosity: why?  Normally needs-lock is only a good idea for
> binary or otherwise unmergable files.  Having files locked all the time
> is a major pain in the butt, especially if you have distributed
> developers.
>
>
>

RE: pre-commit hook script help

Posted by Gavin Lambert <ga...@compacsort.com>.
Quoth Phil <ma...@gmail.com>:
> I need a hook script that will either check to make sure
> svn:needs-lock is set for all files or a hook script that will set
> svn:needs-lock for all files. I have the following hook script that
> works but only for files WITHOUT spaces in the file name...  
> 
> Could someone help me by suggestiong how I can improve the following
> script or perhaps they have written one that works that I could
> modify.  

Wild guess (ie. not tested at all): try changing this line:

> the_files=`$SVNLOOK changed -t "$TXN" "$REPO" | $SED -n
> 's/^\(A\|.U\)\s*\(.*[^/]\)$/\2/p'` 

to have double-quotes around the \2.

>         echo "File $a_file doesn't have the svn:needs-lock property
>         set." 1>&2 echo "Repository policy dictates that all files
>         must set the svn:needs-lock property." 1>&2 exit 1

Just out of curiosity: why?  Normally needs-lock is only a good idea for
binary or otherwise unmergable files.  Having files locked all the time
is a major pain in the butt, especially if you have distributed
developers.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org