cvs: SVNROOT / run-conversion.php

[email protected] ("Gwynne Raskind")
Newsgroups svn.migration
Message-ID <cvsgwynne1228456238@cvsserver>
gwynne		Fri Dec  5 05:50:38 2008 UTC

  Modified files:              
    /SVNROOT	run-conversion.php 
  Log:
  - No longer necessary to always run processcvs. In fact, very undesireable. Processcvs and cvs2svn are really interdependant.
  - cp() logs its output in a shared file for sanity
  - fix mv()
  - cp() uses recursive, verbose, preserving options
  - To hell with DIR_SEP, this script will only ever run on y1
  - Several small typos
  - scandir() the copied repo before making the new dirs so we don't rm() them
  - Oops, when you use a dest var, you have to set it for all cases
  - No longer report the repo contents, because we no longer use a repo class
  - Instead of doing a 16-hour full checkout of php-src, do a 10-minute sparse checkout of the root dirs needed
  - httpd.conf is now a static file and won't be generated by this script
gwynne-20081205055038.txt (text/plain, 9.3 KB)
http://cvs.php.net/viewvc.cgi/SVNROOT/run-conversion.php?r1=1.50&r2=1.51&diff_format=u
Index: SVNROOT/run-conversion.php
diff -u SVNROOT/run-conversion.php:1.50 SVNROOT/run-conversion.php:1.51
--- SVNROOT/run-conversion.php:1.50	Wed Dec  3 20:22:26 2008
+++ SVNROOT/run-conversion.php	Fri Dec  5 05:50:37 2008
@@ -7,7 +7,7 @@
 
 // -----------------------------------------------------------------------------------------------------------------------------
 // Constants
-$version = substr('$Revision: 1.50 $', strlen('$Revision: '), -2);
+$version = substr('$Revision: 1.51 $', strlen('$Revision: '), -2);
 
 $passes = array(
     'processcvs',       // Process CVS modules
@@ -41,8 +41,7 @@
 
 function is_running_pass($pass)
 {
-    // We always run processcvs so the other passes have info to work with
-    return $GLOBALS['options']['pass'] === NULL || $GLOBALS['options']['pass'] == $pass || $pass == 'processcvs';
+    return $GLOBALS['options']['pass'] === NULL || $GLOBALS['options']['pass'] == $pass;
 }
 
 function scandir_is_meta($value)
@@ -78,12 +77,12 @@
 
 function cp($source, $dest)
 {
-    run_command("cp " . escapeshellarg($source) . ' ' . escapeshellarg($dest));
+    run_command("cp -Rpv " . escapeshellarg($source) . ' ' . escapeshellarg($dest) . ' >> ' . escapeshellarg("{$GLOBALS['temp_path']}/cp-output"));
 }
 
 function mv($source, $dest)
 {
-    run_command("cp " . escapeshellarg($source) . ' ' . escapeshellarg($dest));
+    run_command("mv " . escapeshellarg($source) . ' ' . escapeshellarg($dest));
 }
 
 function rm($path)
@@ -189,14 +188,14 @@
     
     public function addCVSModule($moduleName, $isMetaModule = false)
     {
-        $cvspath = $GLOBALS['options']['cvsroot'] . DIR_SEP . $moduleName . DIR_SEP;
+        $cvspath = "{$GLOBALS['temp_path']}/cvsrepo/{$moduleName}/";
         if ($isMetaModule) {
             $modprefix = $moduleName . '/';
             foreach(scandir_no_meta($cvspath) as $module) {
                 if (!is_dir($cvspath . $module) || 
                         count(scandir($cvspath . $module)) == 2 || $module == 'Attic' ||
-                        ($moduleName == 'pecl' && $module == 'libextractor') ||
-                        ($moduleName == 'pear' && in_array($module, array('HTML_QuickForm_ComboBox', 'Services_Compete', 'XML_HTMLSax3')))) {
+                        ($moduleName == 'php/pecl' && $module == 'libextractor') ||
+                        ($moduleName == 'pear/modules' && in_array($module, array('HTML_QuickForm_ComboBox', 'Services_Compete', 'XML_HTMLSax3')))) {
                     continue; // empty dir
                 }
                 $this->optionsFileContents .= <<<EOEXTRA
@@ -296,19 +295,19 @@
     mv("{$cvsPath}/ZendEngine2", "{$cvsPath}/php-src/ZendEngine2");
     mv("{$cvsPath}/pdo-specs", "{$cvsPath}/pecl/pdo/specs");
     
+    $cvs_modules = scandir_no_meta($cvsPath);
+
     mkdir("{$cvsPath}/gtk");
     mkdir("{$cvsPath}/php");
     mkdir("{$cvsPath}/pear");
-    mkdir("{$cvsPath)/web");
+    mkdir("{$cvsPath}/web");
     mkdir("{$cvsPath}/phpdoc");
     
-    $cvs_modules = scandir_no_meta($cvsPath);
     foreach ($cvs_modules as $cvs_module) {
         if ($cvs_module == 'CVSROOT') {
             continue;
         }
-        if (!is_dir($options['cvsroot'] . DIR_SEP . $cvs_module) ||
-                count(scandir($options['cvsroot'] . DIR_SEP . $cvs_module)) == 2 ||
+        if (!is_dir("{$cvsPath}/{$cvs_module}") || count(scandir("{$cvsPath}/{$cvs_module}")) == 2 ||
                 in_array($cvs_module, array('smarty', 'smarty-web', 'php4.fubar', 'php4.unused', 'peardoc.backup', 'php3', 'phpfi', 'livedocs',
                     'Zend', 'functable', 'dialin', 'docstuff', 'jpgraph', 'phpoc_de', 'phpdoc-fa_IR', 'lxr', 'portal', 'pres', 'embed', 'imapd'))) {
             rm("{$cvsPath}/{$cvs_module}");
@@ -327,12 +326,16 @@
                 $dest_cvs_module = substr($cvs_module, 0, -4);
             } else if (substr($cvs_module, -3) == 'web') {
                 $dest_cvs_module = substr($cvs_module, 0, -3);
+            } else {
+                $dest_cvs_module = $cvs_module;
             }
             mv("{$cvsPath}/{$cvs_module}", "{$cvsPath}/web/{$dest_cvs_module}");
             $converter->addCVSModule("web/{$dest_cvs_module}");
         } else if (strncmp($cvs_module, "phpdoc", 6) == 0 || $cvs_module == 'doc-base') {
-            if (substr($cvs_module, 7) == 'phpdoc-') {
+            if (substr($cvs_module, 0, 7) == 'phpdoc-') {
                 $dest_cvs_module = substr($cvs_module, 7);
+            } else {
+                $dest_cvs_module = $cvs_module;
             }
             mv("{$cvsPath}/{$cvs_module}", "{$cvsPath}/phpdoc/{$dest_cvs_module}");
             $converter->addCVSModule("phpdoc/{$dest_cvs_module}");
@@ -340,11 +343,6 @@
     }
     
     run_command('find ' . escapeshellarg("{$cvsPath}/pear/modules") . " -name '.svn' -type d -print0 | xargs -0 rm -Rf");
-
-    v(2, "Prepared " . count($repoList) . " SVN repositories.\n");
-    foreach ($repoList as $repo) {
-        v(2, $repo . "\n");
-    }
 }
     
 // -----------------------------------------------------------------------------------------------------------------------------
@@ -378,11 +376,11 @@
     
     $output = run_command('svnlook youngest ' . escapeshellarg($svnPath));
     if (trim(end($output)) != 0) {
-        v(2 "SVN repository isn't empty. Not converting.\n");
+        v(2, "SVN repository isn't empty. Not converting.\n");
         return; // Repo isn't empty
     }
     
-    v(1, "Running cvs2svn for '{$this->repositoryName}'...\n");
+    v(1, "Running cvs2svn for '{$svnPath}'...\n");
     $converter->setOutputPath($svnPath);
     $converter->run();
 }
@@ -396,13 +394,31 @@
     $rawTagList = run_command('exec svn ls file:///' . escapeshellarg("{$svnPath}/tags"));
     $rawBranchList = run_command('exec svn ls file:///' . escapeshellarg("{$svnPath}/branches"));
     
-    if (!file_exists($GLOBALS['temp_path'] . DIR_SEP . 'php-src-co')) {
-        run_command('exec svn checkout file:///' . escapeshellarg($svnPath) . ' ' .
-            escapeshellarg($GLOBALS['temp_path'] . DIR_SEP . 'php-src-co') . ' 2>&1 > ' .
-            escapeshellarg($GLOBALS['temp_path'] . DIR_SEP . 'co-output'));
-    }
     $oldcwd = getcwd();
-    chdir($GLOBALS['temp_path'] . DIR_SEP . 'php-src-co');
+
+    $sparseCoPath = "{$GLOBALS['temp_path']}/php-src-sparse-co";
+    $tmpfilePath = "{$GLOBALS['temp_path']}/sparse-co-output";
+    if (!file_exists($sparseCoPath)) {
+        // Checkout branches, tags, trunk
+        run_command('exec svn checkout --depth immediates file:///' . escapeshellarg($svnPath) . ' ' .
+            escapeshellarg($sparseCoPath) . ' > ' . escapeshellarg($tmpfilePath));
+        // Checkout trunk
+        run_command('cd ' . escapeshellarg("{$sparseCoPath}/trunk") . ' && exec svn update --set-depth immediates >> ' . escapeshellarg($tmpfilePath));
+        // Checkout branch list
+        run_command('cd ' . escapeshellarg("{$sparseCoPath}/branches") . ' && exec svn update --set-depth immediates >> ' . escapeshellarg($tmpfilePath));
+        foreach ($rawBranchList as $branch) {
+            run_command('cd ' . escapeshellarg("{$sparseCoPath}/branches/{$branch}") .
+                ' && exec svn update --set-depth immediates >> ' . escapeshellarg($tmpfilePath));
+        }
+        // Checkout tag list
+        run_command('cd ' . escapeshellarg("{$sparseCoPath}/tags") . ' && exec svn update --set-depth immediates >> ' . escapeshellarg($tmpfilePath));
+        foreach ($rawTagList as $tag) {
+            run_command('cd ' . escapeshellarg("{$sparseCoPath}/tags/{$tag}") .
+                ' && exec svn update --set-depth immediates >> ' . escapeshellarg($tmpfilePath));
+        }
+    }
+    
+    chdir($sparseCoPath);
     
     $tagList = array();
     $branchList = array();
@@ -428,7 +444,7 @@
     $props = array();
     
     foreach ($links as $link) {
-        $info = lstat($GLOBALS['options']['cvsroot'] . DIR_SEP . 'php-src' . DIR_SEP . 'ext' . DIR_SEP . $link);
+        $info = lstat("{$GLOBALS['temp_path']}/cvsrepo/php/php-src/ext/{$link}");
         $createDate = $info['ctime'];
         foreach ($tagList as $tag => $tagDate) {
             $path = 'tags' . DIR_SEP . $tag . DIR_SEP . 'ext';
@@ -458,31 +474,7 @@
 // install pass
 function pass_install()
 {
-    v(2, "Installing global Apache 2.2 configuration file....\n");
-    $svnRoot = $GLOBALS['options']['svnroot'];
-    $logsDir = $svnRoot . DIR_SEP . 'logs' . DIR_SEP;
-    $apacheConf = $svnRoot. DIR_SEP . 'httpd.conf';
-    $confContents = <<<EOHTTPD
-<VirtualHost *:80>
-    ServerName svn.php.net
-    CustomLog "|/local/bin/rotatelogs {$logsDir}/svn-svn_log.%Y%m%d 86400" "%t %u %{SVN-ACTION}e" env=SVN-ACTION
-    CustomLog "|/local/bin/rotatelogs {$logsDir}/svn-access_log.%Y%m%d 86400" combined
-    ErrorLog "|/local/bin/rotatelogs {$logsDir}/svn-error_log.%Y%m%d 86400"
-    <Location "/">
-        DAV svn
-        SVNPath "{$svnRoot}/repository"
-        AuthzSVNAccessFile "{$svnRoot]/SVNROOT/authz.db"
-        Satisfy All
-        Require valid-user
-        AuthType Digest
-        AuthName "PHP Subversion Repositories"
-        AuthUserFile "{$svnRoot}/SVNROOT/users.db"
-        AuthDigestDomain "/"
-    </Location>
-</VirtualHost>
-
-EOHTTPD;
-    file_put_contents($apacheConf, $confContents);
+    v(1, "Installing administrative files...\n");
 
     v(2, "Installing post-commit hook...\n");
     unlink("{$svnRoot}/repository/hooks/post-commit");
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.