gwynne          Fri Oct 24 02:45:27 2008 UTC

  Added files:                 
    /SVNROOT    run-conversion.php 
  Log:
  initial version of conversion script
  

http://cvs.php.net/viewvc.cgi/SVNROOT/run-conversion.php?view=markup&rev=1.1
Index: SVNROOT/run-conversion.php
+++ SVNROOT/run-conversion.php
<?php

$version = '$Rev$';

print "PHP Group CVS->SVN respository conversion version {$version}.\n";
print "Started at " . date(DATE_RFC2822) . "\n";

$CVSROOT = "/home/repository";
$SVNROOT = "/home/repository-svn";

$do_cvs2svn = TRUE;
$do_svnrm = TRUE;
$do_reorg = TRUE;

function is_option($optName, $arg, &$value)
{
    if (strncmp($arg, $optName, strlen($optName)) == 0) {
        if (!is_null($value)) {
            $value = substr($arg, strlen($optName) + 1);
        }
        return true;
    }
    return false;
}

foreach ($argv as $i => $arg) {
    if (is_option("--cvsroot", $arg, $value)) {
        $CVSROOT = $value;
    } else if (is_option("--svnroot", $arg, $value)) {
        $SVNROOT = $value;
    } else if (is_option("--cvs2svn", $arg, $value)) {
        $do_cvs2svn = ($value == 'true');
    } else if (is_option("--svnrm", $arg, $value)) {
        $do_svnrm = ($value == 'true');
    } else if (is_option("--reorg", $arg, $value)) {
        $do_reorg = ($value == 'true');
    }
}

if ($do_cvs2svn) {
    print "Running cvs2svn...\n";
    
    $cvs2svn_process = proc_open("cvs2svn --options=phpsvn.options", array(
            0 => array('pipe', 'r'),
            1 => array('file', './phpsvn.conversion.out', 'w'),
            2 => array('pipe', 'w'),
        ), $pipes, NULL, NULL);
    fclose($pipes[0]);
    $procinfo = array();
    
    do {
        usleep(500000);
        $procinfo = proc_get_status($cvs2svn_process);
    } while ($procinfo['running'] == TRUE);
    
    $errorText = stream_get_contents($pipes[2]);
    fclose($pipes[2]);
    
    proc_close($cvs2svn_process);
    
    if ($procinfo['exitcode'] != 0) {
        print "Error executing cvs2svn. Error output is:\n{$errorText}\n";
        exit($procinfo['exitcode']);
    }
}

if ($do_svnrm) {
    print "Running svn rm...\n";
    
    exec("svn rm -m \"[SVN CONVERSION] Removing .svn directories that break SVN 
checkout.\" " .
            "file:///{$SVNROOT}/pear/Selenium/branches/shin/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/branches/shin/tests/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/branches/shin/tests/events/.svn " 
.
            "file:///{$SVNROOT}/pear/Selenium/branches/shin/tests/html/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/branches/shin/docs/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/branches/shin/examples/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/tags/start/tests/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/tags/start/tests/events/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/tags/start/tests/html/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/tags/start/docs/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/tags/start/examples/.svn " .
            "file:///{$SVNROOT}/pear/Selenium/tags/start/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/branches/shin/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/branches/shin/tests/.svn 
" .
            
"file:///{$SVNROOT}/pear/Testing_Selenium/branches/shin/tests/events/.svn " .
            
"file:///{$SVNROOT}/pear/Testing_Selenium/branches/shin/tests/html/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/branches/shin/docs/.svn " 
.
            
"file:///{$SVNROOT}/pear/Testing_Selenium/branches/shin/examples/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/tags/start/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/tags/start/tests/.svn " .
            
"file:///{$SVNROOT}/pear/Testing_Selenium/tags/start/tests/events/.svn " .
            
"file:///{$SVNROOT}/pear/Testing_Selenium/tags/start/tests/html/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/tags/start/docs/.svn " .
            "file:///{$SVNROOT}/pear/Testing_Selenium/tags/start/examples/.svn 
2>&1", $svnrm_output, $exitstatus);
    if ($exitstatus != 0) {
        print "Error executing svn rm. Error output is:\n" . implode("\n", 
$svnrm_output) . "\n";
        exit($exitstatus);
    }
}

if ($do_reorg) {
    print "If this were implemented yet, a series of svn cp, svn rm, and svn mv 
commands would follow. It isn't, so they don't. Sorry.\n";
    exit(1);
}

print "Finished at " . date(DATE_RFC2822) . "\n";

?>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to