Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15592081
D9128.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
15 KB
Referenced Files
None
Subscribers
None
D9128.diff
View Options
diff --git a/resources/sql/autopatches/20140515.history.1.sql b/resources/sql/autopatches/20140515.history.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140515.history.1.sql
@@ -0,0 +1,6 @@
+CREATE TABLE {$NAMESPACE}_repository.repository_history (
+ id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
+ repositoryID INT UNSIGNED NOT NULL,
+ commitIdentifier VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
+ historyType INT UNSIGNED NOT NULL
+) ENGINE=InnoDB, COLLATE utf8_general_ci;
diff --git a/resources/sql/autopatches/20140515.history.2.sql b/resources/sql/autopatches/20140515.history.2.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140515.history.2.sql
@@ -0,0 +1,7 @@
+ALTER TABLE {$NAMESPACE}_repository.repository_lintmessage CHANGE branchID historyID INT NOT NULL;
+
+ALTER TABLE {$NAMESPACE}_repository.repository_coverage CHANGE branchID historyID INT NOT NULL;
+
+DELETE FROM {$NAMESPACE}_repository.repository_lintmessage;
+
+DELETE FROM {$NAMESPACE}_repository.repository_coverage;
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
@@ -1995,6 +1995,7 @@
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryGitCommitMessageParserWorker.php',
'PhabricatorRepositoryGraphCache' => 'applications/repository/graphcache/PhabricatorRepositoryGraphCache.php',
'PhabricatorRepositoryGraphStream' => 'applications/repository/daemon/PhabricatorRepositoryGraphStream.php',
+ 'PhabricatorRepositoryHistory' => 'applications/repository/storage/PhabricatorRepositoryHistory.php',
'PhabricatorRepositoryListController' => 'applications/repository/controller/PhabricatorRepositoryListController.php',
'PhabricatorRepositoryManagementCacheWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementCacheWorkflow.php',
'PhabricatorRepositoryManagementDeleteWorkflow' => 'applications/repository/management/PhabricatorRepositoryManagementDeleteWorkflow.php',
@@ -4833,6 +4834,7 @@
'PhabricatorRepositoryGitCommitChangeParserWorker' => 'PhabricatorRepositoryCommitChangeParserWorker',
'PhabricatorRepositoryGitCommitMessageParserWorker' => 'PhabricatorRepositoryCommitMessageParserWorker',
'PhabricatorRepositoryGraphStream' => 'Phobject',
+ 'PhabricatorRepositoryHistory' => 'PhabricatorRepositoryDAO',
'PhabricatorRepositoryListController' => 'PhabricatorRepositoryController',
'PhabricatorRepositoryManagementCacheWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
'PhabricatorRepositoryManagementDeleteWorkflow' => 'PhabricatorRepositoryManagementWorkflow',
diff --git a/src/applications/diffusion/DiffusionLintSaveRunner.php b/src/applications/diffusion/DiffusionLintSaveRunner.php
--- a/src/applications/diffusion/DiffusionLintSaveRunner.php
+++ b/src/applications/diffusion/DiffusionLintSaveRunner.php
@@ -127,10 +127,24 @@
$this->runArcLint($files);
$this->saveLintMessages();
+ // TODO: This will disappear when DiffusionLintSaveRunner is replaced
+ // with Harbormaster (which I think should happen relatively soon).
+ $existing_history = id(new PhabricatorRepositoryHistory())->loadOneWhere(
+ 'repositoryID = %d AND commitIdentifier = %s',
+ $this->branch->getRepositoryID(),
+ $this->branch->getLintCommit());
+ $existing_history->delete();
+
$this->lintCommit = $api->getUnderlyingWorkingCopyRevision();
$this->branch->setLintCommit($this->lintCommit);
$this->branch->save();
+ id(new PhabricatorRepositoryHistory())
+ ->setRepositoryID($this->branch->getRepositoryID())
+ ->setCommitIdentifier($this->branch->getLintCommit())
+ ->setHistoryType(PhabricatorRepositoryHistory::HISTORY_BASE)
+ ->save();
+
if ($this->blame) {
$this->blameAuthors();
$this->blame = array();
diff --git a/src/applications/diffusion/controller/DiffusionBrowseFileController.php b/src/applications/diffusion/controller/DiffusionBrowseFileController.php
--- a/src/applications/diffusion/controller/DiffusionBrowseFileController.php
+++ b/src/applications/diffusion/controller/DiffusionBrowseFileController.php
@@ -171,13 +171,13 @@
private function loadLintMessages() {
$drequest = $this->getDiffusionRequest();
- $branch = $drequest->loadBranch();
+ $history = $drequest->loadHistory();
- if (!$branch || !$branch->getLintCommit()) {
+ if (!$history) {
return;
}
- $this->lintCommit = $branch->getLintCommit();
+ $this->lintCommit = $history->getCommitIdentifier();
$conn = id(new PhabricatorRepository())->establishConnection('r');
@@ -191,9 +191,9 @@
$this->lintMessages = queryfx_all(
$conn,
- 'SELECT * FROM %T WHERE branchID = %d %Q AND path = %s',
+ 'SELECT * FROM %T WHERE historyID = %d %Q AND path = %s',
PhabricatorRepository::TABLE_LINTMESSAGE,
- $branch->getID(),
+ $history->getID(),
$where,
'/'.$drequest->getPath());
}
diff --git a/src/applications/diffusion/controller/DiffusionLastModifiedController.php b/src/applications/diffusion/controller/DiffusionLastModifiedController.php
--- a/src/applications/diffusion/controller/DiffusionLastModifiedController.php
+++ b/src/applications/diffusion/controller/DiffusionLastModifiedController.php
@@ -55,10 +55,10 @@
$phids = array_filter($phids);
$handles = $this->loadViewerHandles($phids);
- $branch = $drequest->loadBranch();
- if ($branch && $commits) {
+ $history = $drequest->loadHistory();
+ if ($history && $commits) {
$lint_query = id(new DiffusionLintCountQuery())
- ->withBranchIDs(array($branch->getID()))
+ ->withHistoryIDs(array($history->getID()))
->withPaths(array_keys($commits));
if ($drequest->getLint()) {
diff --git a/src/applications/diffusion/controller/DiffusionLintController.php b/src/applications/diffusion/controller/DiffusionLintController.php
--- a/src/applications/diffusion/controller/DiffusionLintController.php
+++ b/src/applications/diffusion/controller/DiffusionLintController.php
@@ -33,25 +33,25 @@
if ($codes && !$drequest) {
// TODO: Build some real Query classes for this stuff.
- $branches = id(new PhabricatorRepositoryBranch())->loadAllWhere(
+ $histories = id(new PhabricatorRepositoryHistory())->loadAllWhere(
'id IN (%Ld)',
- array_unique(ipull($codes, 'branchID')));
+ array_unique(ipull($codes, 'historyID')));
$repositories = id(new PhabricatorRepositoryQuery())
->setViewer($user)
- ->withIDs(mpull($branches, 'getRepositoryID'))
+ ->withIDs(mpull($histories, 'getRepositoryID'))
->execute();
$drequests = array();
- foreach ($branches as $id => $branch) {
- if (empty($repositories[$branch->getRepositoryID()])) {
+ foreach ($histories as $id => $history) {
+ if (empty($repositories[$history->getRepositoryID()])) {
continue;
}
$drequests[$id] = DiffusionRequest::newFromDictionary(array(
'user' => $user,
- 'repository' => $repositories[$branch->getRepositoryID()],
- 'branch' => $branch->getName(),
+ 'repository' => $repositories[$history->getRepositoryID()],
+ 'commit' => $commit->getName(),
));
}
}
@@ -60,7 +60,7 @@
$total = 0;
foreach ($codes as $code) {
if (!$this->diffusionRequest) {
- $drequest = idx($drequests, $code['branchID']);
+ $drequest = idx($drequests, $code['historyID']);
}
if (!$drequest) {
@@ -181,12 +181,12 @@
$where = array('1 = 1');
if ($drequest) {
- $branch = $drequest->loadBranch();
- if (!$branch) {
+ $history = $drequest->loadHistory();
+ if (!$history) {
return array();
}
- $where[] = qsprintf($conn, 'branchID = %d', $branch->getID());
+ $where[] = qsprintf($conn, 'historyID = %d', $history->getID());
if ($drequest->getPath() != '') {
$path = '/'.$drequest->getPath();
@@ -217,23 +217,23 @@
->execute();
$repositories = mpull($repositories, 'getID', 'getPHID');
- $branches = id(new PhabricatorRepositoryBranch())->loadAllWhere(
+ $histories = id(new PhabricatorRepositoryHistory())->loadAllWhere(
'repositoryID IN (%Ld)',
$repositories);
- $branches = mgroup($branches, 'getRepositoryID');
+ $histories = mgroup($histories, 'getRepositoryID');
}
foreach ($paths as $path) {
- $branch = idx(
- $branches,
+ $history = idx(
+ $histories,
idx(
$repositories,
$path->getRepositoryPHID()));
- if ($branch) {
+ if ($history) {
$condition = qsprintf(
$conn,
- '(branchID IN (%Ld) AND path LIKE %>)',
- array_keys($branch),
+ '(historyID IN (%Ld) AND path LIKE %>)',
+ array_keys($history),
$path->getPath());
if ($path->getExcluded()) {
$where[] = 'NOT '.$condition;
@@ -248,7 +248,7 @@
return queryfx_all(
$conn,
'SELECT
- branchID,
+ historyID,
code,
MAX(severity) AS maxSeverity,
MAX(name) AS maxName,
diff --git a/src/applications/diffusion/controller/DiffusionLintDetailsController.php b/src/applications/diffusion/controller/DiffusionLintDetailsController.php
--- a/src/applications/diffusion/controller/DiffusionLintDetailsController.php
+++ b/src/applications/diffusion/controller/DiffusionLintDetailsController.php
@@ -7,8 +7,8 @@
$offset = $this->getRequest()->getInt('offset', 0);
$drequest = $this->getDiffusionRequest();
- $branch = $drequest->loadBranch();
- $messages = $this->loadLintMessages($branch, $limit, $offset);
+ $history = $drequest->loadHistory();
+ $messages = $this->loadLintMessages($history, $limit, $offset);
$is_dir = (substr('/'.$drequest->getPath(), -1) == '/');
$authors = $this->loadViewerHandles(ipull($messages, 'authorPHID'));
@@ -29,7 +29,7 @@
'action' => 'browse',
'path' => $message['path'],
'line' => $message['line'],
- 'commit' => $branch->getLintCommit(),
+ 'commit' => $history->getCommitIdentifier(),
))),
$message['line']);
@@ -95,19 +95,19 @@
}
private function loadLintMessages(
- PhabricatorRepositoryBranch $branch,
+ PhabricatorRepositoryHistory $history,
$limit,
$offset) {
$drequest = $this->getDiffusionRequest();
- if (!$branch) {
+ if (!$history) {
return array();
}
- $conn = $branch->establishConnection('r');
+ $conn = $history->establishConnection('r');
$where = array(
- qsprintf($conn, 'branchID = %d', $branch->getID()),
+ qsprintf($conn, 'historyID = %d', $history->getID()),
);
if ($drequest->getPath() != '') {
diff --git a/src/applications/diffusion/query/DiffusionLintCountQuery.php b/src/applications/diffusion/query/DiffusionLintCountQuery.php
--- a/src/applications/diffusion/query/DiffusionLintCountQuery.php
+++ b/src/applications/diffusion/query/DiffusionLintCountQuery.php
@@ -2,12 +2,12 @@
final class DiffusionLintCountQuery extends PhabricatorQuery {
- private $branchIDs;
+ private $historyIDs;
private $paths;
private $codes;
- public function withBranchIDs(array $branch_ids) {
- $this->branchIDs = $branch_ids;
+ public function withHistoryIDs(array $history_ids) {
+ $this->historyIDs = $history_ids;
return $this;
}
@@ -26,8 +26,8 @@
throw new Exception(pht("Call withPaths() before execute()!"));
}
- if (!$this->branchIDs) {
- throw new Exception(pht("Call withBranchIDs() before execute()!"));
+ if (!$this->historyIDs) {
+ throw new Exception(pht("Call withHistoryIDs() before execute()!"));
}
$conn_r = id(new PhabricatorRepositoryCommit())->establishConnection('r');
@@ -81,11 +81,11 @@
$this->codes);
}
- if ($this->branchIDs !== null) {
+ if ($this->historyIDs !== null) {
$where[] = qsprintf(
$conn_r,
- 'branchID IN (%Ld)',
- $this->branchIDs);
+ 'historyID IN (%Ld)',
+ $this->historyIDs);
}
return $this->formatWhereClause($where);
diff --git a/src/applications/diffusion/request/DiffusionRequest.php b/src/applications/diffusion/request/DiffusionRequest.php
--- a/src/applications/diffusion/request/DiffusionRequest.php
+++ b/src/applications/diffusion/request/DiffusionRequest.php
@@ -27,6 +27,7 @@
private $initFromConduit = true;
private $user;
private $branchObject = false;
+ private $historyObject = false;
abstract protected function getSupportsBranches();
abstract protected function isStableCommit($symbol);
@@ -350,10 +351,31 @@
return $this->branchObject;
}
+ public function loadHistory() {
+ // TODO: This will use the current commit identifier OR branch
+ // in the future when everything is hooked up.
+ $this->loadBranch();
+
+ // The branch must have commit identifier against it.
+ if (!$this->branchObject->getLintCommit()) {
+ return null;
+ }
+
+ if ($this->historyObject === false) {
+ $this->historyObject = id(new RepositoryHistory())
+ ->loadOneWhere(
+ 'commitIdentifier = %s AND repositoryID = %d',
+ $this->getBranch()->getCommitIdentifier(),
+ $this->getRepository()->getID());
+ }
+
+ return $this->historyObject;
+ }
+
public function loadCoverage() {
// TODO: This should also die.
- $branch = $this->loadBranch();
- if (!$branch) {
+ $history = $this->loadHistory();
+ if (!$history) {
return;
}
@@ -362,9 +384,9 @@
$coverage_row = queryfx_one(
id(new PhabricatorRepository())->establishConnection('r'),
- 'SELECT * FROM %T WHERE branchID = %d AND pathID = %d',
+ 'SELECT * FROM %T WHERE historyID = %d AND pathID = %d',
'repository_coverage',
- $branch->getID(),
+ $history->getID(),
$path_map[$path]);
if (!$coverage_row) {
return null;
diff --git a/src/applications/diffusion/view/DiffusionBrowseTableView.php b/src/applications/diffusion/view/DiffusionBrowseTableView.php
--- a/src/applications/diffusion/view/DiffusionBrowseTableView.php
+++ b/src/applications/diffusion/view/DiffusionBrowseTableView.php
@@ -100,8 +100,8 @@
));
}
- $branch = $this->getDiffusionRequest()->loadBranch();
- $show_lint = ($branch && $branch->getLintCommit());
+ $history = $this->getDiffusionRequest()->loadHistory();
+ $show_lint = (bool)$history;
$lint = $request->getLint();
$view = new AphrontTableView($rows);
diff --git a/src/applications/repository/storage/PhabricatorRepositoryHistory.php b/src/applications/repository/storage/PhabricatorRepositoryHistory.php
new file mode 100644
--- /dev/null
+++ b/src/applications/repository/storage/PhabricatorRepositoryHistory.php
@@ -0,0 +1,14 @@
+<?php
+
+final class PhabricatorRepositoryHistory
+ extends PhabricatorRepositoryDAO {
+
+ protected $repositoryID;
+ protected $commitIdentifier;
+ protected $historyType;
+
+ const HISTORY_BASE = 0;
+ const HISTORY_INCREMENTAL = 1;
+ const HISTORY_AGGREGATED = 2;
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, May 11, 3:59 AM (15 h, 27 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7588517
Default Alt Text
D9128.diff (15 KB)
Attached To
Mode
D9128: Initial transition to use history table everywhere
Attached
Detach File
Event Timeline
Log In to Comment