Esempio n. 1
0
 /**
  * Retrieve file's status
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  File resource
  * @param  string path
  * @param  array options
  * @return int
  */
 public function getStatus(core_kernel_file_File $resource, $path, $options = array())
 {
     $returnValue = (int) 0;
     $startTime = helpers_Time::getMicroTime();
     if ($resource->getRepository()->authenticate()) {
         //Status of the target
         $status = null;
         //Get a list of statuses
         $svnStatusOptions = SVN_NON_RECURSIVE;
         if ($options['SHOW_UPDATES']) {
             $svnStatusOptions = $svnStatusOptions | SVN_SHOW_UPDATES;
         }
         $statuses = @svn_status($path, $svnStatusOptions);
         // * An explanation could be that the file is in a non working copy directory, it occured when we create a folders structure
         if ($statuses !== false) {
             //Extract required status
             foreach ($statuses as $s) {
                 if ($s['path'] == $path) {
                     $status = $s;
                 }
             }
             // If the file has a status, check the status is not unversioned or added
             if (!is_null($status)) {
                 if ($status['locked']) {
                     $returnValue = VERSIONING_FILE_STATUS_LOCKED;
                 } else {
                     if ($status['repos_text_status'] == VERSIONING_FILE_STATUS_DELETED) {
                         $returnValue = VERSIONING_FILE_STATUS_REMOTELY_DELETED;
                     } else {
                         if ($status['repos_text_status'] == VERSIONING_FILE_STATUS_MODIFIED) {
                             $returnValue = VERSIONING_FILE_STATUS_REMOTELY_MODIFIED;
                         } else {
                             $returnValue = $status['text_status'];
                         }
                     }
                 }
             } else {
                 if (!file_exists($path)) {
                     $returnValue = VERSIONING_FILE_STATUS_UNVERSIONED;
                 } else {
                     $returnValue = VERSIONING_FILE_STATUS_NORMAL;
                 }
             }
         } else {
             $returnValue = VERSIONING_FILE_STATUS_UNVERSIONED;
         }
     }
     $endTime = helpers_Time::getMicroTime();
     common_Logger::i("svn_getStatus ('.{$path}.') '.{$returnValue}.' -> " . ($endTime - $startTime) . 's');
     return (int) $returnValue;
 }