public function __construct(array $leftFiles, array $rightFiles, array $originalFiles)
 {
     if (count($originalFiles) != count($leftFiles)) {
         throw new Engine_File_Diff_Exception("Count of left, right, and original did not match");
     }
     $this->_originalFiles = $originalFiles;
     parent::__construct($leftFiles, $rightFiles);
 }
Exemple #2
0
 public function getDiffBatch()
 {
     $rightFilesRaw = $this->getDiffTargetFiles();
     $originalFilesRaw = $this->getDiffCurrentFiles();
     //$leftFilesRaw = $this->getDiffMasterFiles();
     $leftFilesRaw = array_unique(array_merge(array_keys($originalFilesRaw), array_keys($originalFilesRaw)));
     sort($leftFilesRaw);
     $leftFiles = array();
     $rightFiles = array();
     $originalFiles = array();
     $leftPath = $this->getManager()->getBasePath();
     $rightPath = null !== $this->getTargetPackage() ? $this->getTargetPackage()->getBasePath() : null;
     $originalPath = null !== $this->getCurrentPackage() ? $this->getCurrentPackage()->getBasePath() : null;
     foreach ($leftFilesRaw as $file) {
         // Skip directories
         // Format left
         $left = $file;
         // Format right
         $right = null;
         if (isset($rightFilesRaw[$file])) {
             if (isset($rightFilesRaw[$file]['dir']) && $rightFilesRaw[$file]['dir']) {
                 continue;
             }
             $right = $rightFilesRaw[$file];
             //$right = $this->_formatFileData($rightFilesRaw[$file], $rightPath, $file);
         }
         // Format original
         $original = null;
         if (isset($originalFilesRaw[$file])) {
             if (isset($originalFilesRaw[$file]['dir']) && $originalFilesRaw[$file]['dir']) {
                 continue;
             }
             $original = $originalFilesRaw[$file];
             //$original = $this->_formatFileData($originalFilesRaw[$file], $originalPath, $file);
         }
         $leftFiles[] = $this->_formatFileData($left, $leftPath, $file);
         $rightFiles[] = $this->_formatFileData($right, $rightPath, $file);
         $originalFiles[] = $this->_formatFileData($original, $originalPath, $file);
     }
     // Skip the three-way (since we don't have any source info)
     if (empty($originalFilesRaw)) {
         $originalFiles = null;
     }
     $diff = Engine_File_Diff_Batch::factory($leftFiles, $rightFiles, $originalFiles);
     //$diff->targetPackage = $this->getTargetPackage();
     //$diff->currentPackage = $this->getCurrentPackage();
     $diff->packageKey = $this->getKey();
     $diff->packageGuid = $this->getGuid();
     // Backwards compatibility
     //$diff->package = $diff->targetPackage;
     //$diff->previousPackage = $diff->currentPackage;
     // Execute now?
     $diff->execute();
     // set file ops and diff summary
     $this->_setFileOperations($diff);
     $this->_setDiffSummary($diff);
     return $diff;
 }