mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-24 22:40:55 +01:00
Stop computing ownership for changed paths for Very Large revisions
Summary: Depends on D19416. Ref T13110. Ref T13130. See PHI598. When rendering a "Very Large" revision (affecting more than 1,000 files) we currently compute the package/changeset ownership map normally. This is basically a big list of which packages own which of the files affected by the change. We use it to: # Show which packages own each file in the table of contents. # Show an "(Owns No Changed Paths)" hint in the reviewers list to help catch out-of-date packages that are no longer relevant. However, this is expensive to build. We don't render the table of contents at all, so (1) is pointless. The value of (2) is very small on these types of changes, and certainly not worth spending many many seconds computing ownership. Instead, just skip building out these relationships for very large changes. Test Plan: Viewed a very large change with package owners; verified it no longer built package map data and rendered the package owners with no "(Owns No Changed Paths)" hints. Reviewers: amckinley Reviewed By: amckinley Maniphest Tasks: T13130, T13110 Differential Revision: https://secure.phabricator.com/D19418
This commit is contained in:
parent
24305cadb9
commit
ee32c186dd
1 changed files with 47 additions and 20 deletions
|
@ -1,22 +1,43 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
final class DifferentialRevisionViewController extends DifferentialController {
|
final class DifferentialRevisionViewController
|
||||||
|
extends DifferentialController {
|
||||||
|
|
||||||
private $revisionID;
|
private $revisionID;
|
||||||
private $veryLargeDiff;
|
private $changesetCount;
|
||||||
|
|
||||||
public function shouldAllowPublic() {
|
public function shouldAllowPublic() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isLargeDiff() {
|
||||||
|
return ($this->getChangesetCount() > $this->getLargeDiffLimit());
|
||||||
|
}
|
||||||
|
|
||||||
public function isVeryLargeDiff() {
|
public function isVeryLargeDiff() {
|
||||||
return $this->veryLargeDiff;
|
return ($this->getChangesetCount() > $this->getVeryLargeDiffLimit());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLargeDiffLimit() {
|
||||||
|
return 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getVeryLargeDiffLimit() {
|
public function getVeryLargeDiffLimit() {
|
||||||
return 1000;
|
return 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getChangesetCount() {
|
||||||
|
if ($this->changesetCount === null) {
|
||||||
|
throw new PhutilInvalidStateException('setChangesetCount');
|
||||||
|
}
|
||||||
|
return $this->changesetCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setChangesetCount($count) {
|
||||||
|
$this->changesetCount = $count;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function handleRequest(AphrontRequest $request) {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$viewer = $this->getViewer();
|
$viewer = $this->getViewer();
|
||||||
$this->revisionID = $request->getURIData('id');
|
$this->revisionID = $request->getURIData('id');
|
||||||
|
@ -82,9 +103,7 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
idx($diffs, $diff_vs),
|
idx($diffs, $diff_vs),
|
||||||
$repository);
|
$repository);
|
||||||
|
|
||||||
if (count($rendering_references) > $this->getVeryLargeDiffLimit()) {
|
$this->setChangesetCount(count($rendering_references));
|
||||||
$this->veryLargeDiff = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->getExists('download')) {
|
if ($request->getExists('download')) {
|
||||||
return $this->buildRawDiffResponse(
|
return $this->buildRawDiffResponse(
|
||||||
|
@ -153,18 +172,16 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
|
|
||||||
$request_uri = $request->getRequestURI();
|
$request_uri = $request->getRequestURI();
|
||||||
|
|
||||||
// Revisions with more than 100 files are "large".
|
|
||||||
// Revisions with more than 1000 files are "very large".
|
|
||||||
$limit = 100;
|
|
||||||
$large = $request->getStr('large');
|
$large = $request->getStr('large');
|
||||||
|
|
||||||
$large_warning =
|
$large_warning =
|
||||||
|
($this->isLargeDiff()) &&
|
||||||
(!$this->isVeryLargeDiff()) &&
|
(!$this->isVeryLargeDiff()) &&
|
||||||
(count($changesets) > $limit) &&
|
|
||||||
(!$large);
|
(!$large);
|
||||||
|
|
||||||
if ($large_warning) {
|
if ($large_warning) {
|
||||||
$count = count($changesets);
|
$count = $this->getChangesetCount();
|
||||||
|
|
||||||
$warning = new PHUIInfoView();
|
$warning = new PHUIInfoView();
|
||||||
$warning->setTitle(pht('Large Diff'));
|
$warning->setTitle(pht('Large Diff'));
|
||||||
$warning->setSeverity(PHUIInfoView::SEVERITY_WARNING);
|
$warning->setSeverity(PHUIInfoView::SEVERITY_WARNING);
|
||||||
|
@ -365,23 +382,33 @@ final class DifferentialRevisionViewController extends DifferentialController {
|
||||||
$other_view = $this->renderOtherRevisions($other_revisions);
|
$other_view = $this->renderOtherRevisions($other_revisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->buildPackageMaps($changesets);
|
|
||||||
|
|
||||||
if ($this->isVeryLargeDiff()) {
|
if ($this->isVeryLargeDiff()) {
|
||||||
$toc_view = null;
|
$toc_view = null;
|
||||||
|
|
||||||
|
// When rendering a "very large" diff, we skip computation of owners
|
||||||
|
// that own no files because it is significantly expensive and not very
|
||||||
|
// valuable.
|
||||||
|
foreach ($revision->getReviewers() as $reviewer) {
|
||||||
|
// Give each reviewer a dummy nonempty value so the UI does not render
|
||||||
|
// the "(Owns No Changed Paths)" note. If that behavior becomes more
|
||||||
|
// sophisticated in the future, this behavior might also need to.
|
||||||
|
$reviewer->attachChangesets($changesets);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$this->buildPackageMaps($changesets);
|
||||||
|
|
||||||
$toc_view = $this->buildTableOfContents(
|
$toc_view = $this->buildTableOfContents(
|
||||||
$changesets,
|
$changesets,
|
||||||
$visible_changesets,
|
$visible_changesets,
|
||||||
$target->loadCoverageMap($viewer));
|
$target->loadCoverageMap($viewer));
|
||||||
}
|
|
||||||
|
|
||||||
// Attach changesets to each reviewer so we can show which Owners package
|
// Attach changesets to each reviewer so we can show which Owners package
|
||||||
// reviewers own no files.
|
// reviewers own no files.
|
||||||
foreach ($revision->getReviewers() as $reviewer) {
|
foreach ($revision->getReviewers() as $reviewer) {
|
||||||
$reviewer_phid = $reviewer->getReviewerPHID();
|
$reviewer_phid = $reviewer->getReviewerPHID();
|
||||||
$reviewer_changesets = $this->getPackageChangesets($reviewer_phid);
|
$reviewer_changesets = $this->getPackageChangesets($reviewer_phid);
|
||||||
$reviewer->attachChangesets($reviewer_changesets);
|
$reviewer->attachChangesets($reviewer_changesets);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$tab_group = id(new PHUITabGroupView());
|
$tab_group = id(new PHUITabGroupView());
|
||||||
|
|
Loading…
Reference in a new issue