Page MenuHomePhabricator

D19295.id46184.diff
No OneTemporary

D19295.id46184.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
@@ -389,6 +389,7 @@
'DifferentialChangesetDetailView' => 'applications/differential/view/DifferentialChangesetDetailView.php',
'DifferentialChangesetFileTreeSideNavBuilder' => 'applications/differential/view/DifferentialChangesetFileTreeSideNavBuilder.php',
'DifferentialChangesetHTMLRenderer' => 'applications/differential/render/DifferentialChangesetHTMLRenderer.php',
+ 'DifferentialChangesetListController' => 'applications/differential/controller/DifferentialChangesetListController.php',
'DifferentialChangesetListView' => 'applications/differential/view/DifferentialChangesetListView.php',
'DifferentialChangesetOneUpMailRenderer' => 'applications/differential/render/DifferentialChangesetOneUpMailRenderer.php',
'DifferentialChangesetOneUpRenderer' => 'applications/differential/render/DifferentialChangesetOneUpRenderer.php',
@@ -397,6 +398,7 @@
'DifferentialChangesetParserTestCase' => 'applications/differential/parser/__tests__/DifferentialChangesetParserTestCase.php',
'DifferentialChangesetQuery' => 'applications/differential/query/DifferentialChangesetQuery.php',
'DifferentialChangesetRenderer' => 'applications/differential/render/DifferentialChangesetRenderer.php',
+ 'DifferentialChangesetSearchEngine' => 'applications/differential/query/DifferentialChangesetSearchEngine.php',
'DifferentialChangesetTestRenderer' => 'applications/differential/render/DifferentialChangesetTestRenderer.php',
'DifferentialChangesetTwoUpRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpRenderer.php',
'DifferentialChangesetTwoUpTestRenderer' => 'applications/differential/render/DifferentialChangesetTwoUpTestRenderer.php',
@@ -5605,6 +5607,7 @@
'DifferentialChangesetDetailView' => 'AphrontView',
'DifferentialChangesetFileTreeSideNavBuilder' => 'Phobject',
'DifferentialChangesetHTMLRenderer' => 'DifferentialChangesetRenderer',
+ 'DifferentialChangesetListController' => 'DifferentialController',
'DifferentialChangesetListView' => 'AphrontView',
'DifferentialChangesetOneUpMailRenderer' => 'DifferentialChangesetRenderer',
'DifferentialChangesetOneUpRenderer' => 'DifferentialChangesetHTMLRenderer',
@@ -5613,6 +5616,7 @@
'DifferentialChangesetParserTestCase' => 'PhabricatorTestCase',
'DifferentialChangesetQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'DifferentialChangesetRenderer' => 'Phobject',
+ 'DifferentialChangesetSearchEngine' => 'PhabricatorApplicationSearchEngine',
'DifferentialChangesetTestRenderer' => 'DifferentialChangesetRenderer',
'DifferentialChangesetTwoUpRenderer' => 'DifferentialChangesetHTMLRenderer',
'DifferentialChangesetTwoUpTestRenderer' => 'DifferentialChangesetTestRenderer',
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
@@ -52,7 +52,13 @@
'(?:query/(?P<queryKey>[^/]+)/)?'
=> 'DifferentialRevisionListController',
'diff/' => array(
- '(?P<id>[1-9]\d*)/' => 'DifferentialDiffViewController',
+ '(?P<id>[1-9]\d*)/' => array(
+ '' => 'DifferentialDiffViewController',
+ 'changesets/' => array(
+ $this->getQueryRoutePattern()
+ => 'DifferentialChangesetListController',
+ ),
+ ),
'create/' => 'DifferentialDiffCreateController',
),
'changeset/' => 'DifferentialChangesetViewController',
diff --git a/src/applications/differential/controller/DifferentialChangesetListController.php b/src/applications/differential/controller/DifferentialChangesetListController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/controller/DifferentialChangesetListController.php
@@ -0,0 +1,51 @@
+<?php
+
+final class DifferentialChangesetListController
+ extends DifferentialController {
+
+ private $diff;
+
+ public function shouldAllowPublic() {
+ return true;
+ }
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $this->getViewer();
+
+ $diff = id(new DifferentialDiffQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($request->getURIData('id')))
+ ->executeOne();
+ if (!$diff) {
+ return new Aphront404Response();
+ }
+ $this->diff = $diff;
+
+ return id(new DifferentialChangesetSearchEngine())
+ ->setController($this)
+ ->setDiff($diff)
+ ->buildResponse();
+ }
+
+ protected function buildApplicationCrumbs() {
+ $crumbs = parent::buildApplicationCrumbs();
+
+ $diff = $this->diff;
+ if ($diff) {
+ $revision = $diff->getRevision();
+ if ($revision) {
+ $crumbs->addTextCrumb(
+ $revision->getMonogram(),
+ $revision->getURI());
+ }
+
+ $crumbs->addTextCrumb(
+ pht('Diff %d', $diff->getID()),
+ $diff->getURI());
+ }
+
+ return $crumbs;
+ }
+
+
+}
diff --git a/src/applications/differential/controller/DifferentialRevisionViewController.php b/src/applications/differential/controller/DifferentialRevisionViewController.php
--- a/src/applications/differential/controller/DifferentialRevisionViewController.php
+++ b/src/applications/differential/controller/DifferentialRevisionViewController.php
@@ -399,8 +399,18 @@
->appendChild($other_view));
}
+ $view_button = id(new PHUIButtonView())
+ ->setTag('a')
+ ->setText(pht('Changeset List'))
+ ->setHref('/differential/diff/'.$target->getID().'/changesets/')
+ ->setIcon('fa-align-left');
+
+ $tab_header = id(new PHUIHeaderView())
+ ->setHeader(pht('Revision Contents'))
+ ->addActionLink($view_button);
+
$tab_view = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Revision Contents'))
+ ->setHeader($tab_header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->addTabGroup($tab_group);
diff --git a/src/applications/differential/query/DifferentialChangesetQuery.php b/src/applications/differential/query/DifferentialChangesetQuery.php
--- a/src/applications/differential/query/DifferentialChangesetQuery.php
+++ b/src/applications/differential/query/DifferentialChangesetQuery.php
@@ -41,19 +41,12 @@
}
}
+ public function newResultObject() {
+ return new DifferentialChangeset();
+ }
+
protected function loadPage() {
- $table = new DifferentialChangeset();
- $conn_r = $table->establishConnection('r');
-
- $data = queryfx_all(
- $conn_r,
- 'SELECT * FROM %T %Q %Q %Q',
- $table->getTableName(),
- $this->buildWhereClause($conn_r),
- $this->buildOrderClause($conn_r),
- $this->buildLimitClause($conn_r));
-
- return $table->loadAllFromArray($data);
+ return $this->loadStandardPage($this->newResultObject());
}
protected function willFilterPage(array $changesets) {
@@ -124,26 +117,24 @@
return $changesets;
}
- protected function buildWhereClause(AphrontDatabaseConnection $conn_r) {
- $where = array();
+ protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
+ $where = parent::buildWhereClauseParts($conn);
if ($this->diffs !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'diffID IN (%Ld)',
mpull($this->diffs, 'getID'));
}
if ($this->ids !== null) {
$where[] = qsprintf(
- $conn_r,
+ $conn,
'id IN (%Ld)',
$this->ids);
}
- $where[] = $this->buildPagingClause($conn_r);
-
- return $this->formatWhereClause($where);
+ return $where;
}
public function getQueryApplicationClass() {
diff --git a/src/applications/differential/query/DifferentialChangesetSearchEngine.php b/src/applications/differential/query/DifferentialChangesetSearchEngine.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/query/DifferentialChangesetSearchEngine.php
@@ -0,0 +1,133 @@
+<?php
+
+final class DifferentialChangesetSearchEngine
+ extends PhabricatorApplicationSearchEngine {
+
+ private $diff;
+
+ public function setDiff(DifferentialDiff $diff) {
+ $this->diff = $diff;
+ return $this;
+ }
+
+ public function getDiff() {
+ return $this->diff;
+ }
+
+ public function getResultTypeDescription() {
+ return pht('Differential Changesets');
+ }
+
+ public function getApplicationClassName() {
+ return 'PhabricatorDifferentialApplication';
+ }
+
+ public function newQuery() {
+ $query = id(new DifferentialChangesetQuery());
+
+ if ($this->diff) {
+ $query->withDiffs(array($this->diff));
+ }
+
+ return $query;
+ }
+
+ protected function buildQueryFromParameters(array $map) {
+ $query = $this->newQuery();
+ return $query;
+ }
+
+ protected function buildCustomSearchFields() {
+ return array();
+ }
+
+ protected function getURI($path) {
+ $diff = $this->getDiff();
+ if ($diff) {
+ return '/differential/diff/'.$diff->getID().'/changesets/'.$path;
+ }
+
+ throw new PhutilMethodNotImplementedException();
+ }
+
+ protected function getBuiltinQueryNames() {
+ $names = array();
+ $names['all'] = pht('All Changesets');
+ return $names;
+ }
+
+ public function buildSavedQueryFromBuiltin($query_key) {
+ $query = $this->newSavedQuery();
+ $query->setQueryKey($query_key);
+
+ $viewer = $this->requireViewer();
+
+ switch ($query_key) {
+ case 'all':
+ return $query->setParameter('order', 'oldest');
+ }
+
+ return parent::buildSavedQueryFromBuiltin($query_key);
+ }
+
+ protected function renderResultList(
+ array $changesets,
+ PhabricatorSavedQuery $query,
+ array $handles) {
+
+ assert_instances_of($changesets, 'DifferentialChangeset');
+ $viewer = $this->requireViewer();
+
+ $rows = array();
+ foreach ($changesets as $changeset) {
+ $link = phutil_tag(
+ 'a',
+ array(
+ 'href' => '/differential/changeset/?ref='.$changeset->getID(),
+ ),
+ $changeset->getDisplayFilename());
+
+ $type = $changeset->getChangeType();
+
+ $title = DifferentialChangeType::getFullNameForChangeType($type);
+
+ $add_lines = $changeset->getAddLines();
+ if (!$add_lines) {
+ $add_lines = null;
+ } else {
+ $add_lines = '+'.$add_lines;
+ }
+
+ $rem_lines = $changeset->getDelLines();
+ if (!$rem_lines) {
+ $rem_lines = null;
+ } else {
+ $rem_lines = '-'.$rem_lines;
+ }
+
+ $rows[] = array(
+ $changeset->newFileTreeIcon(),
+ $title,
+ $link,
+ );
+ }
+
+ $table = id(new AphrontTableView($rows))
+ ->setHeaders(
+ array(
+ null,
+ pht('Change'),
+ pht('Path'),
+ ))
+ ->setColumnClasses(
+ array(
+ null,
+ null,
+ 'pri wide',
+ ));
+
+ return id(new PhabricatorApplicationSearchResultView())
+ ->setTable($table);
+ }
+
+}

File Metadata

Mime Type
text/plain
Expires
Wed, Apr 23, 2:39 AM (3 d, 9 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7639627
Default Alt Text
D19295.id46184.diff (11 KB)

Event Timeline