Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionBrowseController.php
| Show First 20 Lines • Show All 1,521 Lines • ▼ Show 20 Lines | private function buildBeforeResponse($before) { | ||||
| $before_uri = $before_uri->alter('renamed', $renamed); | $before_uri = $before_uri->alter('renamed', $renamed); | ||||
| $before_uri = $before_uri->alter('follow', $follow); | $before_uri = $before_uri->alter('follow', $follow); | ||||
| return id(new AphrontRedirectResponse())->setURI($before_uri); | return id(new AphrontRedirectResponse())->setURI($before_uri); | ||||
| } | } | ||||
| private function getBeforeLineNumber($target_commit) { | private function getBeforeLineNumber($target_commit) { | ||||
| $drequest = $this->getDiffusionRequest(); | $drequest = $this->getDiffusionRequest(); | ||||
| $viewer = $this->getViewer(); | |||||
| $line = $drequest->getLine(); | $line = $drequest->getLine(); | ||||
| if (!$line) { | if (!$line) { | ||||
| return null; | return null; | ||||
| } | } | ||||
| $raw_diff = $this->callConduitWithDiffusionRequest( | $diff_info = $this->callConduitWithDiffusionRequest( | ||||
| 'diffusion.rawdiffquery', | 'diffusion.rawdiffquery', | ||||
| array( | array( | ||||
| 'commit' => $drequest->getCommit(), | 'commit' => $drequest->getCommit(), | ||||
| 'path' => $drequest->getPath(), | 'path' => $drequest->getPath(), | ||||
| 'againstCommit' => $target_commit, | 'againstCommit' => $target_commit, | ||||
| )); | )); | ||||
| $file_phid = $diff_info['filePHID']; | |||||
| $file = id(new PhabricatorFileQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withPHIDs(array($file_phid)) | |||||
| ->executeOne(); | |||||
| if (!$file) { | |||||
| throw new Exception( | |||||
| pht( | |||||
| 'Failed to load file ("%s") returned by "%s".', | |||||
| $file_phid, | |||||
| 'diffusion.rawdiffquery.')); | |||||
| } | |||||
| $raw_diff = $file->loadFileData(); | |||||
| $old_line = 0; | $old_line = 0; | ||||
| $new_line = 0; | $new_line = 0; | ||||
| foreach (explode("\n", $raw_diff) as $text) { | foreach (explode("\n", $raw_diff) as $text) { | ||||
| if ($text[0] == '-' || $text[0] == ' ') { | if ($text[0] == '-' || $text[0] == ' ') { | ||||
| $old_line++; | $old_line++; | ||||
| } | } | ||||
| if ($text[0] == '+' || $text[0] == ' ') { | if ($text[0] == '+' || $text[0] == ' ') { | ||||
| ▲ Show 20 Lines • Show All 486 Lines • Show Last 20 Lines | |||||