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

Re: pre commit trigger

From: David Weintraub <qazwart_at_gmail.com>
Date: Wed, 13 May 2009 12:06:55 -0400

Perl passes it's command line arguments from the @ARGV array. Delete
the following two lines:

   $ARGV[0]= $1;
   $ARGV[1]=$2;

This is overwriting what you're passing into the Perl script.

What you're doing is overwriting what is being passed to your Perl script.

Remember, I already have a Perl hook script that already prevents you
from committing files with spaces in their names. Feel free to use it:
<http://dl.getdropbox.com/u/433257/hooks.zip>.

On Wed, May 13, 2009 at 11:52 AM, Irfan Sayed <irfu.sayed_at_gmail.com> wrote:
> Ok but now how should i fix the issue.
> i modified the code as :
>
> #!/usr/bin/perl
>
> $svnlook = "/usr/bin/svnlook";
> $ARGV[0]= $1;
> $ARGV[1]=$2;
>
> chomp($repo = $ARGV[0]);
> chomp($txn = $ARGV[1]);
>
> $option = "-t";
> print STDERR "$txn\n";
>
> my @cmd = `$svnlook changed $option $txn $repo`;
> foreach(@cmd)
> {
>  if ($_ =~/^A/)
> {
>  print STDERR "added\n";
>  exit 1;
> }
> else{
>  print STDERR "hi\n";
>  print STDERR "not added\n";
>  exit 1;
> }
>
> }
>
> now i am able to commit
> but i am not able to see any print output which i mention in foreach
> loop. i modified the code so it should print "not added" in the
> console output
>
> please advise
> regards
> irf
>
>
>
>
> On Wed, May 13, 2009 at 8:58 PM, Andy Levy <andy.levy_at_gmail.com> wrote:
>>
>> On Wed, May 13, 2009 at 11:22, Irfan Sayed <irfu.sayed_at_gmail.com> wrote:
>> > thanks really for reply.
>> > Ok.
>> >
>> > Now script is executing but it is giving transaction id instead of
>> > path which is being commited
>> >
>> > here is the script
>> > #!/usr/bin/perl
>> >
>> > $svnlook = "/usr/bin/svnlook";
>> > chomp($repo = $ARGV[0]);
>> > chomp($txn = $ARGV[1]);
>> >
>> > $option = "-t";
>> > print STDERR "$txn\n";
>> >
>> > my @cmd = `$svnlook changed $option $txn $repo`;
>> > foreach(@cmd)
>> > {
>> >  if ($_ =~/^A/)
>> > {
>> >  print STDERR "added\n";
>> >  exit 1;
>> > }
>> > else{
>> >  print STDERR "not added\n";
>> >  exit 1;
>> > }
>> > }
>> >
>> >
>> > and the output which i got in tortoise svn client is
>> >
>> > Commit failed (details follow):
>> > Commit blocked by pre-commit hook (exit code 1) with output:
>> > 127-4b
>> > not added
>>
>> You're getting exactly what you should be getting. Look at your source:
>>
>> > chomp($repo = $ARGV[0]);
>> > chomp($txn = $ARGV[1]);
>> >
>> > $option = "-t";
>> > print STDERR "$txn\n";
>>
>> > i am modifying existing source code file so in foreach loop first
>> > condition will fail. now in this output "127-4b" is the transaction id
>> > but what i am expecting here is the path which is getting commited
>>
>> You're expecting the path being committed but your code is outputting
>> the transaction ID.
>

-- 
David Weintraub
qazwart_at_gmail.com
------------------------------------------------------
http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=2239674
To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
Received on 2009-05-13 18:08:09 CEST

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.