messages for subversion errors

leop - February 12, 2008 - 17:54
Project:Subversion
Version:5.x-2.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

It would be cool to have messages that show the errors produced by executed commands for subversion. This gives the user a lot more detail about the nature of the problem, and prevents bug reports of the type "subversion module showing empty page when...". To get drupal error messages, I now use the following code:

<?php
 
// Check if exec produced an error, and report it
 
$svn_error_check = create_function('$in', 'return (substr($in, 0, 4) == "svn:");');
 
$messages = array_filter($output, $svn_error_check);
  if (
count($messages) > 0) {
     
drupal_set_message(implode('<br>', array_filter($output, "$svn_error_check")), 'error', FALSE);
      return array();
  }
?>

after exec(SUBVERSION_WEB_SERVER_SET_HOME_DIR . implode(' ', $cmd), $output); in subversion_ls. This code check whether any of the returned lines from exec starts with 'svn:'. I'm not entirely sure whether this is the right check (since I can only produce errors on the server now), but the svn_error_check can be changed to check whether something is an error message. This code could easily be adjusted to work at other places where an exec command is given. It is important not to cache the results when an error was generated, because otherwise the error won't show up anymore.

 
 

Drupal is a registered trademark of Dries Buytaert.