Changeset View
Changeset View
Standalone View
Standalone View
src/parser/ArcanistBundle.php
| Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | private function getEOL($patch_type) { | ||||
| switch ($patch_type) { | switch ($patch_type) { | ||||
| case 'git': | case 'git': | ||||
| return "\n"; | return "\n"; | ||||
| case 'unified': | case 'unified': | ||||
| return phutil_is_windows() ? "\r\n" : "\n"; | return phutil_is_windows() ? "\r\n" : "\n"; | ||||
| default: | default: | ||||
| throw new Exception( | throw new Exception( | ||||
| "Unknown patch type '{$patch_type}'!"); | pht("Unknown patch type '%s'!", $patch_type)); | ||||
| } | } | ||||
| } | } | ||||
| public static function newFromArcBundle($path) { | public static function newFromArcBundle($path) { | ||||
| $path = Filesystem::resolvePath($path); | $path = Filesystem::resolvePath($path); | ||||
| $future = new ExecFuture( | $future = new ExecFuture( | ||||
| 'tar tfO %s', | 'tar tfO %s', | ||||
| ▲ Show 20 Lines • Show All 232 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.'); | pht( | ||||
| '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 297 Lines • ▼ Show 20 Lines | if ($this->diskPath) { | ||||
| list($blob_data) = execx('tar xfO %s blobs/%s', $this->diskPath, $phid); | list($blob_data) = execx('tar xfO %s blobs/%s', $this->diskPath, $phid); | ||||
| return $blob_data; | return $blob_data; | ||||
| } | } | ||||
| $console = PhutilConsole::getConsole(); | $console = PhutilConsole::getConsole(); | ||||
| if ($this->conduit) { | if ($this->conduit) { | ||||
| if ($name) { | if ($name) { | ||||
| $console->writeErr("Downloading binary data for '%s'...\n", $name); | $console->writeErr( | ||||
| "%s\n", | |||||
| pht("Downloading binary data for '%s'...", $name)); | |||||
| } else { | } else { | ||||
| $console->writeErr("Downloading binary data...\n"); | $console->writeErr("%s\n", pht('Downloading binary data...')); | ||||
| } | } | ||||
| $data_base64 = $this->conduit->callMethodSynchronous( | $data_base64 = $this->conduit->callMethodSynchronous( | ||||
| 'file.download', | 'file.download', | ||||
| array( | array( | ||||
| 'phid' => $phid, | 'phid' => $phid, | ||||
| )); | )); | ||||
| return base64_decode($data_base64); | return base64_decode($data_base64); | ||||
| } | } | ||||
| throw new Exception("Nowhere to load blob '{$phid}' from!"); | throw new Exception(pht("Nowhere to load blob '%s' from!", $phid)); | ||||
| } | } | ||||
| private function buildBinaryChange(ArcanistDiffChange $change, $old_binary) { | private function buildBinaryChange(ArcanistDiffChange $change, $old_binary) { | ||||
| $eol = $this->getEOL('git'); | $eol = $this->getEOL('git'); | ||||
| // In Git, when we write out a binary file move or copy, we need the | // In Git, when we write out a binary file move or copy, we need the | ||||
| // original binary for the source and the current binary for the | // original binary for the source and the current binary for the | ||||
| // destination. | // destination. | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | private function buildBinaryChange(ArcanistDiffChange $change, $old_binary) { | ||||
| 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( | ||||
| pht( | |||||
| '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 | |||||