1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-18 19:40:55 +01:00

Make Differential load lint/unit data from Harbormaster

Summary: Fixes T8095. Still needs UI/UX work (see T8096) but this has all the core features now.

Test Plan: Saw Harbormaster lint/unit data as though it was Differential lint-unit data.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8095

Differential Revision: https://secure.phabricator.com/D13401
This commit is contained in:
epriestley 2015-06-23 07:09:23 -07:00
parent c4eef3dfcb
commit de30e15b7e
6 changed files with 76 additions and 37 deletions

View file

@ -10,7 +10,7 @@ return array(
'core.pkg.css' => 'eb51e6dc', 'core.pkg.css' => 'eb51e6dc',
'core.pkg.js' => '711e63c0', 'core.pkg.js' => '711e63c0',
'darkconsole.pkg.js' => 'e7393ebb', 'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '02273347', 'differential.pkg.css' => '1ca3c116',
'differential.pkg.js' => 'ebef29b1', 'differential.pkg.js' => 'ebef29b1',
'diffusion.pkg.css' => '591664fa', 'diffusion.pkg.css' => '591664fa',
'diffusion.pkg.js' => '0115b37c', 'diffusion.pkg.js' => '0115b37c',
@ -61,7 +61,6 @@ return array(
'rsrc/css/application/differential/changeset-view.css' => 'e19cfd6e', 'rsrc/css/application/differential/changeset-view.css' => 'e19cfd6e',
'rsrc/css/application/differential/core.css' => '7ac3cabc', 'rsrc/css/application/differential/core.css' => '7ac3cabc',
'rsrc/css/application/differential/phui-inline-comment.css' => 'aa16f165', 'rsrc/css/application/differential/phui-inline-comment.css' => 'aa16f165',
'rsrc/css/application/differential/results-table.css' => '181aa9d9',
'rsrc/css/application/differential/revision-comment.css' => '14b8565a', 'rsrc/css/application/differential/revision-comment.css' => '14b8565a',
'rsrc/css/application/differential/revision-history.css' => '0e8eb855', 'rsrc/css/application/differential/revision-history.css' => '0e8eb855',
'rsrc/css/application/differential/revision-list.css' => 'f3c47d33', 'rsrc/css/application/differential/revision-list.css' => 'f3c47d33',
@ -358,7 +357,6 @@ return array(
'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '037b59eb', 'rsrc/js/application/differential/behavior-edit-inline-comments.js' => '037b59eb',
'rsrc/js/application/differential/behavior-keyboard-nav.js' => '2c426492', 'rsrc/js/application/differential/behavior-keyboard-nav.js' => '2c426492',
'rsrc/js/application/differential/behavior-populate.js' => '8694b1df', 'rsrc/js/application/differential/behavior-populate.js' => '8694b1df',
'rsrc/js/application/differential/behavior-show-field-details.js' => 'bba9eedf',
'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb', 'rsrc/js/application/differential/behavior-toggle-files.js' => 'ca3f91eb',
'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d', 'rsrc/js/application/differential/behavior-user-select.js' => 'a8d8459d',
'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => 'b42eddc7', 'rsrc/js/application/diffusion/DiffusionLocateFileSource.js' => 'b42eddc7',
@ -513,7 +511,6 @@ return array(
'differential-changeset-view-css' => 'e19cfd6e', 'differential-changeset-view-css' => 'e19cfd6e',
'differential-core-view-css' => '7ac3cabc', 'differential-core-view-css' => '7ac3cabc',
'differential-inline-comment-editor' => 'd4c87bf4', 'differential-inline-comment-editor' => 'd4c87bf4',
'differential-results-table-css' => '181aa9d9',
'differential-revision-add-comment-css' => 'c47f8c40', 'differential-revision-add-comment-css' => 'c47f8c40',
'differential-revision-comment-css' => '14b8565a', 'differential-revision-comment-css' => '14b8565a',
'differential-revision-history-css' => '0e8eb855', 'differential-revision-history-css' => '0e8eb855',
@ -567,7 +564,6 @@ return array(
'javelin-behavior-differential-feedback-preview' => 'b064af76', 'javelin-behavior-differential-feedback-preview' => 'b064af76',
'javelin-behavior-differential-keyboard-navigation' => '2c426492', 'javelin-behavior-differential-keyboard-navigation' => '2c426492',
'javelin-behavior-differential-populate' => '8694b1df', 'javelin-behavior-differential-populate' => '8694b1df',
'javelin-behavior-differential-show-field-details' => 'bba9eedf',
'javelin-behavior-differential-toggle-files' => 'ca3f91eb', 'javelin-behavior-differential-toggle-files' => 'ca3f91eb',
'javelin-behavior-differential-user-select' => 'a8d8459d', 'javelin-behavior-differential-user-select' => 'a8d8459d',
'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04', 'javelin-behavior-diffusion-commit-branches' => 'bdaf4d04',
@ -1705,11 +1701,6 @@ return array(
'javelin-workflow', 'javelin-workflow',
'phabricator-draggable-list', 'phabricator-draggable-list',
), ),
'bba9eedf' => array(
'javelin-behavior',
'javelin-stratcom',
'javelin-dom',
),
'bd4c8dca' => array( 'bd4c8dca' => array(
'javelin-install', 'javelin-install',
'javelin-util', 'javelin-util',
@ -2192,7 +2183,6 @@ return array(
'differential.pkg.css' => array( 'differential.pkg.css' => array(
'differential-core-view-css', 'differential-core-view-css',
'differential-changeset-view-css', 'differential-changeset-view-css',
'differential-results-table-css',
'differential-revision-history-css', 'differential-revision-history-css',
'differential-revision-list-css', 'differential-revision-list-css',
'differential-table-of-contents-css', 'differential-table-of-contents-css',

View file

@ -265,8 +265,25 @@ final class DifferentialRevisionViewController extends DifferentialController {
$revision_detail_box->setInfoView($revision_warnings); $revision_detail_box->setInfoView($revision_warnings);
} }
$detail_diffs = array_select_keys(
$diffs,
array($diff_vs, $target->getID()));
$detail_diffs = mpull($detail_diffs, null, 'getPHID');
$buildables = id(new HarbormasterBuildableQuery())
->setViewer($user)
->withBuildablePHIDs(array_keys($detail_diffs))
->withManualBuildables(false)
->needBuilds(true)
->needTargets(true)
->execute();
$buildables = mpull($buildables, null, 'getBuildablePHID');
foreach ($detail_diffs as $diff_phid => $detail_diff) {
$detail_diff->attachBuildable(idx($buildables, $diff_phid));
}
$diff_detail_box = $this->buildDiffDetailView( $diff_detail_box = $this->buildDiffDetailView(
array_select_keys($diffs, array($diff_vs, $target->getID())), $detail_diffs,
$revision, $revision,
$field_list); $field_list);

View file

@ -54,7 +54,19 @@ final class DifferentialLintField
$lint = array(); $lint = array();
// TODO: Look for Harbormaster messages here. $buildable = $diff->getBuildable();
if ($buildable) {
$target_phids = array();
foreach ($buildable->getBuilds() as $build) {
foreach ($build->getBuildTargets() as $target) {
$target_phids[] = $target->getPHID();
}
}
$lint = id(new HarbormasterBuildLintMessage())->loadAllWhere(
'buildTargetPHID IN (%Ls) LIMIT 25',
$target_phids);
}
if (!$lint) { if (!$lint) {
// No Harbormaster messages, so look for legacy messages and make them // No Harbormaster messages, so look for legacy messages and make them

View file

@ -52,7 +52,19 @@ final class DifferentialUnitField
$unit = array(); $unit = array();
// TODO: Look for Harbormaster results here. $buildable = $diff->getBuildable();
if ($buildable) {
$target_phids = array();
foreach ($buildable->getBuilds() as $build) {
foreach ($build->getBuildTargets() as $target) {
$target_phids[] = $target->getPHID();
}
}
$unit = id(new HarbormasterBuildUnitMessage())->loadAllWhere(
'buildTargetPHID IN (%Ls) LIMIT 25',
$target_phids);
}
if (!$unit) { if (!$unit) {
$legacy_unit = $diff->getProperty('arc:unit'); $legacy_unit = $diff->getProperty('arc:unit');

View file

@ -39,6 +39,7 @@ final class DifferentialDiff
private $changesets = self::ATTACHABLE; private $changesets = self::ATTACHABLE;
private $revision = self::ATTACHABLE; private $revision = self::ATTACHABLE;
private $properties = array(); private $properties = array();
private $buildable = self::ATTACHABLE;
protected function getConfiguration() { protected function getConfiguration() {
return array( return array(
@ -323,6 +324,15 @@ final class DifferentialDiff
return $this->assertAttachedKey($this->properties, $key); return $this->assertAttachedKey($this->properties, $key);
} }
public function attachBuildable(HarbormasterBuildable $buildable = null) {
$this->buildable = $buildable;
return $this;
}
public function getBuildable() {
return $this->assertAttached($this->buildable);
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */ /* -( PhabricatorPolicyInterface )----------------------------------------- */

View file

@ -13,6 +13,7 @@ final class HarbormasterBuildableQuery
private $needContainerHandles; private $needContainerHandles;
private $needBuildableHandles; private $needBuildableHandles;
private $needBuilds; private $needBuilds;
private $needTargets;
public function withIDs(array $ids) { public function withIDs(array $ids) {
$this->ids = $ids; $this->ids = $ids;
@ -59,19 +60,17 @@ final class HarbormasterBuildableQuery
return $this; return $this;
} }
public function needTargets($need) {
$this->needTargets = $need;
return $this;
}
public function newResultObject() {
return new HarbormasterBuildable();
}
protected function loadPage() { protected function loadPage() {
$table = new HarbormasterBuildable(); return $this->loadStandardPage($this->newResultObject());
$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);
} }
protected function willFilterPage(array $page) { protected function willFilterPage(array $page) {
@ -157,11 +156,12 @@ final class HarbormasterBuildableQuery
} }
} }
if ($this->needBuilds) { if ($this->needBuilds || $this->needTargets) {
$builds = id(new HarbormasterBuildQuery()) $builds = id(new HarbormasterBuildQuery())
->setViewer($this->getViewer()) ->setViewer($this->getViewer())
->setParentQuery($this) ->setParentQuery($this)
->withBuildablePHIDs(mpull($page, 'getPHID')) ->withBuildablePHIDs(mpull($page, 'getPHID'))
->needBuildTargets($this->needTargets)
->execute(); ->execute();
$builds = mgroup($builds, 'getBuildablePHID'); $builds = mgroup($builds, 'getBuildablePHID');
foreach ($page as $key => $buildable) { foreach ($page as $key => $buildable) {
@ -172,47 +172,45 @@ final class HarbormasterBuildableQuery
return $page; return $page;
} }
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) {
$where = array(); $where = parent::buildWhereClauseParts($conn);
if ($this->ids !== null) { if ($this->ids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'id IN (%Ld)', 'id IN (%Ld)',
$this->ids); $this->ids);
} }
if ($this->phids !== null) { if ($this->phids !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'phid IN (%Ls)', 'phid IN (%Ls)',
$this->phids); $this->phids);
} }
if ($this->buildablePHIDs !== null) { if ($this->buildablePHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'buildablePHID IN (%Ls)', 'buildablePHID IN (%Ls)',
$this->buildablePHIDs); $this->buildablePHIDs);
} }
if ($this->containerPHIDs !== null) { if ($this->containerPHIDs !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'containerPHID in (%Ls)', 'containerPHID in (%Ls)',
$this->containerPHIDs); $this->containerPHIDs);
} }
if ($this->manualBuildables !== null) { if ($this->manualBuildables !== null) {
$where[] = qsprintf( $where[] = qsprintf(
$conn_r, $conn,
'isManualBuildable = %d', 'isManualBuildable = %d',
(int)$this->manualBuildables); (int)$this->manualBuildables);
} }
$where[] = $this->buildPagingClause($conn_r); return $where;
return $this->formatWhereClause($where);
} }
public function getQueryApplicationClass() { public function getQueryApplicationClass() {