Changeset View
Changeset View
Standalone View
Standalone View
src/parser/ArcanistBundle.php
| Show First 20 Lines • Show All 418 Lines • ▼ Show 20 Lines | foreach ($changes as $change) { | ||||
| if ($cur_path === null) { | if ($cur_path === null) { | ||||
| $cur_index = 'b/'.$old_path; | $cur_index = 'b/'.$old_path; | ||||
| $cur_target = '/dev/null'; | $cur_target = '/dev/null'; | ||||
| } else { | } else { | ||||
| $cur_index = 'b/'.$cur_path; | $cur_index = 'b/'.$cur_path; | ||||
| $cur_target = 'b/'.$cur_path; | $cur_target = 'b/'.$cur_path; | ||||
| } | } | ||||
| $old_target = $this->encodeGitTargetPath($old_target); | |||||
| $cur_target = $this->encodeGitTargetPath($cur_target); | |||||
| $result[] = "diff --git {$old_index} {$cur_index}".$eol; | $result[] = "diff --git {$old_index} {$cur_index}".$eol; | ||||
| if ($type == ArcanistDiffChangeType::TYPE_ADD) { | if ($type == ArcanistDiffChangeType::TYPE_ADD) { | ||||
| $result[] = "new file mode {$new_mode}".$eol; | $result[] = "new file mode {$new_mode}".$eol; | ||||
| } | } | ||||
| if ($type == ArcanistDiffChangeType::TYPE_COPY_HERE || | if ($type == ArcanistDiffChangeType::TYPE_COPY_HERE || | ||||
| $type == ArcanistDiffChangeType::TYPE_MOVE_HERE || | $type == ArcanistDiffChangeType::TYPE_MOVE_HERE || | ||||
| ▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Lines | while ($ii < $n) { | ||||
| $old_offset += ($jj - $ii) - $new_lines; | $old_offset += ($jj - $ii) - $new_lines; | ||||
| $new_offset += ($jj - $ii) - $old_lines; | $new_offset += ($jj - $ii) - $old_lines; | ||||
| $ii = $jj; | $ii = $jj; | ||||
| } | } | ||||
| return $results; | return $results; | ||||
| } | } | ||||
| private function encodeGitTargetPath($path) { | |||||
| // See T8768. If a target path contains spaces, it must be terminated with | |||||
| // a tab. If we don't do this, Mercurial has the wrong behavior when | |||||
| // applying the patch. This results in a semantic trailing whitespace | |||||
| // character: | |||||
| // | |||||
| // +++ b/X Y.txt\t | |||||
| // | |||||
| // Everyone is at fault here and there are no winners. | |||||
| if (strpos($path, ' ') !== false) { | |||||
| $path = $path."\t"; | |||||
| } | |||||
| return $path; | |||||
| } | |||||
| private function getOldPath(ArcanistDiffChange $change) { | private function getOldPath(ArcanistDiffChange $change) { | ||||
| $old_path = $change->getOldPath(); | $old_path = $change->getOldPath(); | ||||
| $type = $change->getType(); | $type = $change->getType(); | ||||
| if (!strlen($old_path) || | if (!strlen($old_path) || | ||||
| $type == ArcanistDiffChangeType::TYPE_ADD) { | $type == ArcanistDiffChangeType::TYPE_ADD) { | ||||
| $old_path = null; | $old_path = null; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 334 Lines • Show Last 20 Lines | |||||