@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.

Remove most of the legacy hunk code

Summary: Ref T8475. This gets rid of most of the old "legacy hunk" code. I'll nuke the rest (and drop the old table) once we're more sure that we're in the clear.

Test Plan: Browsed Differential.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T8475

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

+1 -112
-1
bin/hunks
··· 1 - ../scripts/setup/manage_hunks.php
-21
scripts/setup/manage_hunks.php
··· 1 - #!/usr/bin/env php 2 - <?php 3 - 4 - $root = dirname(dirname(dirname(__FILE__))); 5 - require_once $root.'/scripts/__init_script__.php'; 6 - 7 - $args = new PhutilArgumentParser($argv); 8 - $args->setTagline(pht('manage hunks')); 9 - $args->setSynopsis(<<<EOSYNOPSIS 10 - **hunks** __command__ [__options__] 11 - Manage Differential hunk storage. 12 - 13 - EOSYNOPSIS 14 - ); 15 - $args->parseStandardArguments(); 16 - 17 - $workflows = id(new PhutilClassMapQuery()) 18 - ->setAncestorClass('PhabricatorHunksManagementWorkflow') 19 - ->execute(); 20 - $workflows[] = new PhutilHelpArgumentWorkflow(); 21 - $args->parseWorkflows($workflows);
-4
src/__phutil_library_map__.php
··· 2784 2784 'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php', 2785 2785 'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php', 2786 2786 'PhabricatorHovercardEngineExtensionModule' => 'applications/search/engineextension/PhabricatorHovercardEngineExtensionModule.php', 2787 - 'PhabricatorHunksManagementMigrateWorkflow' => 'applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php', 2788 - 'PhabricatorHunksManagementWorkflow' => 'applications/differential/management/PhabricatorHunksManagementWorkflow.php', 2789 2787 'PhabricatorIDsSearchEngineExtension' => 'applications/search/engineextension/PhabricatorIDsSearchEngineExtension.php', 2790 2788 'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php', 2791 2789 'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php', ··· 7777 7775 'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController', 7778 7776 'PhabricatorHovercardEngineExtension' => 'Phobject', 7779 7777 'PhabricatorHovercardEngineExtensionModule' => 'PhabricatorConfigModule', 7780 - 'PhabricatorHunksManagementMigrateWorkflow' => 'PhabricatorHunksManagementWorkflow', 7781 - 'PhabricatorHunksManagementWorkflow' => 'PhabricatorManagementWorkflow', 7782 7778 'PhabricatorIDsSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 7783 7779 'PhabricatorIDsSearchField' => 'PhabricatorSearchField', 7784 7780 'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter',
-60
src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php
··· 1 - <?php 2 - 3 - final class PhabricatorHunksManagementMigrateWorkflow 4 - extends PhabricatorHunksManagementWorkflow { 5 - 6 - protected function didConstruct() { 7 - $this 8 - ->setName('migrate') 9 - ->setExamples('**migrate**') 10 - ->setSynopsis(pht('Migrate hunks to modern storage.')) 11 - ->setArguments(array()); 12 - } 13 - 14 - public function execute(PhutilArgumentParser $args) { 15 - $saw_any_rows = false; 16 - $console = PhutilConsole::getConsole(); 17 - 18 - $table = new DifferentialLegacyHunk(); 19 - foreach (new LiskMigrationIterator($table) as $hunk) { 20 - $saw_any_rows = true; 21 - 22 - $id = $hunk->getID(); 23 - $console->writeOut("%s\n", pht('Migrating hunk %d...', $id)); 24 - 25 - $new_hunk = id(new DifferentialModernHunk()) 26 - ->setChangesetID($hunk->getChangesetID()) 27 - ->setOldOffset($hunk->getOldOffset()) 28 - ->setOldLen($hunk->getOldLen()) 29 - ->setNewOffset($hunk->getNewOffset()) 30 - ->setNewLen($hunk->getNewLen()) 31 - ->setChanges($hunk->getChanges()) 32 - ->setDateCreated($hunk->getDateCreated()) 33 - ->setDateModified($hunk->getDateModified()); 34 - 35 - $hunk->openTransaction(); 36 - $new_hunk->save(); 37 - $hunk->delete(); 38 - $hunk->saveTransaction(); 39 - 40 - $old_len = strlen($hunk->getChanges()); 41 - $new_len = strlen($new_hunk->getData()); 42 - if ($old_len) { 43 - $diff_len = ($old_len - $new_len); 44 - $console->writeOut( 45 - "%s\n", 46 - pht( 47 - 'Saved %s bytes (%s).', 48 - new PhutilNumber($diff_len), 49 - sprintf('%.1f%%', 100 * ($diff_len / $old_len)))); 50 - } 51 - } 52 - 53 - if ($saw_any_rows) { 54 - $console->writeOut("%s\n", pht('Done.')); 55 - } else { 56 - $console->writeOut("%s\n", pht('No rows to migrate.')); 57 - } 58 - } 59 - 60 - }
-4
src/applications/differential/management/PhabricatorHunksManagementWorkflow.php
··· 1 - <?php 2 - 3 - abstract class PhabricatorHunksManagementWorkflow 4 - extends PhabricatorManagementWorkflow {}
+1 -15
src/applications/differential/query/DifferentialHunkQuery.php
··· 46 46 $this->buildLimitClause($conn_r)); 47 47 $modern_results = $table->loadAllFromArray($modern_data); 48 48 49 - 50 - // Now, load legacy hunks. 51 - $table = new DifferentialLegacyHunk(); 52 - $conn_r = $table->establishConnection('r'); 53 - 54 - $legacy_data = queryfx_all( 55 - $conn_r, 56 - 'SELECT * FROM %T %Q %Q %Q', 57 - $table->getTableName(), 58 - $this->buildWhereClause($conn_r), 59 - $this->buildOrderClause($conn_r), 60 - $this->buildLimitClause($conn_r)); 61 - $legacy_results = $table->loadAllFromArray($legacy_data); 62 - 63 49 // Strip all the IDs off since they're not unique and nothing should be 64 50 // using them. 65 - return array_values(array_merge($legacy_results, $modern_results)); 51 + return array_values($modern_results); 66 52 } 67 53 68 54 protected function willFilterPage(array $hunks) {
-7
src/applications/differential/storage/DifferentialChangeset.php
··· 98 98 public function delete() { 99 99 $this->openTransaction(); 100 100 101 - $legacy_hunks = id(new DifferentialLegacyHunk())->loadAllWhere( 102 - 'changesetID = %d', 103 - $this->getID()); 104 - foreach ($legacy_hunks as $legacy_hunk) { 105 - $legacy_hunk->delete(); 106 - } 107 - 108 101 $modern_hunks = id(new DifferentialModernHunk())->loadAllWhere( 109 102 'changesetID = %d', 110 103 $this->getID());