? drush_pm
? drush_pm_cvs
? drush_pm_svn
? drush_pm_wget
? drush_simpletest
? drush_sql
? drush_tools
? drushrc.php
? drushrc.phpe
? example.drushrc.phpe
? services
? commands/alias
? commands/site
? commands/pm/handler
? includes/table.inc
Index: drush.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/drush.php,v
retrieving revision 1.75
diff -u -p -r1.75 drush.php
--- drush.php	27 Oct 2009 23:59:37 -0000	1.75
+++ drush.php	3 Nov 2009 16:44:52 -0000
@@ -64,12 +64,14 @@ function drush_verify_cli() {
  */
 function drush_main() {
   $phases = _drush_bootstrap_phases();
-
+  $completed_phases = array();
+  
   $return = '';
   $command_found = FALSE;
 
   foreach ($phases as $phase) {
     if (drush_bootstrap($phase)) {
+      $completed_phases[$phase] = TRUE;
       $command = drush_parse_command();
       
       // Process a remote command if 'remote-host' option is set.
@@ -79,7 +81,7 @@ function drush_main() {
       }
 
       if (is_array($command)) {
-        if ($command['bootstrap'] == $phase && empty($command['bootstrap_errors'])) {
+        if (array_key_exists($command['bootstrap'], $completed_phases) && empty($command['bootstrap_errors'])) {
           drush_log(dt("Found command: !command", array('!command' => $command['command'])), 'bootstrap');
           $command_found = TRUE;
           // Dispatch the command(s).
Index: commands/core/sitealias.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/sitealias.drush.inc,v
retrieving revision 1.2
diff -u -p -r1.2 sitealias.drush.inc
--- commands/core/sitealias.drush.inc	27 Oct 2009 23:59:38 -0000	1.2
+++ commands/core/sitealias.drush.inc	3 Nov 2009 16:44:52 -0000
@@ -24,12 +24,13 @@ function sitealias_drush_command() {
       'site' => 'Site specification alias to print',
     ),
     'options' => array(
-      '--full' => 'Print the full alias record for each site',
-      '--long' => 'Print the long-form site specification for each site',
-      '--short' => 'Print only the site alias name (default)',
-      '--db' => 'Include the databases structure in the full alias record',
-      '--db-url' => 'Include the short-form db-url in the full alias record',
-      '--no-db' => 'Do not include the database record in the full alias record (default)',
+      '--full' => 'Print the full alias record for each site.',
+      '--long' => 'Print the long-form site specification for each site.',
+      '--short' => 'Print only the site alias name (default).',
+      '--with-db' => 'Include the databases structure in the full alias record.',
+      '--with-db-url' => 'Include the short-form db-url in the full alias record.',
+      '--no-db' => 'Do not include the database record in the full alias record (default).',
+      '--with-optional' => 'Include optional default items.',
     ),
     'aliases' => array('sa'),
     'examples' => array(
@@ -180,13 +181,19 @@ function drush_sitealias_get_site_specif
 function _drush_sitealias_print_record($site_alias) {
   $output_db = drush_get_option('with-db');
   $output_db_url = drush_get_option('with-db-url');
-
+  $output_optional_items = drush_get_option('with-optional');
+  
   // Get the alias record for the specified site alias.
   // If the user wants database information included in
   // the record, then try to fetch that info from the
   // remote site.
   $alias_record = drush_sitealias_get_record($site_alias, isset($output_db) | isset($output_db_url));
   
+  // Include the optional items, if requested
+  if ($output_optional_items) {
+    _drush_sitealias_add_transient_defaults($alias_record);
+  }
+  
   // If the user specified --with-db-url, then leave the
   // 'db-url' entry in the alias record (unless it is not
   // set, in which case we will leave the 'databases' record instead).
Index: includes/backend.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/backend.inc,v
retrieving revision 1.19
diff -u -p -r1.19 backend.inc
--- includes/backend.inc	28 Oct 2009 11:57:56 -0000	1.19
+++ includes/backend.inc	3 Nov 2009 16:44:52 -0000
@@ -355,7 +355,7 @@ function _drush_backend_generate_command
   // @TODO: Implement proper multi platform / multi server support.
   $cmd = $php . sprintf(escapeshellcmd(" %s %s %s --backend"), escapeshellcmd($drush_path), $option_str, $command);
 
-  if (!is_null($hostname)) {
+  if (!is_null($hostname) && ($hostname != 'localhost')) {
     $username = (!is_null($username)) ? $username : get_current_user();
     $cmd = sprintf("ssh -o PasswordAuthentication=no %s@%s %s", escapeshellarg($username), escapeshellarg($hostname), escapeshellarg($cmd));
   }
Index: includes/environment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/environment.inc,v
retrieving revision 1.50
diff -u -p -r1.50 environment.inc
--- includes/environment.inc	30 Oct 2009 21:12:21 -0000	1.50
+++ includes/environment.inc	3 Nov 2009 16:44:52 -0000
@@ -527,7 +527,7 @@ function _drush_bootstrap_drupal_site_va
   $uri = 'http://'. $current;
 
   $drush_uri = drush_bootstrap_value('drush_uri', drush_get_option(array('l', 'uri'), $uri));
-
+  
   // Fake the necessary HTTP headers that Drupal needs:
   if ($drush_uri) {
     $drupal_base_url = parse_url($drush_uri);
@@ -555,26 +555,24 @@ function _drush_bootstrap_drupal_site_va
   $_SERVER['REQUEST_METHOD']  = NULL;
   $_SERVER['SERVER_SOFTWARE'] = NULL;
   $_SERVER['HTTP_USER_AGENT'] = NULL;
-  
+
   $site = drush_bootstrap_value('site', $_SERVER['HTTP_HOST']);
- 
-  $conf_path = drush_bootstrap_value('conf_path', conf_path());
+  
+  $conf_path = drush_bootstrap_value('conf_path', conf_path(TRUE, TRUE));
   $conf_file = "./$conf_path/settings.php";
   if (!file_exists($conf_file)) {
     return drush_bootstrap_error('DRUPAL_SITE_SETTINGS_NOT_FOUND', dt("Could not find a Drupal settings.php file at !file.",
        array('!file' => $conf_file)));
   }
-
+ 
   return TRUE;
 }
 
 /**
- * Initialize a site on the Drupal root.
- *
- * We now set various contexts that we determined and confirmed to be valid.
- * Additionaly we load an optional drushrc.php file in the site directory.
+ * Called by _drush_bootstrap_drupal_site to do the main work
+ * of the drush srupal site bootstrap.
  */
-function _drush_bootstrap_drupal_site() {
+function _drush_bootstrap_do_drupal_site() {
   $drush_uri = drush_set_context('DRUSH_URI', drush_bootstrap_value('drush_uri')); 
   $site = drush_set_context('DRUSH_DRUPAL_SITE', drush_bootstrap_value('site'));
   $conf_path = drush_set_context('DRUSH_DRUPAL_SITE_ROOT', drush_bootstrap_value('conf_path'));
@@ -585,6 +583,53 @@ function _drush_bootstrap_drupal_site() 
   drush_log(dt("Initialized Drupal site !site at !site_root", array('!site' => $site, '!site_root' => $conf_path)));
   drush_load_config('site');
 }
+ 
+/**
+ * Initialize a site on the Drupal root.
+ *
+ * We now set various contexts that we determined and confirmed to be valid.
+ * Additionaly we load an optional drushrc.php file in the site directory.
+ */
+function _drush_bootstrap_drupal_site() {
+  _drush_bootstrap_do_drupal_site();
+  _drush_bootstrap_redo_drupal_site();
+}
+
+/**
+ * Re-do the drupal site bootstrap (and possibly the
+ * drupal root bootstrap) if a site alias was processed
+ * after the site bootstrap phase completed.  This will
+ * happen when processing "drush sitealias command" for
+ * a site alias defined in a drushrc.php file in the
+ * default site's drush configuration directory.
+ */
+function _drush_bootstrap_redo_drupal_site() {
+  // If drush_load_config defined a site alias that did not
+  // exist before, then sitealias check arg might now match
+  // against one of those aliases.
+  if (drush_sitealias_check_arg() === TRUE) {
+    $remote_host = drush_get_option('remote-host');
+    if (!isset($remote_host)) {         
+      // Check to see if the drupal root changed.
+      // If it has, we will set remote-host to cause
+      // this command to be executed via the backend invoke
+      // process.
+      $sitealias_drupal_root = drush_get_option(array('r', 'root'));
+      if (($sitealias_drupal_root != null) && (DRUPAL_ROOT != $sitealias_drupal_root)) {
+	drush_set_option('remote-host', 'localhost');
+      }
+      else {
+        // If we set an alias, then we need to bootstrap the
+        // drupal site once again.  It is possible to re-bootstrap
+        // the site at this point because settings.php has not
+        // been included yet.
+        drush_log(dt("re-bootstrap drupal site"));
+        _drush_bootstrap_drupal_site_validate();
+        _drush_bootstrap_do_drupal_site();
+      }
+    }
+  }
+}
 
 /**
  * Initialize and load the Drupal configuration files.
Index: includes/sitealias.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/sitealias.inc,v
retrieving revision 1.3
diff -u -p -r1.3 sitealias.inc
--- includes/sitealias.inc	28 Oct 2009 11:57:56 -0000	1.3
+++ includes/sitealias.inc	3 Nov 2009 16:44:52 -0000
@@ -16,9 +16,7 @@ function drush_sitealias_check_arg() {
   if (_drush_sitealias_set_context_by_name($args[0])) {
     array_shift($args);
     // We only need to expand the site specification
-    // once, then we are done.  (Should we set a flag indicating
-    // that we already did this?  Otherwise 'drush alias1 alias2 command'
-    // would behave strangely.)
+    // once, then we are done.
     drush_set_arguments($args);
     return TRUE;
   }
@@ -189,7 +187,12 @@ function _drush_sitealias_add_static_def
 function _drush_sitealias_add_transient_defaults(&$alias_record) {
   if (isset($alias_record['path-aliases'])) {
     if (!array_key_exists('!drush', $alias_record['path-aliases'])) {
-      $alias_record['path-aliases']['!drush'] = dirname(DRUSH_COMMAND);
+      if (array_key_exists('!drush-script', $alias_record['path-aliases'])) {
+        $alias_record['path-aliases']['!drush'] = dirname($alias_record['path-aliases']['!drush-script']);
+      }
+      else {
+        $alias_record['path-aliases']['!drush'] = dirname(DRUSH_COMMAND);
+      }
     }
   }
 }
