Page MenuHomePhabricator

D21615.id51451.diff
No OneTemporary

D21615.id51451.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -613,6 +613,7 @@
'DifferentialRevisionAcceptTransaction' => 'applications/differential/xaction/DifferentialRevisionAcceptTransaction.php',
'DifferentialRevisionActionTransaction' => 'applications/differential/xaction/DifferentialRevisionActionTransaction.php',
'DifferentialRevisionAffectedFilesHeraldField' => 'applications/differential/herald/DifferentialRevisionAffectedFilesHeraldField.php',
+ 'DifferentialRevisionAffectedPathsController' => 'applications/differential/controller/DifferentialRevisionAffectedPathsController.php',
'DifferentialRevisionAuthorHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorHeraldField.php',
'DifferentialRevisionAuthorPackagesHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorPackagesHeraldField.php',
'DifferentialRevisionAuthorProjectsHeraldField' => 'applications/differential/herald/DifferentialRevisionAuthorProjectsHeraldField.php',
@@ -6733,6 +6734,7 @@
'DifferentialRevisionAcceptTransaction' => 'DifferentialRevisionReviewTransaction',
'DifferentialRevisionActionTransaction' => 'DifferentialRevisionTransactionType',
'DifferentialRevisionAffectedFilesHeraldField' => 'DifferentialRevisionHeraldField',
+ 'DifferentialRevisionAffectedPathsController' => 'DifferentialController',
'DifferentialRevisionAuthorHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionAuthorPackagesHeraldField' => 'DifferentialRevisionHeraldField',
'DifferentialRevisionAuthorProjectsHeraldField' => 'DifferentialRevisionHeraldField',
diff --git a/src/applications/differential/application/PhabricatorDifferentialApplication.php b/src/applications/differential/application/PhabricatorDifferentialApplication.php
--- a/src/applications/differential/application/PhabricatorDifferentialApplication.php
+++ b/src/applications/differential/application/PhabricatorDifferentialApplication.php
@@ -74,6 +74,8 @@
=> 'DifferentialRevisionOperationController',
'inlines/(?P<id>[1-9]\d*)/'
=> 'DifferentialRevisionInlinesController',
+ 'paths/(?P<id>[1-9]\d*)/'
+ => 'DifferentialRevisionAffectedPathsController',
),
'comment/' => array(
'inline/' => array(
diff --git a/src/applications/differential/controller/DifferentialRevisionAffectedPathsController.php b/src/applications/differential/controller/DifferentialRevisionAffectedPathsController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/controller/DifferentialRevisionAffectedPathsController.php
@@ -0,0 +1,127 @@
+<?php
+
+final class DifferentialRevisionAffectedPathsController
+ extends DifferentialController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+ $id = $request->getURIData('id');
+
+ $revision = id(new DifferentialRevisionQuery())
+ ->withIDs(array($id))
+ ->setViewer($viewer)
+ ->executeOne();
+ if (!$revision) {
+ return new Aphront404Response();
+ }
+
+ $table = new DifferentialAffectedPath();
+ $conn = $table->establishConnection('r');
+
+ $paths = queryfx_all(
+ $conn,
+ 'SELECT * FROM %R WHERE revisionID = %d',
+ $table,
+ $revision->getID());
+
+ $repository_ids = array();
+ $path_ids = array();
+
+ foreach ($paths as $path) {
+ $repository_id = $path['repositoryID'];
+ $path_id = $path['pathID'];
+
+ $repository_ids[] = $repository_id;
+ $path_ids[] = $path_id;
+ }
+
+ $repository_ids = array_fuse($repository_ids);
+
+ if ($repository_ids) {
+ $repositories = id(new PhabricatorRepositoryQuery())
+ ->setViewer($viewer)
+ ->withIDs($repository_ids)
+ ->execute();
+ $repositories = mpull($repositories, null, 'getID');
+ } else {
+ $repositories = array();
+ }
+
+ $handles = $viewer->loadHandles(mpull($repositories, 'getPHID'));
+
+ $path_ids = array_fuse($path_ids);
+ if ($path_ids) {
+ $path_names = id(new DiffusionPathQuery())
+ ->withPathIDs($path_ids)
+ ->execute();
+ } else {
+ $path_names = array();
+ }
+
+ $rows = array();
+ foreach ($paths as $path) {
+ $repository_id = $path['repositoryID'];
+ $path_id = $path['pathID'];
+
+ $repository = idx($repositories, $repository_id);
+ if ($repository) {
+ $repository_phid = $repository->getPHID();
+ $repository_link = $handles[$repository_phid]->renderLink();
+ } else {
+ $repository_link = null;
+ }
+
+ $path_name = idx($path_names, $path_id);
+ if ($path_name !== null) {
+ $path_view = $path_name['path'];
+ } else {
+ $path_view = null;
+ }
+
+ $rows[] = array(
+ $repository_id,
+ $repository_link,
+ $path_id,
+ $path_view,
+ );
+ }
+
+ // Sort rows by path name.
+ $rows = isort($rows, 3);
+
+ $table_view = id(new AphrontTableView($rows))
+ ->setNoDataString(pht('This revision has no indexed affected paths.'))
+ ->setHeaders(
+ array(
+ pht('Repository ID'),
+ pht('Repository'),
+ pht('Path ID'),
+ pht('Path'),
+ ))
+ ->setColumnClasses(
+ array(
+ null,
+ null,
+ null,
+ 'wide',
+ ));
+
+ $box_view = id(new PHUIObjectBoxView())
+ ->setHeaderText(pht('Affected Path Index'))
+ ->setTable($table_view);
+
+ $crumbs = $this->buildApplicationCrumbs()
+ ->addTextCrumb($revision->getMonogram(), $revision->getURI())
+ ->addTextCrumb(pht('Affected Path Index'));
+
+ return $this->newPage()
+ ->setCrumbs($crumbs)
+ ->setTitle(
+ array(
+ $revision->getMonogram(),
+ pht('Affected Path Index'),
+ ))
+ ->appendChild($box_view);
+ }
+
+}
diff --git a/src/applications/system/events/PhabricatorSystemDebugUIEventListener.php b/src/applications/system/events/PhabricatorSystemDebugUIEventListener.php
--- a/src/applications/system/events/PhabricatorSystemDebugUIEventListener.php
+++ b/src/applications/system/events/PhabricatorSystemDebugUIEventListener.php
@@ -44,6 +44,16 @@
->setName(pht('View Hovercard'))
->setHref(urisprintf('/search/hovercard/?names=%s', $phid));
+ if ($object instanceof DifferentialRevision) {
+ $submenu[] = id(new PhabricatorActionView())
+ ->setIcon('fa-database')
+ ->setName(pht('View Affected Path Index'))
+ ->setHref(
+ urisprintf(
+ '/differential/revision/paths/%s/',
+ $object->getID()));
+ }
+
$developer_action = id(new PhabricatorActionView())
->setName(pht('Advanced/Developer...'))
->setIcon('fa-magic')

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 6, 1:25 AM (3 w, 6 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7228113
Default Alt Text
D21615.id51451.diff (6 KB)

Event Timeline