mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-19 18:28:39 +01:00
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
This commit is contained in:
parent
03423c632c
commit
ab018e1b49
7 changed files with 160 additions and 2 deletions
|
@ -2642,6 +2642,8 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDefaultSyntaxStyle' => 'infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php',
|
'PhabricatorDefaultSyntaxStyle' => 'infrastructure/syntax/PhabricatorDefaultSyntaxStyle.php',
|
||||||
'PhabricatorDesktopNotificationsSetting' => 'applications/settings/setting/PhabricatorDesktopNotificationsSetting.php',
|
'PhabricatorDesktopNotificationsSetting' => 'applications/settings/setting/PhabricatorDesktopNotificationsSetting.php',
|
||||||
'PhabricatorDesktopNotificationsSettingsPanel' => 'applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php',
|
'PhabricatorDesktopNotificationsSettingsPanel' => 'applications/settings/panel/PhabricatorDesktopNotificationsSettingsPanel.php',
|
||||||
|
'PhabricatorDestructibleCodex' => 'applications/system/codex/PhabricatorDestructibleCodex.php',
|
||||||
|
'PhabricatorDestructibleCodexInterface' => 'applications/system/interface/PhabricatorDestructibleCodexInterface.php',
|
||||||
'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php',
|
'PhabricatorDestructibleInterface' => 'applications/system/interface/PhabricatorDestructibleInterface.php',
|
||||||
'PhabricatorDestructionEngine' => 'applications/system/engine/PhabricatorDestructionEngine.php',
|
'PhabricatorDestructionEngine' => 'applications/system/engine/PhabricatorDestructionEngine.php',
|
||||||
'PhabricatorDestructionEngineExtension' => 'applications/system/engine/PhabricatorDestructionEngineExtension.php',
|
'PhabricatorDestructionEngineExtension' => 'applications/system/engine/PhabricatorDestructionEngineExtension.php',
|
||||||
|
@ -3780,6 +3782,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRepositoryCommitTestCase' => 'applications/repository/storage/__tests__/PhabricatorRepositoryCommitTestCase.php',
|
'PhabricatorRepositoryCommitTestCase' => 'applications/repository/storage/__tests__/PhabricatorRepositoryCommitTestCase.php',
|
||||||
'PhabricatorRepositoryConfigOptions' => 'applications/repository/config/PhabricatorRepositoryConfigOptions.php',
|
'PhabricatorRepositoryConfigOptions' => 'applications/repository/config/PhabricatorRepositoryConfigOptions.php',
|
||||||
'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php',
|
'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php',
|
||||||
|
'PhabricatorRepositoryDestructibleCodex' => 'applications/repository/codex/PhabricatorRepositoryDestructibleCodex.php',
|
||||||
'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php',
|
'PhabricatorRepositoryDiscoveryEngine' => 'applications/repository/engine/PhabricatorRepositoryDiscoveryEngine.php',
|
||||||
'PhabricatorRepositoryEditor' => 'applications/repository/editor/PhabricatorRepositoryEditor.php',
|
'PhabricatorRepositoryEditor' => 'applications/repository/editor/PhabricatorRepositoryEditor.php',
|
||||||
'PhabricatorRepositoryEngine' => 'applications/repository/engine/PhabricatorRepositoryEngine.php',
|
'PhabricatorRepositoryEngine' => 'applications/repository/engine/PhabricatorRepositoryEngine.php',
|
||||||
|
@ -7937,6 +7940,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle',
|
'PhabricatorDefaultSyntaxStyle' => 'PhabricatorSyntaxStyle',
|
||||||
'PhabricatorDesktopNotificationsSetting' => 'PhabricatorInternalSetting',
|
'PhabricatorDesktopNotificationsSetting' => 'PhabricatorInternalSetting',
|
||||||
'PhabricatorDesktopNotificationsSettingsPanel' => 'PhabricatorSettingsPanel',
|
'PhabricatorDesktopNotificationsSettingsPanel' => 'PhabricatorSettingsPanel',
|
||||||
|
'PhabricatorDestructibleCodex' => 'Phobject',
|
||||||
'PhabricatorDestructionEngine' => 'Phobject',
|
'PhabricatorDestructionEngine' => 'Phobject',
|
||||||
'PhabricatorDestructionEngineExtension' => 'Phobject',
|
'PhabricatorDestructionEngineExtension' => 'Phobject',
|
||||||
'PhabricatorDestructionEngineExtensionModule' => 'PhabricatorConfigModule',
|
'PhabricatorDestructionEngineExtensionModule' => 'PhabricatorConfigModule',
|
||||||
|
@ -9241,6 +9245,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorFlaggableInterface',
|
'PhabricatorFlaggableInterface',
|
||||||
'PhabricatorMarkupInterface',
|
'PhabricatorMarkupInterface',
|
||||||
'PhabricatorDestructibleInterface',
|
'PhabricatorDestructibleInterface',
|
||||||
|
'PhabricatorDestructibleCodexInterface',
|
||||||
'PhabricatorProjectInterface',
|
'PhabricatorProjectInterface',
|
||||||
'PhabricatorSpacesInterface',
|
'PhabricatorSpacesInterface',
|
||||||
'PhabricatorConduitResultInterface',
|
'PhabricatorConduitResultInterface',
|
||||||
|
@ -9283,6 +9288,7 @@ phutil_register_library_map(array(
|
||||||
'PhabricatorRepositoryCommitTestCase' => 'PhabricatorTestCase',
|
'PhabricatorRepositoryCommitTestCase' => 'PhabricatorTestCase',
|
||||||
'PhabricatorRepositoryConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
'PhabricatorRepositoryConfigOptions' => 'PhabricatorApplicationConfigOptions',
|
||||||
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',
|
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',
|
||||||
|
'PhabricatorRepositoryDestructibleCodex' => 'PhabricatorDestructibleCodex',
|
||||||
'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine',
|
'PhabricatorRepositoryDiscoveryEngine' => 'PhabricatorRepositoryEngine',
|
||||||
'PhabricatorRepositoryEditor' => 'PhabricatorApplicationTransactionEditor',
|
'PhabricatorRepositoryEditor' => 'PhabricatorApplicationTransactionEditor',
|
||||||
'PhabricatorRepositoryEngine' => 'Phobject',
|
'PhabricatorRepositoryEngine' => 'Phobject',
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PhabricatorRepositoryDestructibleCodex
|
||||||
|
extends PhabricatorDestructibleCodex {
|
||||||
|
|
||||||
|
public function getDestructionNotes() {
|
||||||
|
$repository = $this->getObject();
|
||||||
|
|
||||||
|
$notes = array();
|
||||||
|
|
||||||
|
if ($repository->hasLocalWorkingCopy()) {
|
||||||
|
$notes[] = pht(
|
||||||
|
'Database records for repository "%s" were destroyed, but this '.
|
||||||
|
'script does not remove working copies on disk. If you also want to '.
|
||||||
|
'destroy the repository working copy, manually remove "%s".',
|
||||||
|
$repository->getDisplayName(),
|
||||||
|
$repository->getLocalPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $notes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
PhabricatorFlaggableInterface,
|
PhabricatorFlaggableInterface,
|
||||||
PhabricatorMarkupInterface,
|
PhabricatorMarkupInterface,
|
||||||
PhabricatorDestructibleInterface,
|
PhabricatorDestructibleInterface,
|
||||||
|
PhabricatorDestructibleCodexInterface,
|
||||||
PhabricatorProjectInterface,
|
PhabricatorProjectInterface,
|
||||||
PhabricatorSpacesInterface,
|
PhabricatorSpacesInterface,
|
||||||
PhabricatorConduitResultInterface,
|
PhabricatorConduitResultInterface,
|
||||||
|
@ -2557,6 +2558,14 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleCodexInterface )------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
public function newDestructibleCodex() {
|
||||||
|
return new PhabricatorRepositoryDestructibleCodex();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( PhabricatorSpacesInterface )----------------------------------------- */
|
/* -( PhabricatorSpacesInterface )----------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
abstract class PhabricatorDestructibleCodex
|
||||||
|
extends Phobject {
|
||||||
|
|
||||||
|
private $viewer;
|
||||||
|
private $object;
|
||||||
|
|
||||||
|
public function getDestructionNotes() {
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function setViewer(PhabricatorUser $viewer) {
|
||||||
|
$this->viewer = $viewer;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getViewer() {
|
||||||
|
return $this->viewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function setObject(
|
||||||
|
PhabricatorDestructibleCodexInterface $object) {
|
||||||
|
$this->object = $object;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function getObject() {
|
||||||
|
return $this->object;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public static function newFromObject(
|
||||||
|
PhabricatorDestructibleCodexInterface $object,
|
||||||
|
PhabricatorUser $viewer) {
|
||||||
|
|
||||||
|
if (!($object instanceof PhabricatorDestructibleInterface)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Object (of class "%s") implements interface "%s", but must also '.
|
||||||
|
'implement interface "%s".',
|
||||||
|
get_class($object),
|
||||||
|
'PhabricatorDestructibleCodexInterface',
|
||||||
|
'PhabricatorDestructibleInterface'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$codex = $object->newDestructibleCodex();
|
||||||
|
if (!($codex instanceof PhabricatorDestructibleCodex)) {
|
||||||
|
throw new Exception(
|
||||||
|
pht(
|
||||||
|
'Object (of class "%s") implements interface "%s", but defines '.
|
||||||
|
'method "%s" incorrectly: this method must return an object of '.
|
||||||
|
'class "%s".',
|
||||||
|
get_class($object),
|
||||||
|
'PhabricatorDestructibleCodexInterface',
|
||||||
|
'newDestructibleCodex()',
|
||||||
|
__CLASS__));
|
||||||
|
}
|
||||||
|
|
||||||
|
$codex
|
||||||
|
->setObject($object)
|
||||||
|
->setViewer($viewer);
|
||||||
|
|
||||||
|
return $codex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -3,6 +3,17 @@
|
||||||
final class PhabricatorDestructionEngine extends Phobject {
|
final class PhabricatorDestructionEngine extends Phobject {
|
||||||
|
|
||||||
private $rootLogID;
|
private $rootLogID;
|
||||||
|
private $collectNotes;
|
||||||
|
private $notes = array();
|
||||||
|
|
||||||
|
public function setCollectNotes($collect_notes) {
|
||||||
|
$this->collectNotes = $collect_notes;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getNotes() {
|
||||||
|
return $this->notes;
|
||||||
|
}
|
||||||
|
|
||||||
public function getViewer() {
|
public function getViewer() {
|
||||||
return PhabricatorUser::getOmnipotentUser();
|
return PhabricatorUser::getOmnipotentUser();
|
||||||
|
@ -36,6 +47,18 @@ final class PhabricatorDestructionEngine extends Phobject {
|
||||||
$this->rootLogID = $log->getID();
|
$this->rootLogID = $log->getID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->collectNotes) {
|
||||||
|
if ($object instanceof PhabricatorDestructibleCodexInterface) {
|
||||||
|
$codex = PhabricatorDestructibleCodex::newFromObject(
|
||||||
|
$object,
|
||||||
|
$this->getViewer());
|
||||||
|
|
||||||
|
foreach ($codex->getDestructionNotes() as $note) {
|
||||||
|
$this->notes[] = $note;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$object->destroyObjectPermanently($this);
|
$object->destroyObjectPermanently($this);
|
||||||
|
|
||||||
if ($object_phid) {
|
if ($object_phid) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
interface PhabricatorDestructibleCodexInterface {
|
||||||
|
|
||||||
|
public function newDestructibleCodex();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// TEMPLATE IMPLEMENTATION /////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/* -( PhabricatorDestructibleCodexInterface )------------------------------ */
|
||||||
|
/*
|
||||||
|
|
||||||
|
public function newDestructibleCodex() {
|
||||||
|
return new <<...>>DestructibleCodex();
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
|
@ -145,6 +145,7 @@ EOBANNER;
|
||||||
|
|
||||||
$console->writeOut("%s\n", pht('Destroying objects...'));
|
$console->writeOut("%s\n", pht('Destroying objects...'));
|
||||||
|
|
||||||
|
$notes = array();
|
||||||
foreach ($named_objects as $object_name => $object) {
|
foreach ($named_objects as $object_name => $object) {
|
||||||
$console->writeOut(
|
$console->writeOut(
|
||||||
pht(
|
pht(
|
||||||
|
@ -152,8 +153,14 @@ EOBANNER;
|
||||||
get_class($object),
|
get_class($object),
|
||||||
$object_name));
|
$object_name));
|
||||||
|
|
||||||
id(new PhabricatorDestructionEngine())
|
$engine = id(new PhabricatorDestructionEngine())
|
||||||
->destroyObject($object);
|
->setCollectNotes(true);
|
||||||
|
|
||||||
|
$engine->destroyObject($object);
|
||||||
|
|
||||||
|
foreach ($engine->getNotes() as $note) {
|
||||||
|
$notes[] = $note;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$console->writeOut(
|
$console->writeOut(
|
||||||
|
@ -162,6 +169,12 @@ EOBANNER;
|
||||||
'Permanently destroyed %s object(s).',
|
'Permanently destroyed %s object(s).',
|
||||||
phutil_count($named_objects)));
|
phutil_count($named_objects)));
|
||||||
|
|
||||||
|
if ($notes) {
|
||||||
|
id(new PhutilConsoleList())
|
||||||
|
->addItems($notes)
|
||||||
|
->draw();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue