mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 23:02:42 +01:00
Rename "HarbormasterBuild" methods to prepare for use of the "BuildMessages" table
Summary: Ref T13072. Rename various "command" properties to "message" properties, to prepare for merging "HarbormasterCommand" into "HarbormasterMessage". This change only renames variables and methods and should not affect program behavior. Test Plan: Grepped for affected symbols, found no unmodified hits. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13072 Differential Revision: https://secure.phabricator.com/D21683
This commit is contained in:
parent
af6cc0c934
commit
0f93d1ffe4
3 changed files with 36 additions and 30 deletions
|
@ -127,7 +127,7 @@ final class HarbormasterBuildEngine extends Phobject {
|
||||||
$build->save();
|
$build->save();
|
||||||
}
|
}
|
||||||
|
|
||||||
$build->deleteUnprocessedCommands();
|
$build->markUnprocessedMessagesAsProcessed();
|
||||||
|
|
||||||
if ($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_BUILDING) {
|
if ($build->getBuildStatus() == HarbormasterBuildStatus::STATUS_BUILDING) {
|
||||||
$this->updateBuildSteps($build);
|
$this->updateBuildSteps($build);
|
||||||
|
|
|
@ -104,13 +104,13 @@ final class HarbormasterBuildQuery
|
||||||
}
|
}
|
||||||
|
|
||||||
$build_phids = mpull($page, 'getPHID');
|
$build_phids = mpull($page, 'getPHID');
|
||||||
$commands = id(new HarbormasterBuildCommand())->loadAllWhere(
|
$messages = id(new HarbormasterBuildCommand())->loadAllWhere(
|
||||||
'targetPHID IN (%Ls) ORDER BY id ASC',
|
'targetPHID IN (%Ls) ORDER BY id ASC',
|
||||||
$build_phids);
|
$build_phids);
|
||||||
$commands = mgroup($commands, 'getTargetPHID');
|
$messages = mgroup($messages, 'getTargetPHID');
|
||||||
foreach ($page as $build) {
|
foreach ($page as $build) {
|
||||||
$unprocessed_commands = idx($commands, $build->getPHID(), array());
|
$unprocessed_messages = idx($messages, $build->getPHID(), array());
|
||||||
$build->attachUnprocessedCommands($unprocessed_commands);
|
$build->attachUnprocessedMessages($unprocessed_messages);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->needBuildTargets) {
|
if ($this->needBuildTargets) {
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
private $buildable = self::ATTACHABLE;
|
private $buildable = self::ATTACHABLE;
|
||||||
private $buildPlan = self::ATTACHABLE;
|
private $buildPlan = self::ATTACHABLE;
|
||||||
private $buildTargets = self::ATTACHABLE;
|
private $buildTargets = self::ATTACHABLE;
|
||||||
private $unprocessedCommands = self::ATTACHABLE;
|
private $unprocessedMessages = self::ATTACHABLE;
|
||||||
|
|
||||||
public static function initializeNewBuild(PhabricatorUser $actor) {
|
public static function initializeNewBuild(PhabricatorUser $actor) {
|
||||||
return id(new HarbormasterBuild())
|
return id(new HarbormasterBuild())
|
||||||
|
@ -28,7 +28,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
public function delete() {
|
public function delete() {
|
||||||
$this->openTransaction();
|
$this->openTransaction();
|
||||||
$this->deleteUnprocessedCommands();
|
$this->deleteUnprocessedMessages();
|
||||||
$result = parent::delete();
|
$result = parent::delete();
|
||||||
$this->saveTransaction();
|
$this->saveTransaction();
|
||||||
|
|
||||||
|
@ -222,15 +222,15 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* -( Build Commands )----------------------------------------------------- */
|
/* -( Build Messages )----------------------------------------------------- */
|
||||||
|
|
||||||
|
|
||||||
private function getUnprocessedCommands() {
|
private function getUnprocessedMessages() {
|
||||||
return $this->assertAttached($this->unprocessedCommands);
|
return $this->assertAttached($this->unprocessedMessages);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function attachUnprocessedCommands(array $commands) {
|
public function attachUnprocessedMessages(array $messages) {
|
||||||
$this->unprocessedCommands = $commands;
|
$this->unprocessedMessages = $messages;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,9 +330,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
public function isPausing() {
|
public function isPausing() {
|
||||||
$is_pausing = false;
|
$is_pausing = false;
|
||||||
foreach ($this->getUnprocessedCommands() as $command_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$command = $command_object->getCommand();
|
$message_type = $message_object->getCommand();
|
||||||
switch ($command) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
case HarbormasterBuildCommand::COMMAND_PAUSE:
|
||||||
$is_pausing = true;
|
$is_pausing = true;
|
||||||
break;
|
break;
|
||||||
|
@ -351,9 +351,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
public function isResuming() {
|
public function isResuming() {
|
||||||
$is_resuming = false;
|
$is_resuming = false;
|
||||||
foreach ($this->getUnprocessedCommands() as $command_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$command = $command_object->getCommand();
|
$message_type = $message_object->getCommand();
|
||||||
switch ($command) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
case HarbormasterBuildCommand::COMMAND_RESUME:
|
case HarbormasterBuildCommand::COMMAND_RESUME:
|
||||||
$is_resuming = true;
|
$is_resuming = true;
|
||||||
|
@ -372,9 +372,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
public function isRestarting() {
|
public function isRestarting() {
|
||||||
$is_restarting = false;
|
$is_restarting = false;
|
||||||
foreach ($this->getUnprocessedCommands() as $command_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$command = $command_object->getCommand();
|
$message_type = $message_object->getCommand();
|
||||||
switch ($command) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_RESTART:
|
case HarbormasterBuildCommand::COMMAND_RESTART:
|
||||||
$is_restarting = true;
|
$is_restarting = true;
|
||||||
break;
|
break;
|
||||||
|
@ -386,9 +386,9 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
public function isAborting() {
|
public function isAborting() {
|
||||||
$is_aborting = false;
|
$is_aborting = false;
|
||||||
foreach ($this->getUnprocessedCommands() as $command_object) {
|
foreach ($this->getUnprocessedMessages() as $message_object) {
|
||||||
$command = $command_object->getCommand();
|
$message_type = $message_object->getCommand();
|
||||||
switch ($command) {
|
switch ($message_type) {
|
||||||
case HarbormasterBuildCommand::COMMAND_ABORT:
|
case HarbormasterBuildCommand::COMMAND_ABORT:
|
||||||
$is_aborting = true;
|
$is_aborting = true;
|
||||||
break;
|
break;
|
||||||
|
@ -398,10 +398,16 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
return $is_aborting;
|
return $is_aborting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function deleteUnprocessedCommands() {
|
public function markUnprocessedMessagesAsProcessed() {
|
||||||
foreach ($this->getUnprocessedCommands() as $key => $command_object) {
|
// TODO: See T13072. This is a placeholder until BuildCommand and
|
||||||
$command_object->delete();
|
// BuildMessage merge.
|
||||||
unset($this->unprocessedCommands[$key]);
|
return $this->deleteUnprocessedMessages();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteUnprocessedMessages() {
|
||||||
|
foreach ($this->getUnprocessedMessages() as $key => $message_object) {
|
||||||
|
$message_object->delete();
|
||||||
|
unset($this->unprocessedMessages[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -452,7 +458,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sendMessage(PhabricatorUser $viewer, $command) {
|
public function sendMessage(PhabricatorUser $viewer, $message_type) {
|
||||||
// TODO: This should not be an editor transaction, but there are plans to
|
// TODO: This should not be an editor transaction, but there are plans to
|
||||||
// merge BuildCommand into BuildMessage which should moot this. As this
|
// merge BuildCommand into BuildMessage which should moot this. As this
|
||||||
// exists today, it can race against BuildEngine.
|
// exists today, it can race against BuildEngine.
|
||||||
|
@ -476,7 +482,7 @@ final class HarbormasterBuild extends HarbormasterDAO
|
||||||
|
|
||||||
$xaction = id(new HarbormasterBuildTransaction())
|
$xaction = id(new HarbormasterBuildTransaction())
|
||||||
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
->setTransactionType(HarbormasterBuildTransaction::TYPE_COMMAND)
|
||||||
->setNewValue($command);
|
->setNewValue($message_type);
|
||||||
|
|
||||||
$editor->applyTransactions($this, array($xaction));
|
$editor->applyTransactions($this, array($xaction));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue