Exemplo n.º 1
0
 /**
  * Short description of method singleton
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @return core_kernel_file_File
  */
 public static function singleton()
 {
     $returnValue = null;
     if (self::$instance == null) {
         self::$instance = new self();
     }
     $returnValue = self::$instance;
     return $returnValue;
 }
Exemplo n.º 2
0
 /**
  * Retrieve given version of a file from a path
  *
  * @access public
  * @author Cédric Alfonsi, <*****@*****.**>
  * @param  File resource
  * @param  string path
  * @param  string version
  * @return boolean
  */
 public function resolve(core_kernel_file_File $resource, $path, $version)
 {
     $returnValue = (bool) false;
     $startTime = helpers_Time::getMicroTime();
     $listParentFolder = helpers_File::scandir(dirname($path));
     return core_kernel_versioning_subversionWindows_File::singleton()->resolve($resource, $path, $version);
     var_dump('resolving');
     switch ($version) {
         case VERSIONING_FILE_VERSION_MINE:
             //use our version of the file before the update we made the conflict
             $resource->setContent(file_get_contents($path . '.mine'));
             //delete the noisy files (mine, r***)
             var_dump($listParentFolder, $path, preg_quote($path), '@^' . preg_quote($path) . '\\.@');
             foreach ($listParentFolder as $file) {
                 if (preg_match('@^' . preg_quote($path) . '\\.@', $file)) {
                     var_dump('deleted noisy file ' . $path);
                     unlink($file);
                 }
             }
             $returnValue = true;
             break;
         case VERSIONING_FILE_VERSION_THEIRS:
             //use the incoming version of the file
             if ($resource->revert() && $resource->update()) {
                 $returnValue = true;
             }
             break;
         case VERSIONING_FILE_VERSION_WORKING:
             //nothing to do, we keep the current version of the file
             $returnValue = true;
             break;
         default:
             //@todo change with invalid argument exception
             throw new common_Exception('invalid argument version');
     }
     //$returnValue = core_kernel_versioning_subversionWindows_File::singleton()->resolve($resource, $path, $version);
     $endTime = helpers_Time::getMicroTime();
     common_Logger::i("svn_resolve ('.{$path}.' : '.{$version}.') -> " . ($endTime - $startTime) . 's');
     return (bool) $returnValue;
 }