From 1b2140d7a48782980fa3df69cd21e88c0b7af48a Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 2 Apr 2011 17:11:51 -0700 Subject: [PATCH] Unmuck some issues with viewing HEAD changes. --- .../change/DiffusionChangeController.php | 15 +++++++-------- .../query/diff/base/DiffusionDiffQuery.php | 14 ++++++++++++++ .../diffusion/query/diff/base/__init__.php | 1 + .../query/diff/git/DiffusionGitDiffQuery.php | 15 +++++++++++++-- .../query/diff/svn/DiffusionSvnDiffQuery.php | 9 +++++++++ .../diffusion/request/base/DiffusionRequest.php | 5 +++++ 6 files changed, 49 insertions(+), 10 deletions(-) diff --git a/src/applications/diffusion/controller/change/DiffusionChangeController.php b/src/applications/diffusion/controller/change/DiffusionChangeController.php index 5d73afcab7..1f9a836eb5 100644 --- a/src/applications/diffusion/controller/change/DiffusionChangeController.php +++ b/src/applications/diffusion/controller/change/DiffusionChangeController.php @@ -23,14 +23,6 @@ class DiffusionChangeController extends DiffusionController { $content = array(); - $content[] = $this->buildCrumbs( - array( - 'branch' => true, - 'path' => true, - 'view' => 'change', - )); - - $diff_query = DiffusionDiffQuery::newFromDiffusionRequest($drequest); $changeset = $diff_query->loadChangeset(); @@ -39,6 +31,13 @@ class DiffusionChangeController extends DiffusionController { $changeset_view->setRenderURI( '/diffusion/'.$drequest->getRepository()->getCallsign().'/diff/'); + $content[] = $this->buildCrumbs( + array( + 'branch' => true, + 'path' => true, + 'view' => 'change', + )); + // TODO: This is pretty awkward, unify the CSS between Diffusion and // Differential better. require_celerity_resource('differential-core-view-css'); diff --git a/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php b/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php index f9c858f98b..275a08e915 100644 --- a/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php +++ b/src/applications/diffusion/query/diff/base/DiffusionDiffQuery.php @@ -57,4 +57,18 @@ abstract class DiffusionDiffQuery { } abstract protected function executeQuery(); + + protected function getEffectiveCommit() { + $drequest = $this->getRequest(); + + $modified_query = DiffusionLastModifiedQuery::newFromDiffusionRequest( + $drequest); + list($commit) = $modified_query->loadLastModification(); + if (!$commit) { + // TODO: Improve error messages here. + return null; + } + return $commit->getCommitIdentifier(); + } + } diff --git a/src/applications/diffusion/query/diff/base/__init__.php b/src/applications/diffusion/query/diff/base/__init__.php index 500696c5a5..d6ecf69496 100644 --- a/src/applications/diffusion/query/diff/base/__init__.php +++ b/src/applications/diffusion/query/diff/base/__init__.php @@ -6,6 +6,7 @@ +phutil_require_module('phabricator', 'applications/diffusion/query/lastmodified/base'); phutil_require_module('phabricator', 'applications/repository/constants/repositorytype'); phutil_require_module('phutil', 'symbols'); diff --git a/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php b/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php index 38099827bd..53fbf740b7 100644 --- a/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php +++ b/src/applications/diffusion/query/diff/git/DiffusionGitDiffQuery.php @@ -22,6 +22,17 @@ final class DiffusionGitDiffQuery extends DiffusionDiffQuery { $drequest = $this->getRequest(); $repository = $drequest->getRepository(); + if (!$drequest->getRawCommit()) { + $effective_commit = $this->getEffectiveCommit(); + if (!$effective_commit) { + return null; + } + // TODO: This side effect is kind of skethcy. + $drequest->setCommit($effective_commit); + } else { + $effective_commit = $drequest->getCommit(); + } + $options = array( '-M', '-C', @@ -36,8 +47,8 @@ final class DiffusionGitDiffQuery extends DiffusionDiffQuery { list($raw_diff) = execx( "(cd %s && git diff {$options} %s^ %s -- %s)", $repository->getDetail('local-path'), - $drequest->getCommit(), - $drequest->getCommit(), + $effective_commit, + $effective_commit, $drequest->getPath()); $parser = new ArcanistDiffParser(); diff --git a/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php b/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php index c8e7916148..8dca68469e 100644 --- a/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php +++ b/src/applications/diffusion/query/diff/svn/DiffusionSvnDiffQuery.php @@ -21,6 +21,15 @@ final class DiffusionSvnDiffQuery extends DiffusionDiffQuery { protected function executeQuery() { $drequest = $this->getRequest(); + if (!$drequest->getRawCommit()) { + $effective_commit = $this->getEffectiveCommit(); + if (!$effective_commit) { + return null; + } + // TODO: Sketchy side effect. + $drequest->setCommit($effective_commit); + } + $path_change_query = DiffusionPathChangeQuery::newFromDiffusionRequest( $drequest); $path_changes = $path_change_query->loadChanges(); diff --git a/src/applications/diffusion/request/base/DiffusionRequest.php b/src/applications/diffusion/request/base/DiffusionRequest.php index c4b89144be..378dd9e7ed 100644 --- a/src/applications/diffusion/request/base/DiffusionRequest.php +++ b/src/applications/diffusion/request/base/DiffusionRequest.php @@ -140,6 +140,11 @@ class DiffusionRequest { return $this->commit; } + public function setCommit($commit) { + $this->commit = $commit; + return $this; + } + public function getCommitURIComponent($commit) { return $commit; }