cvs: SVNROOT / pre-commit

[email protected] ("Gwynne Raskind") Mon, 22 Jun 2009 12:38:57 -0000
Newsgroups svn.migration
Message-ID <cvsgwynne1245674337@cvsserver>
gwynne		Mon Jun 22 12:38:57 2009 UTC

  Modified files:              
    /SVNROOT	pre-commit 
  Log:
  fixed a few mistakes
  
http://cvs.php.net/viewvc.cgi/SVNROOT/pre-commit?r1=1.7&r2=1.8&diff_format=u
Index: SVNROOT/pre-commit
diff -u SVNROOT/pre-commit:1.7 SVNROOT/pre-commit:1.8
--- SVNROOT/pre-commit:1.7	Mon Jun 22 12:22:26 2009
+++ SVNROOT/pre-commit	Mon Jun 22 12:38:57 2009
@@ -15,7 +15,7 @@
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.7 $', strlen('$Revision: '), -2);
+$version = substr('$Revision: 1.8 $', strlen('$Revision: '), -2);
 $is_DEBUG = (isset($_ENV['DEBUG']) && $_ENV['DEBUG'] === 'DEBUG');
 
 // -----------------------------------------------------------------------------------------------------------------------------
@@ -26,7 +26,7 @@
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Arguments
-if ($argc != 3) {
+if ($argc != 3 && !$is_DEBUG) {
     fail("Pass exactly two arguments: REPOS and TXN.\n");
 }
 $REPOS = $argv[1];
@@ -36,7 +36,8 @@
 // Utility
 function run_svnlook($command, $extra_args = array())
 {
-    exec('exec svnlook ' . escapeshellarg($command) . ' -t ' . escapeshellarg($GLOBALS['TXN']) . ' ' . 
+    $selector = $GLOBALS['is_DEBUG'] ? '-r' : '-t';
+    exec('exec svnlook ' . escapeshellarg($command) . " {$selector} " . escapeshellarg($GLOBALS['TXN']) . ' ' . 
         escapeshellarg($GLOBALS['REPOS']) . ' ' . implode(' ', array_map('escapeshellarg', $extra_args)) . ' 2>&1', $output, $status);
     if ($status != 0) {
         fail("svnlook failed with exit code {$status}\nOutput:\n" . implode("\n", $output) . "\n");
@@ -73,7 +74,7 @@
     $paths_changed = explode("\n", $data[0]);
     $dirs_changed = explode("\n", $data[1]);
     $log_message = array('test1', 'test2');
-    $author = $argv[2];
+    $author = $argv[3];
 } else {
     $paths_changed = run_svnlook('changed');
     $dirs_changed = run_svnlook('dirs-changed');
@@ -164,16 +165,15 @@
 // -----------------------------------------------------------------------------------------------------------------------------
 // Changing text files requires svn:keywords set
 $paths_added = array_filter($paths_changed, create_function('$v', 'return ($v[0] === "A");'));
-$didError = 0;
 foreach ($paths_added as $path_added) {
     $path_added = substr($path_added, strpos($path_added, ' ') + 1);
     if ($is_DEBUG) {
         print "DEBUG: Checking properties for {$path_added}.\n";
     }
 
-    $properties = array_map('trim', run_svnlook('proplist', FALSE, NULL, array($path_added)));
-    if (in_array($properties, 'svn:mime-type')) {
-        $mimetype = trim(implode("\n", run_svnlook('propget', FALSE, NULL, array('svn:mime-type', $path_added))));
+    $properties = array_map('trim', run_svnlook('proplist', array($path_added)));
+    if (in_array('svn:mime-type', $properties)) {
+        $mimetype = trim(implode("\n", run_svnlook('propget', array('svn:mime-type', $path_added))));
     } else {
         $mimetype = 'text/unknown';
     }
@@ -182,7 +182,7 @@
         if ($is_DEBUG) {
             print "DEBUG: File is non-binary. Checking for keywords.\n";
         }
-        if (!in_array($properties, 'svn:keywords')) {
+        if (!in_array('svn:keywords', $properties)) {
             fail("svn:keywords not set on textual file {$path_added}.\n");
         }
         if ($is_DEBUG) {