Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top