1
0
Fork 0
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:
epriestley 2016-12-13 10:01:49 -08:00
parent c67e87c809
commit 1e9a462baa
7 changed files with 1 additions and 112 deletions

View file

@ -1 +0,0 @@
../scripts/setup/manage_hunks.php

View file

@ -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);

View file

@ -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',

View file

@ -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.'));
}
}
}

View file

@ -1,4 +0,0 @@
<?php
abstract class PhabricatorHunksManagementWorkflow
extends PhabricatorManagementWorkflow {}

View file

@ -46,23 +46,9 @@ final class DifferentialHunkQuery
$this->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) {

View file

@ -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());