Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15453972
D9291.id22330.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D9291.id22330.diff
View Options
diff --git a/bin/hunks b/bin/hunks
new file mode 120000
--- /dev/null
+++ b/bin/hunks
@@ -0,0 +1 @@
+../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
new file mode 100755
--- /dev/null
+++ b/scripts/setup/manage_hunks.php
@@ -0,0 +1,21 @@
+#!/usr/bin/env php
+<?php
+
+$root = dirname(dirname(dirname(__FILE__)));
+require_once $root.'/scripts/__init_script__.php';
+
+$args = new PhutilArgumentParser($argv);
+$args->setTagline('manage hunks');
+$args->setSynopsis(<<<EOSYNOPSIS
+**hunks** __command__ [__options__]
+ Manage Differential hunk storage.
+
+EOSYNOPSIS
+ );
+$args->parseStandardArguments();
+
+$workflows = id(new PhutilSymbolLoader())
+ ->setAncestorClass('PhabricatorHunksManagementWorkflow')
+ ->loadObjects();
+$workflows[] = new PhutilHelpArgumentWorkflow();
+$args->parseWorkflows($workflows);
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1665,6 +1665,8 @@
'PhabricatorHomeQuickCreateController' => 'applications/home/controller/PhabricatorHomeQuickCreateController.php',
'PhabricatorHovercardExample' => 'applications/uiexample/examples/PhabricatorHovercardExample.php',
'PhabricatorHovercardView' => 'view/widget/hovercard/PhabricatorHovercardView.php',
+ 'PhabricatorHunksManagementMigrateWorkflow' => 'applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php',
+ 'PhabricatorHunksManagementWorkflow' => 'applications/differential/management/PhabricatorHunksManagementWorkflow.php',
'PhabricatorIRCBot' => 'infrastructure/daemon/bot/PhabricatorIRCBot.php',
'PhabricatorIRCProtocolAdapter' => 'infrastructure/daemon/bot/adapter/PhabricatorIRCProtocolAdapter.php',
'PhabricatorIRCProtocolHandler' => 'infrastructure/daemon/bot/handler/PhabricatorIRCProtocolHandler.php',
@@ -4488,6 +4490,8 @@
'PhabricatorHomeQuickCreateController' => 'PhabricatorHomeController',
'PhabricatorHovercardExample' => 'PhabricatorUIExample',
'PhabricatorHovercardView' => 'AphrontView',
+ 'PhabricatorHunksManagementMigrateWorkflow' => 'PhabricatorHunksManagementWorkflow',
+ 'PhabricatorHunksManagementWorkflow' => 'PhabricatorManagementWorkflow',
'PhabricatorIRCBot' => 'PhabricatorDaemon',
'PhabricatorIRCProtocolAdapter' => 'PhabricatorBaseProtocolAdapter',
'PhabricatorIRCProtocolHandler' => 'PhabricatorBotHandler',
diff --git a/src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php b/src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/management/PhabricatorHunksManagementMigrateWorkflow.php
@@ -0,0 +1,48 @@
+<?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 DifferentialHunkLegacy();
+ 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 DifferentialHunkModern())
+ ->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();
+ }
+
+ 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
new file mode 100644
--- /dev/null
+++ b/src/applications/differential/management/PhabricatorHunksManagementWorkflow.php
@@ -0,0 +1,6 @@
+<?php
+
+abstract class PhabricatorHunksManagementWorkflow
+ extends PhabricatorManagementWorkflow {
+
+}
diff --git a/src/applications/differential/storage/DifferentialHunk.php b/src/applications/differential/storage/DifferentialHunk.php
--- a/src/applications/differential/storage/DifferentialHunk.php
+++ b/src/applications/differential/storage/DifferentialHunk.php
@@ -57,7 +57,7 @@
final private function makeContent($include) {
$results = array();
- $lines = explode("\n", $this->changes);
+ $lines = explode("\n", $this->getChanges());
// NOTE: To determine whether the recomposed file should have a trailing
// newline, we look for a "\ No newline at end of file" line which appears
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 30, 3:25 PM (2 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7648519
Default Alt Text
D9291.id22330.diff (5 KB)
Attached To
Mode
D9291: Add a `bin/hunks` script to manage migrations of hunk data
Attached
Detach File
Event Timeline
Log In to Comment