|
| 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 DifferentialHunkLegacy(); |
| 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 DifferentialHunkModern()) |
| 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 | + |
| 41 | + if ($saw_any_rows) { |
| 42 | + $console->writeOut("%s\n", pht('Done.')); |
| 43 | + } else { |
| 44 | + $console->writeOut("%s\n", pht('No rows to migrate.')); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | +} |
0 commit comments