svn: /web/doc-editor/trunk/ install/firstRun.php php/RepositoryManager.php php/SvnClient.php

[email protected] (Chan Ka Shing)
Newsgroups php.doc.web
Message-ID <[email protected]>
mrkschan                                 Mon, 26 Apr 2010 07:35:17 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=298580

Log:
update install script. svn co will now report failed

Changed paths:
    U   web/doc-editor/trunk/install/firstRun.php
    U   web/doc-editor/trunk/php/RepositoryManager.php
    U   web/doc-editor/trunk/php/SvnClient.php

Modified: web/doc-editor/trunk/install/firstRun.php
===================================================================
--- web/doc-editor/trunk/install/firstRun.php	2010-04-26 07:31:25 UTC (rev 298579)
+++ web/doc-editor/trunk/install/firstRun.php	2010-04-26 07:35:17 UTC (rev 298580)
@@ -36,7 +36,13 @@
     }
     flush();
     // checkout repository from VCS
-    $rm->checkoutRepository();
+    $co_response = $rm->checkoutRepository();
+    if (0 != $co_response['err']) {
+        // error found in checkout, print the output and skip processing
+        echo "\n * Repository checkout failed.\n";
+        echo implode("\n", $co_response['output']);
+        continue;
+    }

     if ($isCLI) {
         echo "\n * Applying tools on repository...";

Modified: web/doc-editor/trunk/php/RepositoryManager.php
===================================================================
--- web/doc-editor/trunk/php/RepositoryManager.php	2010-04-26 07:31:25 UTC (rev 298579)
+++ web/doc-editor/trunk/php/RepositoryManager.php	2010-04-26 07:35:17 UTC (rev 298580)
@@ -116,6 +116,8 @@
     /**
      * Checkout the phpdoc-all repository.
      * This method must be call ONLY by the /firstRun.php script.
+     *
+     * @return An associative array{ 'err': svn co return code, 'output': svn co output contained in an array }
      */
     public function checkoutRepository()
     {
@@ -125,10 +127,12 @@

         if ($lock->lock()) {
             // exec the checkout
-            VCSFactory::getInstance()->checkout();
+            $rtn = VCSFactory::getInstance()->checkout();
         }

         $lock->release();
+
+        return $rtn;
     }

     /**
@@ -184,7 +188,7 @@
         array_shift($t);

         $pathWithoutLang = '/' . implode("/", $t).'/';
-
+
         // If we are in the root folder, we have //. We must consider this case.
         if( $pathWithoutLang == '//' ) { $pathWithoutLang = '/'; }

@@ -211,16 +215,16 @@
                         $actualFiles[$actual[$i]['text']] = array( "name"=> $actual[$i]['text'], "version"=> "" );
                     }
                 }
-
+
                 // We get versions for this files
                 while( list($k, $v) = each($actualFiles) ) {

                     $file = new File($firstFolder, $pathWithoutLang, $k);
                     $info = $file->getInfo();
                     $actualFiles[$k]['version'] = $info['rev'];
-
+
                 }
-
+
             }

             // We update the repository recursively
@@ -253,7 +257,7 @@

                 debug(json_encode($nowFiles));
                 debug(json_encode($actualFiles));
-
+
                 // We search for differences
                 reset($nowFiles); reset($nowFolders);
                 while( list($k, $v) = each($nowFiles) ) {
@@ -660,7 +664,7 @@
         if( !$folders ) {
             return false;
         }
-
+
         $return = array();

         function parsePath($path, &$pathInfo) {
@@ -696,7 +700,7 @@
         }
         return $return;
     }
-
+
     /**
      * Commit file changes to repository.
      *
@@ -708,7 +712,7 @@
     {
         $rf        = RepositoryFetcher::getInstance();
         $commitLog = Array();
-
+
         // Get informations about files we need to commit
         $fileInfos = $rf->getModifiesById($ids);

@@ -724,7 +728,7 @@
             $commitLog = array_merge($commitLog, $c);
             $this->delPendingCommit($foldersInfos);
         }
-
+
         // Task for files
         // Loop over $fileInfos to find files to be create, update or delete
         $create_stack = array();
@@ -1541,7 +1545,7 @@
      */
     public function delFiles($files)
     {
-
+
         for ($i = 0; $i < count($files); $i++) {
             $query = sprintf('DELETE FROM files
                 WHERE

Modified: web/doc-editor/trunk/php/SvnClient.php
===================================================================
--- web/doc-editor/trunk/php/SvnClient.php	2010-04-26 07:31:25 UTC (rev 298579)
+++ web/doc-editor/trunk/php/SvnClient.php	2010-04-26 07:35:17 UTC (rev 298580)
@@ -228,6 +228,8 @@
      *  cd DOC_EDITOR_DATA_PATH
      *  svn co http://DOC_EDITOR_VCS_SERVER_HOST:DOC_EDITOR_VCS_SERVER_PORT/DOC_EDITOR_VCS_SERVER_PATH DOC_EDITOR_VCS_MODULE
      *
+     * @return An associative array{ 'err': svn co return code, 'output': svn co output contained in an array }
+     *
      *  see http://wiki.php.net/doc/scratchpad/howto/checkout
      */
     public function checkout()
@@ -242,14 +244,18 @@
         $module = $appConf[$project]['vcs.module'];

         $cmd = 'cd '.$appConf['GLOBAL_CONFIGURATION']['data.path'].'; '
-              ."svn co http://$host:$port/$uri $module; ";
+              ."svn co http://$host:$port/$uri $module";

+        $err = 1;
         $trial_threshold = 3;
-        while ($trial_threshold-- > 0) {
-            $output = array();
-            exec($cmd, $output);
-            if (strlen(trim(implode('', $output))) != 0) break;
+        $output = array();
+        for ($trial = 0; $err != 0 && $trial < $trial_threshold; ++$trial) {
+            array_push($output, "svn co trial #$trial\n");
+            exec("$cmd 2>&1", $output, $err); // if no err, err = 0
+            if ($err == 0) array_push($output, "Success.\n");
         }
+
+        return array('err' => $err, 'output' => $output);
     }

     /**
@@ -412,14 +418,14 @@
     public function createCommitLogFile($log)
     {
         $path = tempnam(sys_get_temp_dir(), 'Doc_Editor_Commit_Log_Message');
-
+
         $handle = fopen($path, "w");
         fwrite($handle, $log);
         fclose($handle);

         return $path;
     }
-
+
     public function deleteCommitLogFile($path)
     {
         @unlink($path);
@@ -483,7 +489,7 @@
         $vcsLang   = $am->vcsLang;
         $vcsLogin  = $am->vcsLogin;
         $vcsPasswd = $am->vcsPasswd;
-
+
         // Info we must store into DB
         $info = array();

@@ -526,7 +532,7 @@
         // Buil the command line

         $cmdCreate = $cmdDelete = $cmdUpdate = '';
-
+
         if (trim($filesCreate) != '') {
             $cmdCreate = "svn add $filesCreate ; svn propset svn:keywords \"Id Rev Revision Date LastChangedDate LastChangedRevision Author LastChangedBy HeadURL URL\" $filesCreate ; svn propset svn:eol-style \"native\" $filesCreate ; ";
         }
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.