? .drush.php.swp
? .svn
? drushrc.php
? z
? includes/.drush.inc.swp
Index: drush.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/drush.php,v
retrieving revision 1.50
diff -u -r1.50 drush.php
--- drush.php	24 Mar 2009 15:22:43 -0000	1.50
+++ drush.php	26 Mar 2009 01:18:12 -0000
@@ -93,11 +93,11 @@
     switch ($phase) {
       case DRUSH_BOOTSTRAP_DRUPAL_DATABASE :
         ob_end_clean();
-        drush_set_error(DRUSH_DRUPAL_DB_ERROR);
+        drush_set_error('DRUSH_DRUPAL_DB_ERROR');
         break;
       case DRUSH_BOOTSTRAP_DRUPAL_FULL :
         ob_end_clean();
-        drush_set_error(DRUSH_DRUPAL_BOOTSTRAP_ERROR);
+        drush_set_error('DRUSH_DRUPAL_BOOTSTRAP_ERROR');
         break;
     }
   }
@@ -108,9 +108,7 @@
     drush_backend_output();
   }
 
-  $error = drush_get_error();
-  $error = ($error) ? $error : DRUSH_SUCCESS;
-  exit($error);
+  exit((drush_get_error()) ? DRUSH_FRAMEWORK_ERROR : DRUSH_SUCCESS);
 }
 
 /**
@@ -133,7 +131,7 @@
     else {
       $message = dt('Could not login with user account `%user\'.', array('%user' => $drush_user));
     }
-    return drush_set_error(DRUPAL_USER_LOGIN_FAILED, $message);
+    return drush_set_error('DRUPAL_USER_LOGIN_FAILED', $message);
   }
 
   return TRUE;
Index: includes/backend.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/backend.inc,v
retrieving revision 1.3
diff -u -r1.3 backend.inc
--- includes/backend.inc	24 Mar 2009 15:22:43 -0000	1.3
+++ includes/backend.inc	26 Mar 2009 01:18:13 -0000
@@ -125,20 +125,9 @@
 function _drush_backend_integrate($data) {
   // Output will either be printed, or buffered to the drush_backend_output command.
   print ($data['output']);
-
-  if (is_array($data['error_log'])) {
-    foreach (array_keys($data['error_log']) as $error_type) {
-      foreach ($data['error_log'][$error_type] as $error) {
-        drush_set_error($error_type, $error);
-      }
-    }
-  }
-
   if (is_array($data['log'])) {
     foreach($data['log'] as $log) {
-      if (!in_array($log['type'], array('failed', 'error'))) {
-        drush_log($log['message'], $log['type']); 
-      }
+      drush_log($log['message'], $log['type'], $log['error']); 
     }
   }
 }
@@ -252,7 +241,7 @@
       return $values;
     }
     else {
-      return drush_set_error(DRUSH_FRAMEWORK_ERROR, dt("The command could not be executed succesfully (returned: !return, code: %code)", array("!return" => $proc['output'], "%code" =>  $proc['code'])));
+      return drush_set_error('DRUSH_FRAMEWORK_ERROR', dt("The command could not be executed succesfully (returned: !return, code: %code)", array("!return" => $proc['output'], "%code" =>  $proc['code'])));
     }
   }
   return FALSE;
Index: includes/context.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/context.inc,v
retrieving revision 1.2
diff -u -r1.2 context.inc
--- includes/context.inc	24 Mar 2009 15:22:43 -0000	1.2
+++ includes/context.inc	26 Mar 2009 01:18:14 -0000
@@ -363,7 +363,7 @@
 
     $fp = fopen($filename, "w+");
     if (!$fp) {
-      return drush_set_error(DRUSH_PERM_ERROR, dt('Drushrc (!filename) could not be written', array('!filename' => $filename)));
+      return drush_set_error('DRUSH_PERM_ERROR', dt('Drushrc (!filename) could not be written', array('!filename' => $filename)));
     }
     else {
       fwrite($fp, "<?php\n");
Index: includes/drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/drush.inc,v
retrieving revision 1.16
diff -u -r1.16 drush.inc
--- includes/drush.inc	24 Mar 2009 15:22:43 -0000	1.16
+++ includes/drush.inc	26 Mar 2009 01:18:14 -0000
@@ -195,7 +195,7 @@
     return drush_show_help($commands);
   }
 
-  drush_set_error(DRUSH_COMMAND_NOT_FOUND, dt('Invalid command !command.', array('!command' => implode(" ", $commands))));
+  drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt('Invalid command !command.', array('!command' => implode(" ", $commands))));
 }
 
 /**
@@ -272,7 +272,7 @@
       break;
     }
   }
-  return drush_set_error(DRUSH_COMMAND_NOT_FOUND, dt('Invalid command !command.', array('!command' => $commandstring)));
+  return drush_set_error('DRUSH_COMMAND_NOT_FOUND', dt('Invalid command !command.', array('!command' => $commandstring)));
 }
 
 /**
@@ -460,25 +460,6 @@
  */
 
 /**
- * Maintain a static array containing all the log messages
- *
- * @param entry
- *   Associative array containing the log message.
- * @return
- *   Entire log history, only if $entry is NULL. If entry is not null, it will return the return of _drush_print_log.
- */
-function _drush_set_log($entry = NULL) {
-  static $log = array();
-  if ($entry == NULL) {
-    return $log;
-  }
-  else {
-    $log[] = $entry;
-    return _drush_print_log($entry);
-  }
-}
-
-/**
  * Add a log message to the log history.
  *
  * @param message
@@ -489,12 +470,16 @@
  *   A type of 'ok' or 'completed' can also be supplied to flag as a 'success'
  *   All other types of messages will be assumed to be notices.
  */
-function drush_log($message, $type = 'notice' ) {
-  return _drush_set_log(array(
+function drush_log($message, $type = 'notice', $error = null) {
+  $log =& drush_get_context('DRUSH_LOG', array());
+  $item = array(
      'type' => $type, 
      'message' => $message, 
      'timestamp' => time()
-    ));
+   );
+  $item['error'] = $error;
+  $log[] = $item;
+  return _drush_print_log($entry);
 }
 
 /**
@@ -504,7 +489,7 @@
  *   Entire log history
  */
 function drush_get_log() {
-  return _drush_set_log();
+  return drush_get_context('DRUSH_LOG', array());
 }
 
 /**
@@ -592,7 +577,7 @@
 /**
 * @name Error status definitions
 * @{
-* Bitmask values used to generate the error code to return.
+* Error code definitions for interpreting the current error status.
 * @see drush_set_error(), drush_get_error(), drush_get_error_log(), drush_cmp_error()
 */
 
@@ -600,16 +585,8 @@
 define('DRUSH_NOT_COMPLETED', 0);
 /** The command completed succesfully. */
 define('DRUSH_SUCCESS', 1);
-/** The command was not found. **/
-define('DRUSH_COMMAND_NOT_FOUND', 2);
-/** Drupal was unable to bootstrap. */
-define('DRUSH_DRUPAL_BOOTSTRAP_ERROR', 4);
-/** The Drupal database API exited due to unsuccesful connection. */ 
-define('DRUSH_DRUPAL_DB_ERROR', 8);
-/** Web server could not be restarted, or other server related issues - less severe. */
-define('DRUSH_PERM_ERROR', 16);
 /** The command could not be completed because the framework has specified errors that have occured. */
-define('DRUSH_FRAMEWORK_ERROR', 32);
+define('DRUSH_FRAMEWORK_ERROR', 2);
 
 /**
  * @} End of "name Error status defintions".
@@ -620,8 +597,9 @@
  * @{
  * Functions that manage the current error status of the Drush framework.
  *
- * These functions operate by maintaining a static variable that is a bitmask of all the errors that have occurred.
- * This bitmask value is returned at the end of program execution, and provide the shell or calling application with
+ * These functions operate by maintaining a static variable that is a equal to the constant DRUSH_FRAMEWORK_ERROR if an
+ * error has occurred.
+ * This error code is returned at the end of program execution, and provide the shell or calling application with
  * more information on how to diagnose any problems that may have occurred.
  */
 
@@ -629,100 +607,36 @@
  * Set an error code for the error handling system.
  *
  * @param error
- *   Any of the defined error status definitions or a text string identifying the type of error.
+ *   A text string identifying the type of error.
  *
  * @param message
  *   Optional. Error message to be logged. If no message is specified, hook_drush_help will be consulted, 
  *   using a key of 'error:MY_ERROR_STRING'.
  *
  * @return
- *   If the error parameter is specified, always returns FALSE, to allow you to return with false in the calling functions,
+ *   Always returns FALSE, to allow you to return with false in the calling functions,
  *   such as <code>return drush_set_error(DRUSH_FRAMEWORK_ERROR)</code>
  */
-function drush_set_error($error = null, $message = null) {
-  static $error_code = DRUSH_NOT_COMPLETED;
+function drush_set_error($error, $message = null) {
+  $error_code =& drush_get_context('DRUSH_ERROR_CODE', DRUSH_NOT_COMPLETED);
+  $error_code = DRUSH_FRAMEWORK_ERROR;
 
-  if ($error) {
-    $error_code = $error_code | _drush_map_error_code($error);    
-    _drush_error_log($error, $message);
-    return FALSE;
-  }
+  $error_log =& drush_get_context('DRUSH_ERROR_LOG', array());
 
-  return $error_code;
-}
-
-/**
- * Map the constant or error index key to a error code.
- *
- * If the error is not one of the pre-defined error status codes, it will
- * assume the error is a DRUSH_FRAMEWORK_ERROR, which is a catch-all
- * for any application specific errors.
- */
-function _drush_map_error_code($error) {
-  if (is_numeric($error) && in_array($error, array(2, 4, 8, 16, 32))) {
-    $code = $error; 
-  }
-  else {
-    $code = 32;
+  if (is_numeric($error)) {
+    $error = 'DRUSH_FRAMEWORK_ERROR';
   }
-  return $code;
-}
 
-/**
- * Map the error code to a textual representation.
- *
- * This simplifies the error log control array, by not having numeric indexes.
- * This in turn simplifies the process of checking for errors that have occured.
- */
+  $message = ($message) ? $message : drush_command_invoke_all('drush_help', 'error:' . $error);
 
-function _drush_map_error_string($error) {
-  static $code_map = array(
-    DRUSH_COMMAND_NOT_FOUND => 'DRUSH_COMMAND_NOT_FOUND',
-    DRUSH_DRUPAL_BOOTSTRAP_ERROR => 'DRUSH_DRUPAL_BOOTSTRAP_ERROR',
-    DRUSH_DRUPAL_DB_ERROR => 'DRUSH_DRUPAL_DB_ERROR',
-    DRUSH_PERM_ERROR => 'DRUSH_PERM_ERROR',
-    DRUSH_FRAMEWORK_ERROR => 'DRUSH_FRAMEWORK_ERROR',
-  );
-  if (is_numeric($error)) {
-    // map a numeric exit code to a string representation
-    return $code_map[$error];
-  }
-  else {
-    // already a string representation, just return.
-    return $error;
+  if (is_array($message)) {
+    $message = implode("\n", $message);
   }
-}
 
-/**
- * Log the errors that occurred.
- *
- * These messages are logged separately so that other commands and applications
- * can inspect the exact causes of the errors.
- *
- * @param $error
- *   Optional. If this is null, it returns the current error log. 
- *   If it is not null, this is the error that has occurred. 
- *
- * @param $message
- *   Optional. The error message to log.
- *   If no message parameter is specified, it will attempt to find a message through
- *   hook_drush_help.
- *
- * @return
- *   An array of all errors that have occurred.
- */
-function _drush_error_log($error = null, $message = null) {
-  static $error_log = array();
-  if ($error) {
-    $error = _drush_map_error_string($error);
-    $message = ($message) ? $message : drush_command_invoke_all('drush_help', 'error:' . $error);
-    if (is_array($message)) {
-      $message = implode("\n", $message);
-    }
-    $error_log[$error][] = $message;
-    drush_log(($message) ? $message : $error, 'error');
-  }
-  return $error_log;
+  $error_log[$error][] = $message;
+  drush_log(($message) ? $message : $error, 'error', $error);
+
+  return FALSE;
 }
 
 /**
@@ -732,7 +646,7 @@
  *   The current aggregate error status
  */
 function drush_get_error() {
-  return drush_set_error();
+  return drush_get_context('DRUSH_ERROR_CODE', DRUSH_NOT_COMPLETED);
 }
 
 /**
@@ -742,20 +656,25 @@
  *   An associative array of error messages indexed by the type of message.
  */
 function drush_get_error_log() {
-  return _drush_error_log();
+  return drush_get_context('DRUSH_ERROR_LOG', array());
 }
 
 /**
  * Check if a specific error status has been set.
  *
  * @param error
- *   Any of the defined error status constants, or a text string identifying the error that has occurred.
+ *   A text string identifying the error that has occurred.
  * @return
  *   TRUE if the specified error has been set, FALSE if not 
  */
 function drush_cmp_error($error) {
   $error_log = drush_get_error_log();
-  return array_key_exists(_drush_map_error_string($error), $error_log);
+  
+  if (is_numeric($error)) {
+    $error = 'DRUSH_FRAMEWORK_ERROR';
+  }
+
+  return array_key_exists($error, $error_log);
 }
 
 /**
Index: includes/environment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/environment.inc,v
retrieving revision 1.7
diff -u -r1.7 environment.inc
--- includes/environment.inc	26 Mar 2009 00:14:43 -0000	1.7
+++ includes/environment.inc	26 Mar 2009 01:18:15 -0000
@@ -299,7 +299,7 @@
 
   $site = drush_set_context('DRUSH_DRUPAL_SITE', $_SERVER['HTTP_HOST']);
   if (($conf_path = conf_path()) && !file_exists("./$conf_path/settings.php")) {
-    drush_set_error(DRUPAL_SITE_SETTINGS_NOT_FOUND);
+    drush_set_error('DRUPAL_SITE_SETTINGS_NOT_FOUND');
   }
   else {
     drush_set_context('DRUSH_DRUPAL_SITE_ROOT', $conf_path);
? drush_pm/.svn
? drush_sql/.svn
? drush_tools/.svn
