perlsvnsvnlook

How can I match the svnlook output in Perl?


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?


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:

    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.