Page MenuHomePhabricator

D16435.diff
No OneTemporary

D16435.diff

diff --git a/resources/sql/autopatches/20160824.repohint.02.movebad.php b/resources/sql/autopatches/20160824.repohint.02.movebad.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160824.repohint.02.movebad.php
@@ -0,0 +1,39 @@
+<?php
+
+$table = new PhabricatorRepositoryCommit();
+$conn = $table->establishConnection('w');
+
+$rows = queryfx_all(
+ $conn,
+ 'SELECT fullCommitName FROM repository_badcommit');
+
+$viewer = PhabricatorUser::getOmnipotentUser();
+
+foreach ($rows as $row) {
+ $identifier = $row['fullCommitName'];
+
+ $commit = id(new DiffusionCommitQuery())
+ ->setViewer($viewer)
+ ->withIdentifiers(array($identifier))
+ ->executeOne();
+
+ if (!$commit) {
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'Skipped hint for "%s", this is not a valid commit.',
+ $identifier));
+ } else {
+ PhabricatorRepositoryCommitHint::updateHint(
+ $commit->getRepository()->getPHID(),
+ $commit->getCommitIdentifier(),
+ null,
+ PhabricatorRepositoryCommitHint::HINT_UNREADABLE);
+
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'Updated commit hint for "%s".',
+ $identifier));
+ }
+}
diff --git a/resources/sql/autopatches/20160824.repohint.03.nukebad.sql b/resources/sql/autopatches/20160824.repohint.03.nukebad.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20160824.repohint.03.nukebad.sql
@@ -0,0 +1 @@
+DROP TABLE {$NAMESPACE}_repository.repository_badcommit;
diff --git a/src/applications/diffusion/controller/DiffusionCommitController.php b/src/applications/diffusion/controller/DiffusionCommitController.php
--- a/src/applications/diffusion/controller/DiffusionCommitController.php
+++ b/src/applications/diffusion/controller/DiffusionCommitController.php
@@ -167,23 +167,29 @@
$count = count($changes);
- $bad_commit = null;
- if ($count == 0) {
- $bad_commit = queryfx_one(
- id(new PhabricatorRepository())->establishConnection('r'),
- 'SELECT * FROM %T WHERE fullCommitName = %s',
- PhabricatorRepository::TABLE_BADCOMMIT,
- $commit->getMonogram());
+ $is_unreadable = false;
+ if (!$count) {
+ $hint = id(new DiffusionCommitHintQuery())
+ ->setViewer($viewer)
+ ->withRepositoryPHIDs(array($repository->getPHID()))
+ ->withOldCommitIdentifiers(array($commit->getCommitIdentifier()))
+ ->executeOne();
+ if ($hint) {
+ $is_unreadable = $hint->isUnreadable();
+ }
}
$show_changesets = false;
$info_panel = null;
$change_list = null;
$change_table = null;
- if ($bad_commit) {
+ if ($is_unreadable) {
$info_panel = $this->renderStatusMessage(
- pht('Bad Commit'),
- $bad_commit['description']);
+ pht('Unreadable Commit'),
+ pht(
+ 'This commit has been marked as unreadable by an administrator. '.
+ 'It may have been corrupted or created improperly by an external '.
+ 'tool.'));
} else if ($is_foreign) {
// Don't render anything else.
} else if (!$commit->isImported()) {
diff --git a/src/applications/diffusion/query/DiffusionCommitHintQuery.php b/src/applications/diffusion/query/DiffusionCommitHintQuery.php
--- a/src/applications/diffusion/query/DiffusionCommitHintQuery.php
+++ b/src/applications/diffusion/query/DiffusionCommitHintQuery.php
@@ -43,7 +43,7 @@
if ($this->repositoryPHIDs !== null) {
$where[] = qsprintf(
$conn,
- 'reositoryPHID IN (%Ls)',
+ 'repositoryPHID IN (%Ls)',
$this->repositoryPHIDs);
}
diff --git a/src/applications/repository/storage/PhabricatorRepository.php b/src/applications/repository/storage/PhabricatorRepository.php
--- a/src/applications/repository/storage/PhabricatorRepository.php
+++ b/src/applications/repository/storage/PhabricatorRepository.php
@@ -35,7 +35,6 @@
const TABLE_PATHCHANGE = 'repository_pathchange';
const TABLE_FILESYSTEM = 'repository_filesystem';
const TABLE_SUMMARY = 'repository_summary';
- const TABLE_BADCOMMIT = 'repository_badcommit';
const TABLE_LINTMESSAGE = 'repository_lintmessage';
const TABLE_PARENTS = 'repository_parents';
const TABLE_COVERAGE = 'repository_coverage';
diff --git a/src/applications/repository/storage/PhabricatorRepositoryCommitHint.php b/src/applications/repository/storage/PhabricatorRepositoryCommitHint.php
--- a/src/applications/repository/storage/PhabricatorRepositoryCommitHint.php
+++ b/src/applications/repository/storage/PhabricatorRepositoryCommitHint.php
@@ -101,6 +101,11 @@
}
+ public function isUnreadable() {
+ return ($this->getHintType() == self::HINT_UNREADABLE);
+ }
+
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
diff --git a/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php b/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
--- a/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
+++ b/src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
@@ -8,20 +8,6 @@
$this->buildRawSchema(
id(new PhabricatorRepository())->getApplicationName(),
- PhabricatorRepository::TABLE_BADCOMMIT,
- array(
- 'fullCommitName' => 'text64',
- 'description' => 'text',
- ),
- array(
- 'PRIMARY' => array(
- 'columns' => array('fullCommitName'),
- 'unique' => true,
- ),
- ));
-
- $this->buildRawSchema(
- id(new PhabricatorRepository())->getApplicationName(),
PhabricatorRepository::TABLE_COVERAGE,
array(
'id' => 'auto',
diff --git a/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php b/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
--- a/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
+++ b/src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
@@ -95,16 +95,16 @@
PhabricatorRepository $repository,
PhabricatorRepositoryCommit $commit);
- protected function isBadCommit(PhabricatorRepositoryCommit $commit) {
- $repository = new PhabricatorRepository();
+ protected function loadCommitHint(PhabricatorRepositoryCommit $commit) {
+ $viewer = PhabricatorUser::getOmnipotentUser();
- $bad_commit = queryfx_one(
- $repository->establishConnection('w'),
- 'SELECT * FROM %T WHERE fullCommitName = %s',
- PhabricatorRepository::TABLE_BADCOMMIT,
- $commit->getMonogram());
+ $repository = $commit->getRepository();
- return (bool)$bad_commit;
+ return id(new DiffusionCommitHintQuery())
+ ->setViewer($viewer)
+ ->withRepositoryPHIDs(array($repository->getPHID()))
+ ->withOldCommitIdentifiers(array($commit->getCommitIdentifier()))
+ ->executeOne();
}
public function renderForDisplay(PhabricatorUser $viewer) {
diff --git a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
--- a/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
+++ b/src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
@@ -22,8 +22,13 @@
PhabricatorRepositoryCommit $commit) {
$this->log("%s\n", pht('Parsing "%s"...', $commit->getMonogram()));
- if ($this->isBadCommit($commit)) {
- $this->log(pht('This commit is marked bad!'));
+
+ $hint = $this->loadCommitHint($commit);
+ if ($hint && $hint->isUnreadable()) {
+ $this->log(
+ pht(
+ 'This commit is marked as unreadable, so changes will not be '.
+ 'parsed.'));
return;
}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 24, 2:24 AM (19 h, 13 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6922707
Default Alt Text
D16435.diff (7 KB)

Event Timeline