tags:

views:

114

answers:

2

I'm running SVN on a Windows server, and I'm using Perl scripts to implement some pre-commit hooks. I'm seeing the following error message from TortoiseSVN:

Error !!ScriptError!! Can't parse line: _U path/to/files/trunk

and this is the script:

foreach my $line (`$svnlook changed -t "$txn" "$repos"`)
{
  chomp($line);
  if ($line !~ /([AUD]).\s\s(.+)$/)
  {
    print STDERR "!!Script Error!! Can't parse line: $line\n";
    exit(1);
  }
  else
  {
     # perform some actions 
  }
}

exit(0);

I tried replacing the regex with things like /_([AUD]).\s\s(.+)$/ with no sucess - I even tried /.*([AUD]).\s\s(.+)$/.

Thoughts? Suggestions?

+3  A: 

Without a look into the SVN documentation I'm just guessing: In the output above only one space is shown between U and the actual path, but you have \s\s in all your regexes.

[edit] Ok, now I had a look into the svnlook reference. First, your regex fails for current versions of svnlook, as the output is specified as follows:

  • The first two columns contain the status
  • the path starts at the fifth column
  • Status may be one of A (added), U (content changed), D (deleted), _U (properties changes), and UU (content + properties changed)

So, you should be able to match with something like ^([_AUD]+)\s+(.+)$. One can get more specific, but that ain't necessary.

If this doesn't match, please pipe the command's output to a file, and post the relevant part here.

gimpf
I replaced it with :if ($line !~ /^\s+([AUD])\s+(.+)$/)but no success - it appears to be irritated by that leading underscore, but I'm wondering if that's actually an underscore or if it's something else like a mangled encoded character.
dls
The last time I looked at the svnlook source code, it really was an underscore. I'd recommend looking at the source code to determine what really may be output. The help isn't fully up-to-date nor accurate in regards to the legal output.
Kaleb Pederson
It is, but googleing it always returns the help for version 1.0...
gimpf
yeah, I found that same documentation and updated the regex to this:`if ($line !~ /^\s*(A|D|U|UU|_U)\s*(.+)$/)`which works much better. Thanks!
dls
A: 

if ($line !~ /^_?([AUD])\s+(.+)$/ should work fine.

jamessan
this works much better for the complete set of svnlook identifiers:`if ($line !~ /^\s*(A|D|U|UU|_U)\s*(.+)$/)`
dls
Ah, yeah. I missed the `UU` bit when I checked the documentation.
jamessan