From 1e9a462baac35314ede3e5ecadbac200dec9e7b6 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 13 Dec 2016 10:01:49 -0800 Subject: [PATCH] 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 --- bin/hunks | 1 - scripts/setup/manage_hunks.php | 21 ------- src/__phutil_library_map__.php | 4 -- ...bricatorHunksManagementMigrateWorkflow.php | 60 ------------------- .../PhabricatorHunksManagementWorkflow.php | 4 -- .../query/DifferentialHunkQuery.php | 16 +---- .../storage/DifferentialChangeset.php | 7 --- 7 files changed, 1 insertion(+), 112 deletions(-) delete mode 120000 bin/hunks delete mode 100755 scripts/setup/manage_hunks.php delete mode 100644 src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php delete mode 100644 src/applications/differential/management/PhabricatorHunksManagementWorkflow.php diff --git a/bin/hunks b/bin/hunks deleted file mode 120000 index dc2cf5492e..0000000000 --- a/bin/hunks +++ /dev/null @@ -1 +0,0 @@ -../scripts/setup/manage_hunks.php \ No newline at end of file diff --git a/scripts/setup/manage_hunks.php b/scripts/setup/manage_hunks.php deleted file mode 100755 index a2d35779de..0000000000 --- a/scripts/setup/manage_hunks.php +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env php -setTagline(pht('manage hunks')); -$args->setSynopsis(<<parseStandardArguments(); - -$workflows = id(new PhutilClassMapQuery()) - ->setAncestorClass('PhabricatorHunksManagementWorkflow') - ->execute(); -$workflows[] = new PhutilHelpArgumentWorkflow(); -$args->parseWorkflows($workflows); diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index ee278c21dd..976ccaed3c 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -2784,8 +2784,6 @@ phutil_register_library_map(array( 'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php', 'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php', 'PhabricatorHovercardEngineExtensionModule' => 'applications/search/engineextension/PhabricatorHovercardEngineExtensionModule.php', - 'PhabricatorHunksManagementMigrateWorkflow' => 'applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php', - 'PhabricatorHunksManagementWorkflow' => 'applications/differential/management/PhabricatorHunksManagementWorkflow.php', 'PhabricatorIDsSearchEngineExtension' => 'applications/search/engineextension/PhabricatorIDsSearchEngineExtension.php', 'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php', 'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php', @@ -7777,8 +7775,6 @@ phutil_register_library_map(array( 'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController', 'PhabricatorHovercardEngineExtension' => 'Phobject', 'PhabricatorHovercardEngineExtensionModule' => 'PhabricatorConfigModule', - 'PhabricatorHunksManagementMigrateWorkflow' => 'PhabricatorHunksManagementWorkflow', - 'PhabricatorHunksManagementWorkflow' => 'PhabricatorManagementWorkflow', 'PhabricatorIDsSearchEngineExtension' => 'PhabricatorSearchEngineExtension', 'PhabricatorIDsSearchField' => 'PhabricatorSearchField', 'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter', diff --git a/src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php b/src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php deleted file mode 100644 index 90c0be1717..0000000000 --- a/src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php +++ /dev/null @@ -1,60 +0,0 @@ -setName('migrate') - ->setExamples('**migrate**') - ->setSynopsis(pht('Migrate hunks to modern storage.')) - ->setArguments(array()); - } - - public function execute(PhutilArgumentParser $args) { - $saw_any_rows = false; - $console = PhutilConsole::getConsole(); - - $table = new DifferentialLegacyHunk(); - foreach (new LiskMigrationIterator($table) as $hunk) { - $saw_any_rows = true; - - $id = $hunk->getID(); - $console->writeOut("%s\n", pht('Migrating hunk %d...', $id)); - - $new_hunk = id(new DifferentialModernHunk()) - ->setChangesetID($hunk->getChangesetID()) - ->setOldOffset($hunk->getOldOffset()) - ->setOldLen($hunk->getOldLen()) - ->setNewOffset($hunk->getNewOffset()) - ->setNewLen($hunk->getNewLen()) - ->setChanges($hunk->getChanges()) - ->setDateCreated($hunk->getDateCreated()) - ->setDateModified($hunk->getDateModified()); - - $hunk->openTransaction(); - $new_hunk->save(); - $hunk->delete(); - $hunk->saveTransaction(); - - $old_len = strlen($hunk->getChanges()); - $new_len = strlen($new_hunk->getData()); - if ($old_len) { - $diff_len = ($old_len - $new_len); - $console->writeOut( - "%s\n", - pht( - 'Saved %s bytes (%s).', - new PhutilNumber($diff_len), - sprintf('%.1f%%', 100 * ($diff_len / $old_len)))); - } - } - - if ($saw_any_rows) { - $console->writeOut("%s\n", pht('Done.')); - } else { - $console->writeOut("%s\n", pht('No rows to migrate.')); - } - } - -} diff --git a/src/applications/differential/management/PhabricatorHunksManagementWorkflow.php b/src/applications/differential/management/PhabricatorHunksManagementWorkflow.php deleted file mode 100644 index a56a5f88e7..0000000000 --- a/src/applications/differential/management/PhabricatorHunksManagementWorkflow.php +++ /dev/null @@ -1,4 +0,0 @@ -buildLimitClause($conn_r)); $modern_results = $table->loadAllFromArray($modern_data); - - // Now, load legacy hunks. - $table = new DifferentialLegacyHunk(); - $conn_r = $table->establishConnection('r'); - - $legacy_data = queryfx_all( - $conn_r, - 'SELECT * FROM %T %Q %Q %Q', - $table->getTableName(), - $this->buildWhereClause($conn_r), - $this->buildOrderClause($conn_r), - $this->buildLimitClause($conn_r)); - $legacy_results = $table->loadAllFromArray($legacy_data); - // Strip all the IDs off since they're not unique and nothing should be // using them. - return array_values(array_merge($legacy_results, $modern_results)); + return array_values($modern_results); } protected function willFilterPage(array $hunks) { diff --git a/src/applications/differential/storage/DifferentialChangeset.php b/src/applications/differential/storage/DifferentialChangeset.php index 4d7b9f5698..57f9d295b6 100644 --- a/src/applications/differential/storage/DifferentialChangeset.php +++ b/src/applications/differential/storage/DifferentialChangeset.php @@ -98,13 +98,6 @@ final class DifferentialChangeset extends DifferentialDAO public function delete() { $this->openTransaction(); - $legacy_hunks = id(new DifferentialLegacyHunk())->loadAllWhere( - 'changesetID = %d', - $this->getID()); - foreach ($legacy_hunks as $legacy_hunk) { - $legacy_hunk->delete(); - } - $modern_hunks = id(new DifferentialModernHunk())->loadAllWhere( 'changesetID = %d', $this->getID());