Don't show changes for commits which affect more than 1,000 files

Summary: @nh, does this do something reasonable on merges? We can refine the behavior ('click to show all 92 million files'), but I want to make sure it's at least feasible before we pursue it.

Test Plan: Set 1000 to "3" and looked at a change which touched 6 files.

Reviewers: nh, vrana, zjwsoft

Reviewed By: nh

CC: aran

Differential Revision: https://secure.phabricator.com/D4730
This commit is contained in:
epriestley
2013-01-30 12:01:49 -08:00
parent c1bcccb227
commit 5256731262
2 changed files with 60 additions and 16 deletions

View File

@@ -3,6 +3,16 @@
final class DiffusionPathChangeQuery {
private $request;
private $limit;
public function setLimit($limit) {
$this->limit = $limit;
return $this;
}
public function getLimit() {
return $this->limit;
}
final private function __construct() {
// <private>
@@ -31,20 +41,36 @@ final class DiffusionPathChangeQuery {
$commit = $drequest->loadCommit();
$conn_r = $repository->establishConnection('r');
$limit = '';
if ($this->limit) {
$limit = qsprintf(
$conn_r,
'LIMIT %d',
$this->limit + 1);
}
$raw_changes = queryfx_all(
$repository->establishConnection('r'),
$conn_r,
'SELECT c.*, p.path pathName, t.path targetPathName,
i.commitIdentifier targetCommitIdentifier
FROM %T c
LEFT JOIN %T p ON c.pathID = p.id
LEFT JOIN %T t ON c.targetPathID = t.id
LEFT JOIN %T i ON c.targetCommitID = i.id
WHERE c.commitID = %d AND isDirect = 1',
WHERE c.commitID = %d AND isDirect = 1 %Q',
PhabricatorRepository::TABLE_PATHCHANGE,
PhabricatorRepository::TABLE_PATH,
PhabricatorRepository::TABLE_PATH,
$commit->getTableName(),
$commit->getID());
$commit->getID(),
$limit);
$limited = $this->limit && (count($raw_changes) > $this->limit);
if ($limited) {
$raw_changes = array_slice($raw_changes, 0, $this->limit);
}
$changes = array();
@@ -68,20 +94,22 @@ final class DiffusionPathChangeQuery {
$changes[$id] = $change;
}
// Deduce the away paths by examining all the changes.
// Deduce the away paths by examining all the changes, if we loaded them
// all.
$away = array();
foreach ($changes as $change) {
if ($change->getTargetPath()) {
$away[$change->getTargetPath()][] = $change->getPath();
if (!$limited) {
$away = array();
foreach ($changes as $change) {
if ($change->getTargetPath()) {
$away[$change->getTargetPath()][] = $change->getPath();
}
}
foreach ($changes as $change) {
if (isset($away[$change->getPath()])) {
$change->setAwayPaths($away[$change->getPath()]);
}
}
}
foreach ($changes as $change) {
if (isset($away[$change->getPath()])) {
$change->setAwayPaths($away[$change->getPath()]);
}
}
return $changes;
}