@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

When destorying a repository, print a notification about removing the working copy

Summary:
Fixes T12946. `bin/remove destroy` does not remove working copies: it's more dangerous than usual, and we can't do it in the general (clustered) case.

Print a notification message after destroying a repository.

Test Plan:
- Destroyed a repository, got a hint about the working copy.
- Destroyed a task, things worked normally.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12946

Differential Revision: https://secure.phabricator.com/D18313

+160 -2
+6
src/__phutil_library_map__.php
··· 2642 2642 'PhabricatorDefaultSyntaxStyle' => 'infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php', 2643 2643 'PhabricatorDesktopNotificationsSetting' => 'applications/settings/setting/PhabricatorDesktopNotificationsSetting.php', 2644 2644 'PhabricatorDesktopNotificationsSettingsPanel' => 'applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php', 2645 + 'PhabricatorDestructibleCodex' => 'applications/system/codex/PhabricatorDestructibleCodex.php', 2646 + 'PhabricatorDestructibleCodexInterface' => 'applications/system/interface/PhabricatorDestructibleCodexInterface.php', 2645 2647 'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php', 2646 2648 'PhabricatorDestructionEngine' => 'applications/system/engine/PhabricatorDestructionEngine.php', 2647 2649 'PhabricatorDestructionEngineExtension' => 'applications/system/engine/PhabricatorDestructionEngineExtension.php', ··· 3780 3782 'PhabricatorRepositoryCommitTestCase' => 'applications/repository/storage/__tests__/PhabricatorRepositoryCommitTestCase.php', 3781 3783 'PhabricatorRepositoryConfigOptions' => 'applications/repository/config/PhabricatorRepositoryConfigOptions.php', 3782 3784 'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php', 3785 + 'PhabricatorRepositoryDestructibleCodex' => 'applications/repository/codex/PhabricatorRepositoryDestructibleCodex.php', 3783 3786 'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php', 3784 3787 'PhabricatorRepositoryEditor' => 'applications/repository/editor/PhabricatorRepositoryEditor.php', 3785 3788 'PhabricatorRepositoryEngine' => 'applications/repository/engine/PhabricatorRepositoryEngine.php', ··· 7937 7940 'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle', 7938 7941 'PhabricatorDesktopNotificationsSetting' => 'PhabricatorInternalSetting', 7939 7942 'PhabricatorDesktopNotificationsSettingsPanel' => 'PhabricatorSettingsPanel', 7943 + 'PhabricatorDestructibleCodex' => 'Phobject', 7940 7944 'PhabricatorDestructionEngine' => 'Phobject', 7941 7945 'PhabricatorDestructionEngineExtension' => 'Phobject', 7942 7946 'PhabricatorDestructionEngineExtensionModule' => 'PhabricatorConfigModule', ··· 9241 9245 'PhabricatorFlaggableInterface', 9242 9246 'PhabricatorMarkupInterface', 9243 9247 'PhabricatorDestructibleInterface', 9248 + 'PhabricatorDestructibleCodexInterface', 9244 9249 'PhabricatorProjectInterface', 9245 9250 'PhabricatorSpacesInterface', 9246 9251 'PhabricatorConduitResultInterface', ··· 9283 9288 'PhabricatorRepositoryCommitTestCase' => 'PhabricatorTestCase', 9284 9289 'PhabricatorRepositoryConfigOptions' => 'PhabricatorApplicationConfigOptions', 9285 9290 'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO', 9291 + 'PhabricatorRepositoryDestructibleCodex' => 'PhabricatorDestructibleCodex', 9286 9292 'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine', 9287 9293 'PhabricatorRepositoryEditor' => 'PhabricatorApplicationTransactionEditor', 9288 9294 'PhabricatorRepositoryEngine' => 'Phobject',
+23
src/applications/repository/codex/PhabricatorRepositoryDestructibleCodex.php
··· 1 + <?php 2 + 3 + final class PhabricatorRepositoryDestructibleCodex 4 + extends PhabricatorDestructibleCodex { 5 + 6 + public function getDestructionNotes() { 7 + $repository = $this->getObject(); 8 + 9 + $notes = array(); 10 + 11 + if ($repository->hasLocalWorkingCopy()) { 12 + $notes[] = pht( 13 + 'Database records for repository "%s" were destroyed, but this '. 14 + 'script does not remove working copies on disk. If you also want to '. 15 + 'destroy the repository working copy, manually remove "%s".', 16 + $repository->getDisplayName(), 17 + $repository->getLocalPath()); 18 + } 19 + 20 + return $notes; 21 + } 22 + 23 + }
+9
src/applications/repository/storage/PhabricatorRepository.php
··· 12 12 PhabricatorFlaggableInterface, 13 13 PhabricatorMarkupInterface, 14 14 PhabricatorDestructibleInterface, 15 + PhabricatorDestructibleCodexInterface, 15 16 PhabricatorProjectInterface, 16 17 PhabricatorSpacesInterface, 17 18 PhabricatorConduitResultInterface, ··· 2554 2555 } 2555 2556 2556 2557 $this->saveTransaction(); 2558 + } 2559 + 2560 + 2561 + /* -( PhabricatorDestructibleCodexInterface )------------------------------ */ 2562 + 2563 + 2564 + public function newDestructibleCodex() { 2565 + return new PhabricatorRepositoryDestructibleCodex(); 2557 2566 } 2558 2567 2559 2568
+66
src/applications/system/codex/PhabricatorDestructibleCodex.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorDestructibleCodex 4 + extends Phobject { 5 + 6 + private $viewer; 7 + private $object; 8 + 9 + public function getDestructionNotes() { 10 + return array(); 11 + } 12 + 13 + final public function setViewer(PhabricatorUser $viewer) { 14 + $this->viewer = $viewer; 15 + return $this; 16 + } 17 + 18 + final public function getViewer() { 19 + return $this->viewer; 20 + } 21 + 22 + final public function setObject( 23 + PhabricatorDestructibleCodexInterface $object) { 24 + $this->object = $object; 25 + return $this; 26 + } 27 + 28 + final public function getObject() { 29 + return $this->object; 30 + } 31 + 32 + final public static function newFromObject( 33 + PhabricatorDestructibleCodexInterface $object, 34 + PhabricatorUser $viewer) { 35 + 36 + if (!($object instanceof PhabricatorDestructibleInterface)) { 37 + throw new Exception( 38 + pht( 39 + 'Object (of class "%s") implements interface "%s", but must also '. 40 + 'implement interface "%s".', 41 + get_class($object), 42 + 'PhabricatorDestructibleCodexInterface', 43 + 'PhabricatorDestructibleInterface')); 44 + } 45 + 46 + $codex = $object->newDestructibleCodex(); 47 + if (!($codex instanceof PhabricatorDestructibleCodex)) { 48 + throw new Exception( 49 + pht( 50 + 'Object (of class "%s") implements interface "%s", but defines '. 51 + 'method "%s" incorrectly: this method must return an object of '. 52 + 'class "%s".', 53 + get_class($object), 54 + 'PhabricatorDestructibleCodexInterface', 55 + 'newDestructibleCodex()', 56 + __CLASS__)); 57 + } 58 + 59 + $codex 60 + ->setObject($object) 61 + ->setViewer($viewer); 62 + 63 + return $codex; 64 + } 65 + 66 + }
+23
src/applications/system/engine/PhabricatorDestructionEngine.php
··· 3 3 final class PhabricatorDestructionEngine extends Phobject { 4 4 5 5 private $rootLogID; 6 + private $collectNotes; 7 + private $notes = array(); 8 + 9 + public function setCollectNotes($collect_notes) { 10 + $this->collectNotes = $collect_notes; 11 + return $this; 12 + } 13 + 14 + public function getNotes() { 15 + return $this->notes; 16 + } 6 17 7 18 public function getViewer() { 8 19 return PhabricatorUser::getOmnipotentUser(); ··· 34 45 35 46 if (!$this->rootLogID) { 36 47 $this->rootLogID = $log->getID(); 48 + } 49 + 50 + if ($this->collectNotes) { 51 + if ($object instanceof PhabricatorDestructibleCodexInterface) { 52 + $codex = PhabricatorDestructibleCodex::newFromObject( 53 + $object, 54 + $this->getViewer()); 55 + 56 + foreach ($codex->getDestructionNotes() as $note) { 57 + $this->notes[] = $note; 58 + } 59 + } 37 60 } 38 61 39 62 $object->destroyObjectPermanently($this);
+18
src/applications/system/interface/PhabricatorDestructibleCodexInterface.php
··· 1 + <?php 2 + 3 + interface PhabricatorDestructibleCodexInterface { 4 + 5 + public function newDestructibleCodex(); 6 + 7 + } 8 + 9 + // TEMPLATE IMPLEMENTATION ///////////////////////////////////////////////////// 10 + 11 + /* -( PhabricatorDestructibleCodexInterface )------------------------------ */ 12 + /* 13 + 14 + public function newDestructibleCodex() { 15 + return new <<...>>DestructibleCodex(); 16 + } 17 + 18 + */
+15 -2
src/applications/system/management/PhabricatorSystemRemoveDestroyWorkflow.php
··· 145 145 146 146 $console->writeOut("%s\n", pht('Destroying objects...')); 147 147 148 + $notes = array(); 148 149 foreach ($named_objects as $object_name => $object) { 149 150 $console->writeOut( 150 151 pht( ··· 152 153 get_class($object), 153 154 $object_name)); 154 155 155 - id(new PhabricatorDestructionEngine()) 156 - ->destroyObject($object); 156 + $engine = id(new PhabricatorDestructionEngine()) 157 + ->setCollectNotes(true); 158 + 159 + $engine->destroyObject($object); 160 + 161 + foreach ($engine->getNotes() as $note) { 162 + $notes[] = $note; 163 + } 157 164 } 158 165 159 166 $console->writeOut( ··· 161 168 pht( 162 169 'Permanently destroyed %s object(s).', 163 170 phutil_count($named_objects))); 171 + 172 + if ($notes) { 173 + id(new PhutilConsoleList()) 174 + ->addItems($notes) 175 + ->draw(); 176 + } 164 177 165 178 return 0; 166 179 }