Changeset View
Changeset View
Standalone View
Standalone View
src/parser/ArcanistBundle.php
| Show First 20 Lines • Show All 373 Lines • ▼ Show 20 Lines | foreach (array_keys($changes) as $multicopy_key) { | ||||
| // The multicopy is now fully represented by MOVE_HERE plus one or more | // The multicopy is now fully represented by MOVE_HERE plus one or more | ||||
| // COPY_HERE, so throw it away. | // COPY_HERE, so throw it away. | ||||
| unset($changes[$multicopy_key]); | unset($changes[$multicopy_key]); | ||||
| break; | break; | ||||
| } | } | ||||
| if (!$decompose_okay) { | if (!$decompose_okay) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "Failed to decompose multicopy changeset in order to generate diff."); | 'Failed to decompose multicopy changeset in order to generate diff.'); | ||||
| } | } | ||||
| } | } | ||||
| foreach ($changes as $change) { | foreach ($changes as $change) { | ||||
| $type = $change->getType(); | $type = $change->getType(); | ||||
| $file_type = $change->getFileType(); | $file_type = $change->getFileType(); | ||||
| if ($file_type == ArcanistDiffChangeType::FILE_DIRECTORY) { | if ($file_type == ArcanistDiffChangeType::FILE_DIRECTORY) { | ||||
| ▲ Show 20 Lines • Show All 367 Lines • ▼ Show 20 Lines | if ($new_data === null) { | ||||
| $new_data = ''; | $new_data = ''; | ||||
| $new_sha1 = str_repeat('0', 40); | $new_sha1 = str_repeat('0', 40); | ||||
| } else { | } else { | ||||
| $new_sha1 = sha1("blob {$new_length}\0{$new_data}"); | $new_sha1 = sha1("blob {$new_length}\0{$new_data}"); | ||||
| } | } | ||||
| $content = array(); | $content = array(); | ||||
| $content[] = "index {$old_sha1}..{$new_sha1}".$eol; | $content[] = "index {$old_sha1}..{$new_sha1}".$eol; | ||||
| $content[] = "GIT binary patch".$eol; | $content[] = 'GIT binary patch'.$eol; | ||||
| $content[] = "literal {$new_length}".$eol; | $content[] = "literal {$new_length}".$eol; | ||||
| $content[] = $this->emitBinaryDiffBody($new_data).$eol; | $content[] = $this->emitBinaryDiffBody($new_data).$eol; | ||||
| $content[] = "literal {$old_length}".$eol; | $content[] = "literal {$old_length}".$eol; | ||||
| $content[] = $this->emitBinaryDiffBody($old_data).$eol; | $content[] = $this->emitBinaryDiffBody($old_data).$eol; | ||||
| return implode('', $content); | return implode('', $content); | ||||
| } | } | ||||
| private function emitBinaryDiffBody($data) { | private function emitBinaryDiffBody($data) { | ||||
| $eol = $this->getEOL('git'); | $eol = $this->getEOL('git'); | ||||
| if (!function_exists('gzcompress')) { | if (!function_exists('gzcompress')) { | ||||
| throw new Exception( | throw new Exception( | ||||
| "This patch has binary data. The PHP zlib extension is required to ". | 'This patch has binary data. The PHP zlib extension is required to '. | ||||
| "apply patches with binary data to git. Install the PHP zlib ". | 'apply patches with binary data to git. Install the PHP zlib '. | ||||
| "extension to continue."); | 'extension to continue.'); | ||||
| } | } | ||||
| // See emit_binary_diff_body() in diff.c for git's implementation. | // See emit_binary_diff_body() in diff.c for git's implementation. | ||||
| $buf = ''; | $buf = ''; | ||||
| $deflated = gzcompress($data); | $deflated = gzcompress($data); | ||||
| $lines = str_split($deflated, 52); | $lines = str_split($deflated, 52); | ||||
| ▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines | |||||