From 8ce5dd31f63cbcf4649b39b89fb795d28ef28de8 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sun, 2 Oct 2011 12:52:54 -0700 Subject: [PATCH] Show open Differential revisions in Diffusion browse views Summary: Still some rough edges, but this adds a table of open revisions to Diffusion. See T262. I'll make this a little better (e.g., "see all.." instead of arbitrary 10 cap, or maybe move to top-level nav?) but I think I have to refactor some other stuff first. This should let us root out any major issues, at least. NOTE: You must associate Arcanist Projects with Repositories (in Repositories -> Arcanist Projects -> Edit) for this to work! Also made paths include all parent paths so that browse views of directories will work. Test Plan: Uploaded a diff which affected "/blah", it appeared when browsing "/" and "/blah". Reviewers: jungejason, nh, tuomaspelkonen, aran Reviewed By: jungejason CC: aran, jungejason Differential Revision: 979 --- .../revision/DifferentialRevisionEditor.php | 14 ++++++- .../controller/base/DiffusionController.php | 38 +++++++++++++++++++ .../diffusion/controller/base/__init__.php | 5 +++ .../browse/DiffusionBrowseController.php | 2 + .../file/DiffusionBrowseFileController.php | 2 + 5 files changed, 59 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index 7842884e2c..a8a9769d00 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -773,13 +773,23 @@ class DifferentialRevisionEditor { $paths[] = $path_prefix.'/'.$changeset->getFileName(); } - $path_map = id(new DiffusionPathIDQuery($paths))->loadPathIDs($paths); + // Mark this as also touching all parent paths, so you can see all pending + // changes to any file within a directory. + $all_paths = array(); + foreach ($paths as $local) { + foreach (DiffusionPathIDQuery::expandPathToRoot($local) as $path) { + $all_paths[$path] = true; + } + } + $all_paths = array_keys($all_paths); + + $path_map = id(new DiffusionPathIDQuery($all_paths))->loadPathIDs(); $table = new DifferentialAffectedPath(); $conn_w = $table->establishConnection('w'); $sql = array(); - foreach ($paths as $path) { + foreach ($all_paths as $path) { $path_id = idx($path_map, $path); if (!$path_id) { // Don't bother creating these, it probably means we're either adding diff --git a/src/applications/diffusion/controller/base/DiffusionController.php b/src/applications/diffusion/controller/base/DiffusionController.php index 132a9854be..0d5fa73c0c 100644 --- a/src/applications/diffusion/controller/base/DiffusionController.php +++ b/src/applications/diffusion/controller/base/DiffusionController.php @@ -108,6 +108,44 @@ abstract class DiffusionController extends PhabricatorController { return $crumbs; } + protected function buildOpenRevisions() { + $drequest = $this->getDiffusionRequest(); + $repository = $drequest->getRepository(); + $path = $drequest->getPath(); + + $path_map = id(new DiffusionPathIDQuery(array($path)))->loadPathIDs(); + $path_id = idx($path_map, $path); + if (!$path_id) { + return null; + } + + $revisions = id(new DifferentialRevisionQuery()) + ->withPath($repository->getID(), $path_id) + ->withStatus(DifferentialRevisionQuery::STATUS_OPEN) + ->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED) + ->setLimit(10) + ->needRelationships(true) + ->execute(); + + if (!$revisions) { + return null; + } + + $view = id(new DifferentialRevisionListView()) + ->setRevisions($revisions) + ->setUser($this->getRequest()->getUser()); + + $phids = $view->getRequiredHandlePHIDs(); + $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); + $view->setHandles($handles); + + $panel = new AphrontPanelView(); + $panel->setHeader('Pending Differential Revisions'); + $panel->appendChild($view); + + return $panel; + } + private function buildCrumbList(array $spec = array()) { $drequest = $this->getDiffusionRequest(); diff --git a/src/applications/diffusion/controller/base/__init__.php b/src/applications/diffusion/controller/base/__init__.php index d154ac6eba..2be5bb582b 100644 --- a/src/applications/diffusion/controller/base/__init__.php +++ b/src/applications/diffusion/controller/base/__init__.php @@ -8,10 +8,15 @@ phutil_require_module('phabricator', 'aphront/response/webpage'); phutil_require_module('phabricator', 'applications/base/controller/base'); +phutil_require_module('phabricator', 'applications/differential/query/revision'); +phutil_require_module('phabricator', 'applications/differential/view/revisionlist'); +phutil_require_module('phabricator', 'applications/diffusion/query/pathid/base'); phutil_require_module('phabricator', 'applications/diffusion/request/base'); phutil_require_module('phabricator', 'applications/diffusion/view/base'); +phutil_require_module('phabricator', 'applications/phid/handle/data'); phutil_require_module('phabricator', 'infrastructure/env'); phutil_require_module('phabricator', 'view/layout/crumbs'); +phutil_require_module('phabricator', 'view/layout/panel'); phutil_require_module('phabricator', 'view/layout/sidenav'); phutil_require_module('phutil', 'markup'); diff --git a/src/applications/diffusion/controller/browse/DiffusionBrowseController.php b/src/applications/diffusion/controller/browse/DiffusionBrowseController.php index f67b9cfaf2..859f6f71b8 100644 --- a/src/applications/diffusion/controller/browse/DiffusionBrowseController.php +++ b/src/applications/diffusion/controller/browse/DiffusionBrowseController.php @@ -122,6 +122,8 @@ class DiffusionBrowseController extends DiffusionController { $content[] = $browse_panel; } + $content[] = $this->buildOpenRevisions(); + $nav = $this->buildSideNav('browse', false); $nav->appendChild($content); diff --git a/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php index 3dacdd7fce..a0ac7b1a1d 100644 --- a/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php +++ b/src/applications/diffusion/controller/file/DiffusionBrowseFileController.php @@ -117,10 +117,12 @@ class DiffusionBrowseFileController extends DiffusionController { )); $content[] = $view_select_panel; $content[] = $corpus; + $content[] = $this->buildOpenRevisions(); $nav = $this->buildSideNav('browse', true); $nav->appendChild($content); + $basename = basename($this->getDiffusionRequest()->getPath()); return $this->buildStandardPageResponse(