@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Migrate the "badcommit" table to use the less-hacky "hint" mechanism

Summary: Ref T11522. This migrates any "badcommit" data (which probably only exists at Facebook and on 1-2 other installs in the wild) to the new "hint" table.

Test Plan:
- Wrote some bad commit annotations to the badcommit table.
- Viewed them in the web UI and used `bin/repository reparse --change ...` to reparse them. Saw "this is bad" messages.
- Ran migration, verified that valid "badcommit" rows were successfully migrated to become "hint" rows.
- Viewed the new web UI and re-parsed the change, saw "unreadable commit" messages.
- Viewed a good commit; reparsed a good commit.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11522

Differential Revision: https://secure.phabricator.com/D16435

+77 -36
+39
resources/sql/autopatches/20160824.repohint.02.movebad.php
··· 1 + <?php 2 + 3 + $table = new PhabricatorRepositoryCommit(); 4 + $conn = $table->establishConnection('w'); 5 + 6 + $rows = queryfx_all( 7 + $conn, 8 + 'SELECT fullCommitName FROM repository_badcommit'); 9 + 10 + $viewer = PhabricatorUser::getOmnipotentUser(); 11 + 12 + foreach ($rows as $row) { 13 + $identifier = $row['fullCommitName']; 14 + 15 + $commit = id(new DiffusionCommitQuery()) 16 + ->setViewer($viewer) 17 + ->withIdentifiers(array($identifier)) 18 + ->executeOne(); 19 + 20 + if (!$commit) { 21 + echo tsprintf( 22 + "%s\n", 23 + pht( 24 + 'Skipped hint for "%s", this is not a valid commit.', 25 + $identifier)); 26 + } else { 27 + PhabricatorRepositoryCommitHint::updateHint( 28 + $commit->getRepository()->getPHID(), 29 + $commit->getCommitIdentifier(), 30 + null, 31 + PhabricatorRepositoryCommitHint::HINT_UNREADABLE); 32 + 33 + echo tsprintf( 34 + "%s\n", 35 + pht( 36 + 'Updated commit hint for "%s".', 37 + $identifier)); 38 + } 39 + }
+1
resources/sql/autopatches/20160824.repohint.03.nukebad.sql
··· 1 + DROP TABLE {$NAMESPACE}_repository.repository_badcommit;
+16 -10
src/applications/diffusion/controller/DiffusionCommitController.php
··· 167 167 168 168 $count = count($changes); 169 169 170 - $bad_commit = null; 171 - if ($count == 0) { 172 - $bad_commit = queryfx_one( 173 - id(new PhabricatorRepository())->establishConnection('r'), 174 - 'SELECT * FROM %T WHERE fullCommitName = %s', 175 - PhabricatorRepository::TABLE_BADCOMMIT, 176 - $commit->getMonogram()); 170 + $is_unreadable = false; 171 + if (!$count) { 172 + $hint = id(new DiffusionCommitHintQuery()) 173 + ->setViewer($viewer) 174 + ->withRepositoryPHIDs(array($repository->getPHID())) 175 + ->withOldCommitIdentifiers(array($commit->getCommitIdentifier())) 176 + ->executeOne(); 177 + if ($hint) { 178 + $is_unreadable = $hint->isUnreadable(); 179 + } 177 180 } 178 181 179 182 $show_changesets = false; 180 183 $info_panel = null; 181 184 $change_list = null; 182 185 $change_table = null; 183 - if ($bad_commit) { 186 + if ($is_unreadable) { 184 187 $info_panel = $this->renderStatusMessage( 185 - pht('Bad Commit'), 186 - $bad_commit['description']); 188 + pht('Unreadable Commit'), 189 + pht( 190 + 'This commit has been marked as unreadable by an administrator. '. 191 + 'It may have been corrupted or created improperly by an external '. 192 + 'tool.')); 187 193 } else if ($is_foreign) { 188 194 // Don't render anything else. 189 195 } else if (!$commit->isImported()) {
+1 -1
src/applications/diffusion/query/DiffusionCommitHintQuery.php
··· 43 43 if ($this->repositoryPHIDs !== null) { 44 44 $where[] = qsprintf( 45 45 $conn, 46 - 'reositoryPHID IN (%Ls)', 46 + 'repositoryPHID IN (%Ls)', 47 47 $this->repositoryPHIDs); 48 48 } 49 49
-1
src/applications/repository/storage/PhabricatorRepository.php
··· 35 35 const TABLE_PATHCHANGE = 'repository_pathchange'; 36 36 const TABLE_FILESYSTEM = 'repository_filesystem'; 37 37 const TABLE_SUMMARY = 'repository_summary'; 38 - const TABLE_BADCOMMIT = 'repository_badcommit'; 39 38 const TABLE_LINTMESSAGE = 'repository_lintmessage'; 40 39 const TABLE_PARENTS = 'repository_parents'; 41 40 const TABLE_COVERAGE = 'repository_coverage';
+5
src/applications/repository/storage/PhabricatorRepositoryCommitHint.php
··· 101 101 } 102 102 103 103 104 + public function isUnreadable() { 105 + return ($this->getHintType() == self::HINT_UNREADABLE); 106 + } 107 + 108 + 104 109 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 105 110 106 111
-14
src/applications/repository/storage/PhabricatorRepositorySchemaSpec.php
··· 8 8 9 9 $this->buildRawSchema( 10 10 id(new PhabricatorRepository())->getApplicationName(), 11 - PhabricatorRepository::TABLE_BADCOMMIT, 12 - array( 13 - 'fullCommitName' => 'text64', 14 - 'description' => 'text', 15 - ), 16 - array( 17 - 'PRIMARY' => array( 18 - 'columns' => array('fullCommitName'), 19 - 'unique' => true, 20 - ), 21 - )); 22 - 23 - $this->buildRawSchema( 24 - id(new PhabricatorRepository())->getApplicationName(), 25 11 PhabricatorRepository::TABLE_COVERAGE, 26 12 array( 27 13 'id' => 'auto',
+8 -8
src/applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php
··· 95 95 PhabricatorRepository $repository, 96 96 PhabricatorRepositoryCommit $commit); 97 97 98 - protected function isBadCommit(PhabricatorRepositoryCommit $commit) { 99 - $repository = new PhabricatorRepository(); 98 + protected function loadCommitHint(PhabricatorRepositoryCommit $commit) { 99 + $viewer = PhabricatorUser::getOmnipotentUser(); 100 100 101 - $bad_commit = queryfx_one( 102 - $repository->establishConnection('w'), 103 - 'SELECT * FROM %T WHERE fullCommitName = %s', 104 - PhabricatorRepository::TABLE_BADCOMMIT, 105 - $commit->getMonogram()); 101 + $repository = $commit->getRepository(); 106 102 107 - return (bool)$bad_commit; 103 + return id(new DiffusionCommitHintQuery()) 104 + ->setViewer($viewer) 105 + ->withRepositoryPHIDs(array($repository->getPHID())) 106 + ->withOldCommitIdentifiers(array($commit->getCommitIdentifier())) 107 + ->executeOne(); 108 108 } 109 109 110 110 public function renderForDisplay(PhabricatorUser $viewer) {
+7 -2
src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
··· 22 22 PhabricatorRepositoryCommit $commit) { 23 23 24 24 $this->log("%s\n", pht('Parsing "%s"...', $commit->getMonogram())); 25 - if ($this->isBadCommit($commit)) { 26 - $this->log(pht('This commit is marked bad!')); 25 + 26 + $hint = $this->loadCommitHint($commit); 27 + if ($hint && $hint->isUnreadable()) { 28 + $this->log( 29 + pht( 30 + 'This commit is marked as unreadable, so changes will not be '. 31 + 'parsed.')); 27 32 return; 28 33 } 29 34