Changeset 16151

Show
Ignore:
Timestamp:
04/20/08 16:12:38 (8 months ago)
Author:
rambo
Message:

forward port r16150

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/fi.hut.staticdumps/bin/post_dump_svn.php

    r15937 r16151  
    120120*/ 
    121121 
     122/** 
     123 * Sort array of filenames to alphabetical tree order 
     124 */ 
     125function by_tree($a_part, $b_part) 
     126{ 
     127    global $dump_path; 
     128    $a_path = $dump_path . $a_part; 
     129    $b_path = $dump_path . $b_part; 
     130    $a_components = explode('/', $a_part); 
     131    $b_components = explode('/', $b_part); 
     132    $a_score = count($a_components); 
     133    $b_score = count($b_components); 
     134    if (is_dir($a_path)) 
     135    { 
     136        --$a_score; 
     137    } 
     138    if (is_dir($b_path)) 
     139    { 
     140        --$b_score; 
     141    } 
     142    if ($a_score === $b_score) 
     143    { 
     144        // Equal scores, sort by strnatcmp 
     145        return strnatcmp($a_part, $b_part); 
     146    } 
     147    // Standard gt/lt response 
     148    if ($a_score > $b_score) 
     149    { 
     150        return 1; 
     151    } 
     152    if ($a_score < $b_score) 
     153    { 
     154        return -1; 
     155    } 
     156} 
     157 
     158usort($remove_files, 'by_tree'); 
     159$remove_files = array_reverse($remove_files); 
     160/* 
     161echo "DEBUG: remove_files (ofter sort)\n"; 
     162print_r($remove_files); 
     163*/ 
    122164foreach ($remove_files as $partial_path) 
    123165{ 
     
    140182} 
    141183 
     184usort($add_files, 'by_tree'); 
     185/* 
     186echo "DEBUG: add_files (after sort)\n"; 
     187print_r($add_files); 
     188*/ 
    142189foreach ($add_files as $partial_path) 
    143190{ 
     
    208255} 
    209256 
     257/* 
     258echo "DEBUG: svn diff {$svn_path}\n"; 
     259$svn_diff_cmd = "cd {$svn_path} && svn diff"; 
     260system($svn_diff_cmd); 
     261*/ 
     262 
    210263$commit_message = "Automatic commit of {$site_url} with " . basename($argv[0]); 
    211264$svn_commit_cmd = "cd {$svn_path} && svn commit -m " . escapeshellarg($commit_message);