diff --git a/Mage/Console.php b/Mage/Console.php
index cf61e0d..05dcfb1 100644
--- a/Mage/Console.php
+++ b/Mage/Console.php
@@ -48,6 +48,12 @@ class Mage_Console
} else if ($this->_args[0] == 'init') {
$this->_action = 'init';
+
+ } else if ($this->_args[0] == 'lock') {
+ $this->_action = 'lock';
+
+ } else if ($this->_args[0] == 'unlock') {
+ $this->_action = 'unlock';
}
foreach ($this->_args as $argument) {
@@ -158,67 +164,79 @@ class Mage_Console
Mage_Console::output('You must indicate a task', 0, 2);
break;
}
- switch ($this->_args[1]) {
- case 'list':
- $task->setAction($this->_args[1]);
- break;
- case 'rollback':
- if (!isset($this->_args[2])) {
- Mage_Console::output('You must indicate a release point', 0, 2);
- break 2;
- }
+ if ($this->_args[1] == 'list') {
+ $task->setAction('list');
- $task->setAction($this->_args[1]);
- $task->setRelease($this->_args[2]);
+ } else if ($this->_args[1] == 'rollback') {
+ if (!isset($this->_args[2])) {
+ Mage_Console::output('You must indicate a release point', 0, 2);
break;
+ }
+
+ $task->setAction($this->_args[1]);
+ $task->setRelease($this->_args[2]);
+
+ } else {
+ Mage_Console::output('Invalid Releases task', 0, 2);
+ break;
}
$task->run($config);
break;
case 'update';
- $task = new Mage_Task_Update;
- $task->run($config);
- break;
+ $task = new Mage_Task_Update;
+ $task->run($config);
+ break;
case 'compile';
- $task = new Mage_Task_Compile;
- $task->run($config);
- break;
+ $task = new Mage_Task_Compile;
+ $task->run($config);
+ break;
case 'install';
- $task = new Mage_Task_Install;
- $task->run();
- break;
+ $task = new Mage_Task_Install;
+ $task->run();
+ break;
+
+ case 'lock';
+ $task = new Mage_Task_Lock;
+ $task->run($config);
+ break;
+
+ case 'unlock';
+ $task = new Mage_Task_Lock;
+ $task->run($config, true);
+ break;
case 'upgrade';
- $task = new Mage_Task_Upgrade;
- $task->run();
- break;
+ $task = new Mage_Task_Upgrade;
+ $task->run();
+ break;
case 'init';
- $task = new Mage_Task_Init;
- $task->run();
- break;
+ $task = new Mage_Task_Init;
+ $task->run();
+ break;
case 'add';
- switch ($this->_args[1]) {
- case 'environment':
- if (isset($this->_args[3]) && ($this->_args[3] == '--with-releases')) {
- $withRelases = true;
- } else {
- $withRelases = false;
- }
+ switch ($this->_args[1]) {
+ case 'environment':
+ if (isset($this->_args[3]) && ($this->_args[3] == '--with-releases')) {
+ $withRelases = true;
+ } else {
+ $withRelases = false;
+ }
- $task = new Mage_Task_Add;
- $task->environment($this->_args[2], $withRelases);
- break;
- }
- break;
+ $task = new Mage_Task_Add;
+ $task->environment($this->_args[2], $withRelases);
+ break;
+ }
+ break;
case 'version';
- $this->showVersion();
- break;
+ $this->showVersion();
+ break;
default:
Mage_Console::output('Invalid action', 0, 2);
diff --git a/Mage/Task/Deploy.php b/Mage/Task/Deploy.php
index 1091696..805b46e 100644
--- a/Mage/Task/Deploy.php
+++ b/Mage/Task/Deploy.php
@@ -18,11 +18,17 @@ class Mage_Task_Deploy
$this->_startTime = time();
$this->_config = $config;
- if ($config->getEnvironment() == '') {
+ if ($config->getEnvironmentName() == '') {
Mage_Console::output('You must specify an environment', 0, 2);
return;
}
+ $lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
+ if (file_exists($lockFile)) {
+ Mage_Console::output('This environment is locked!', 0, 2);
+ return;
+ }
+
// Run Pre-Deployment Tasks
$this->_runNonDeploymentTasks('pre-deploy', $config, 'Pre-Deployment');
diff --git a/Mage/Task/Lock.php b/Mage/Task/Lock.php
new file mode 100644
index 0000000..798ea42
--- /dev/null
+++ b/Mage/Task/Lock.php
@@ -0,0 +1,23 @@
+_config = $config;
+
+ if ($config->getEnvironmentName() == '') {
+ Mage_Console::output('You must specify an environment', 0, 2);
+ return;
+ }
+
+ $lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
+ if (file_exists($lockFile)) {
+ @unlink($lockFile);
+ }
+
+ Mage_Console::output('Unlocked deployment to ' . $config->getEnvironmentName() . ' environment', 1, 2);
+ }
+
+}
\ No newline at end of file
diff --git a/Mage/Task/Releases.php b/Mage/Task/Releases.php
index 38e502f..c155da8 100644
--- a/Mage/Task/Releases.php
+++ b/Mage/Task/Releases.php
@@ -31,11 +31,17 @@ class Mage_Task_Releases
{
$this->_config = $config;
- if ($config->getEnvironment() == '') {
+ if ($config->getEnvironmentName() == '') {
Mage_Console::output('You must specify an environment', 0, 2);
return;
}
+ $lockFile = '.mage/' . $config->getEnvironmentName() . '.lock';
+ if (file_exists($lockFile)) {
+ Mage_Console::output('This environment is locked!', 0, 2);
+ return;
+ }
+
// Run Tasks for Deployment
$hosts = $config->getHosts();