mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-17 12:22:42 +01:00
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
This commit is contained in:
parent
c67e87c809
commit
1e9a462baa
7 changed files with 1 additions and 112 deletions
|
@ -1 +0,0 @@
|
||||||
../scripts/setup/manage_hunks.php
|
|
|
@ -1,21 +0,0 @@
|
||||||
#!/usr/bin/env php
|
|
||||||
<?php
|
|
||||||
|
|
||||||
$root = dirname(dirname(dirname(__FILE__)));
|
|
||||||
require_once $root.'/scripts/__init_script__.php';
|
|
||||||
|
|
||||||
$args = new PhutilArgumentParser($argv);
|
|
||||||
$args->setTagline(pht('manage hunks'));
|
|
||||||
$args->setSynopsis(<<<EOSYNOPSIS
|
|
||||||
**hunks** __command__ [__options__]
|
|
||||||
Manage Differential hunk storage.
|
|
||||||
|
|
||||||
EOSYNOPSIS
|
|
||||||
);
|
|
||||||
$args->parseStandardArguments();
|
|
||||||
|
|
||||||
$workflows = id(new PhutilClassMapQuery())
|
|
||||||
->setAncestorClass('PhabricatorHunksManagementWorkflow')
|
|
||||||
->execute();
|
|
||||||
$workflows[] = new PhutilHelpArgumentWorkflow();
|
|
||||||
$args->parseWorkflows($workflows);
|
|
|
@ -2784,8 +2784,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php',
|
'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php',
|
||||||
'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php',
|
'PhabricatorHovercardEngineExtension' => 'applications/search/engineextension/PhabricatorHovercardEngineExtension.php',
|
||||||
'PhabricatorHovercardEngineExtensionModule' => 'applications/search/engineextension/PhabricatorHovercardEngineExtensionModule.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',
|
'PhabricatorIDsSearchEngineExtension' => 'applications/search/engineextension/PhabricatorIDsSearchEngineExtension.php',
|
||||||
'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php',
|
'PhabricatorIDsSearchField' => 'applications/search/field/PhabricatorIDsSearchField.php',
|
||||||
'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php',
|
'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php',
|
||||||
|
@ -7777,8 +7775,6 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController',
|
'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController',
|
||||||
'PhabricatorHovercardEngineExtension' => 'Phobject',
|
'PhabricatorHovercardEngineExtension' => 'Phobject',
|
||||||
'PhabricatorHovercardEngineExtensionModule' => 'PhabricatorConfigModule',
|
'PhabricatorHovercardEngineExtensionModule' => 'PhabricatorConfigModule',
|
||||||
'PhabricatorHunksManagementMigrateWorkflow' => 'PhabricatorHunksManagementWorkflow',
|
|
||||||
'PhabricatorHunksManagementWorkflow' => 'PhabricatorManagementWorkflow',
|
|
||||||
'PhabricatorIDsSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
'PhabricatorIDsSearchEngineExtension' => 'PhabricatorSearchEngineExtension',
|
||||||
'PhabricatorIDsSearchField' => 'PhabricatorSearchField',
|
'PhabricatorIDsSearchField' => 'PhabricatorSearchField',
|
||||||
'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter',
|
'PhabricatorIRCProtocolAdapter' => 'PhabricatorProtocolAdapter',
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
final class PhabricatorHunksManagementMigrateWorkflow
|
|
||||||
extends PhabricatorHunksManagementWorkflow {
|
|
||||||
|
|
||||||
protected function didConstruct() {
|
|
||||||
$this
|
|
||||||
->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.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
abstract class PhabricatorHunksManagementWorkflow
|
|
||||||
extends PhabricatorManagementWorkflow {}
|
|
|
@ -46,23 +46,9 @@ final class DifferentialHunkQuery
|
||||||
$this->buildLimitClause($conn_r));
|
$this->buildLimitClause($conn_r));
|
||||||
$modern_results = $table->loadAllFromArray($modern_data);
|
$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
|
// Strip all the IDs off since they're not unique and nothing should be
|
||||||
// using them.
|
// using them.
|
||||||
return array_values(array_merge($legacy_results, $modern_results));
|
return array_values($modern_results);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function willFilterPage(array $hunks) {
|
protected function willFilterPage(array $hunks) {
|
||||||
|
|
|
@ -98,13 +98,6 @@ final class DifferentialChangeset extends DifferentialDAO
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$this->openTransaction();
|
$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(
|
$modern_hunks = id(new DifferentialModernHunk())->loadAllWhere(
|
||||||
'changesetID = %d',
|
'changesetID = %d',
|
||||||
$this->getID());
|
$this->getID());
|
||||||
|
|
Loading…
Reference in a new issue