Index: commands/core/core.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/core.drush.inc,v
retrieving revision 1.30
diff -u -p -r1.30 core.drush.inc
--- commands/core/core.drush.inc	2 Jun 2009 23:48:31 -0000	1.30
+++ commands/core/core.drush.inc	8 Aug 2009 02:39:01 -0000
@@ -106,6 +106,7 @@ function core_drush_command() {
 function core_drush_engine_drupal() {
   $engines = array();
   $engines['update'] = array();
+  $engines['environment'] = array();
   return $engines;
 }
 
Index: commands/core/drupal/environment.inc
===================================================================
RCS file: commands/core/drupal/environment.inc
diff -N commands/core/drupal/environment.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ commands/core/drupal/environment.inc	8 Aug 2009 02:39:01 -0000
@@ -0,0 +1,29 @@
+<?php
+// $Id:
+/**
+ * @file
+ *   Helper functions for /includes/environment.php.
+ *   drush_include_engine() magically includes either this file
+ *   or environment_7.php depending on which version of drupal drush
+ *   is called from.
+ */
+
+/**
+ * Get module information for all installed modules.
+ *
+ * @return
+ *   An array containing module info for all installed modules.
+ */
+function _drush_get_modules() {
+  return module_rebuild_cache();
+}
+
+/**
+ * Get theme information for all installed themes.
+ *
+ * @return
+ *   An array containing theme info for all installed themes.
+ */
+function _drush_get_themes() {
+  return _system_theme_data();
+}
\ No newline at end of file
Index: commands/core/drupal/environment_7.inc
===================================================================
RCS file: commands/core/drupal/environment_7.inc
diff -N commands/core/drupal/environment_7.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ commands/core/drupal/environment_7.inc	8 Aug 2009 02:39:01 -0000
@@ -0,0 +1,34 @@
+<?php
+// $Id:
+/**
+ * @file
+ *   Helper functions for /includes/environment.php.
+ *   drush_include_engine() magically includes either this file
+ *   or environment.php depending on which version of drupal drush
+ *   is called from.
+ */
+
+/**
+ * Get module information for all installed modules.
+ *
+ * @return
+ *   An array containing module info for all installed modules.
+ */
+function _drush_get_modules() {
+  $module_info = drupal_system_listing('/\.module$/', 'modules', 'name', 0);
+  system_get_files_database($module_info, 'module');
+  foreach($module_info as $module_name => $module){
+    $module_info[$module_name]->info = drupal_parse_info_file(dirname($module->filename) .'/'. $module->name .'.info');
+  }
+  return $module_info;
+}
+
+/**
+ * Get theme information for all installed themes.
+ *
+ * @return
+ *   An array containing theme info for all installed themes.
+ */
+function _drush_get_themes() {
+  return _system_get_theme_data();
+}
\ No newline at end of file
Index: commands/core/drupal/update_6.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/drupal/update_6.inc,v
retrieving revision 1.8
diff -u -p -r1.8 update_6.inc
--- commands/core/drupal/update_6.inc	27 May 2009 00:40:59 -0000	1.8
+++ commands/core/drupal/update_6.inc	8 Aug 2009 02:39:01 -0000
@@ -149,8 +149,8 @@ function update_check_incompatibility($n
 
   // Store values of expensive functions for future use.
   if (empty($themes) || empty($modules)) {
-    $themes = _system_theme_data();
-    $modules = module_rebuild_cache();
+    $themes = drush_get_themes();
+    $modules = drush_get_modules();
   }
 
   if ($type == 'module' && isset($modules[$name])) {
Index: commands/core/drupal/update_7.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/core/drupal/update_7.inc,v
retrieving revision 1.8
diff -u -p -r1.8 update_7.inc
--- commands/core/drupal/update_7.inc	27 May 2009 00:40:59 -0000	1.8
+++ commands/core/drupal/update_7.inc	8 Aug 2009 02:39:02 -0000
@@ -246,8 +246,8 @@ function update_check_incompatibility($n
 
   // Store values of expensive functions for future use.
   if (empty($themes) || empty($modules)) {
-    $themes = _system_theme_data();
-    $modules = module_rebuild_cache();
+    $themes = drush_get_themes();
+    $modules = drush_get_modules();
   }
 
   if ($type == 'module' && isset($modules[$name])) {
@@ -418,7 +418,7 @@ function update_main() {
   drupal_load('module', 'filter');
 
   // Set up $language, since the installer components require it.
-  drupal_init_language();
+  drupal_language_initialize();
 
   // Set up theme system for the maintenance page.
   drupal_maintenance_theme();
@@ -430,7 +430,7 @@ function update_main() {
   // been created yet.
   drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_DATABASE);
   include_once DRUPAL_ROOT . '/includes/install.inc';
-  drupal_install_init_database();
+  drupal_install_initialize_database();
   spl_autoload_unregister('drupal_autoload_class');
   spl_autoload_unregister('drupal_autoload_interface');
   // The new {blocked_ips} table is used in Drupal 7 to store a list of
@@ -451,13 +451,8 @@ function update_main() {
 
   // Updates only run reliably if user ID #1 is logged in. For example, node_delete() requires elevated perms in D5/6.
   if (!drush_get_context('DRUSH_USER')) {
-    // Remove after http://drupal.org/node/439236 lands.
-    require(DRUPAL_ROOT . '/modules/field/field.crud.inc');
-    require(DRUPAL_ROOT . '/modules/field/field.autoload.inc');
-
     drush_set_option('user', 1);
     drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_LOGIN);
-
   }
 
   drupal_maintenance_theme();
Index: commands/pm/pm.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/pm/pm.drush.inc,v
retrieving revision 1.42
diff -u -p -r1.42 pm.drush.inc
--- commands/pm/pm.drush.inc	29 Jul 2009 04:42:52 -0000	1.42
+++ commands/pm/pm.drush.inc	8 Aug 2009 02:39:02 -0000
@@ -213,7 +213,7 @@ function pm_module_manage($modules = arr
     require_once('./'. drupal_get_path('module', 'system') .'/system.module');
   }
 
-  $module_info = module_rebuild_cache();
+  $module_info = drush_get_modules();
   $enabled = array();
   foreach ($module_info as $module_name => $module) {
     // In Drupal 5, system_modules() returns NULL for the dependency list of the module if there are no dependencies. 
@@ -274,7 +274,7 @@ function pm_module_manage($modules = arr
       drupal_form_submit('system_modules', $form_state);
     }
 
-    $module_info = module_rebuild_cache();
+    $module_info = drush_get_modules();
     foreach ($modules as $module_name) {
       if ($enable) { 
         if ($module_info[$module_name]->status) {
Index: commands/pm/update_info/drupal_7.inc
===================================================================
RCS file: commands/pm/update_info/drupal_7.inc
diff -N commands/pm/update_info/drupal_7.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ commands/pm/update_info/drupal_7.inc	8 Aug 2009 02:39:02 -0000
@@ -0,0 +1,86 @@
+<?php
+// $Id: drupal_6.inc,v 1.5 2009/04/18 01:29:32 grugnog Exp $
+
+function pm_update_filter(&$release) {
+  $update = FALSE;
+  switch($release['status']) {
+    case UPDATE_CURRENT:
+      $status = dt('Up to date');
+      $release['candidate_version'] = $release['recommended'];
+      break;
+    case UPDATE_NOT_CURRENT:
+      $status = dt('Update available');
+      pm_release_recommended($release);
+      break;
+    case UPDATE_NOT_SECURE:
+      $status = dt('SECURITY UPDATE available');
+      pm_release_recommended($release);
+      break;
+    case UPDATE_REVOKED:
+      $status = dt('Installed version REVOKED');
+      pm_release_recommended($release);
+      break;
+    case UPDATE_NOT_SUPPORTED:
+      $status = dt('Installed version not supported');
+      pm_release_recommended($release);
+      break;
+    case UPDATE_NOT_CHECKED:
+      $status = dt('Unable to check status');
+      break;
+    case UPDATE_UNKNOWN:
+    default:
+      $status = dt('Unknown');
+      break;
+  }
+  return $status;
+}
+
+function pm_update_last_check() {
+  return variable_get('update_last_check', 0);
+}
+
+/**
+ * Command callback. Refresh update status information.
+ */
+function _pm_refresh() {
+  drush_print(dt("Refreshing update status information ..."));
+  update_refresh();
+  drush_print(dt("Done."));
+}
+
+/**
+ * Get update information for all installed projects.
+ *
+ * @return An array containing remote and local versions for all installed projects
+ */
+function _pm_get_update_info($projects = NULL) {
+  // We force a refresh if the cache is not available.
+  if (!cache_get('update_info', 'cache_update')) {
+    _pm_refresh();
+  }
+  $info = update_get_available();
+  $data = update_calculate_project_data($info);
+  $data = pm_get_project_path($data, 'includes');
+  return $data;
+}
+
+/**
+ * Get project information from drupal.org.
+ *
+ * @param $projects An array of project names
+ */
+function pm_get_project_info($projects) {
+  $info = array();
+  $data = array();
+  foreach ($projects as $project_name => $project) {
+    $url = UPDATE_DEFAULT_URL. "/$project_name/". drush_drupal_major_version() . '.x';
+    $xml = drupal_http_request($url);
+    $data[] = $xml->data;
+  }
+  if ($data) {
+    include_once drupal_get_path('module', 'update') .'/update.fetch.inc';
+    $parser = new update_xml_parser;
+    $info = $parser->parse($data);
+  }
+  return $info;
+}
\ No newline at end of file
Index: includes/command.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/command.inc,v
retrieving revision 1.36
diff -u -p -r1.36 command.inc
--- includes/command.inc	27 May 2009 19:38:12 -0000	1.36
+++ includes/command.inc	8 Aug 2009 02:39:03 -0000
@@ -404,7 +404,7 @@ function _drush_find_commandfiles($phase
     case DRUSH_BOOTSTRAP_DRUPAL_FULL:
       // Add enabled module paths. Since we are bootstrapped,
       // we can use the Drupal API.
-      $files = module_rebuild_cache();
+      $files = drush_get_modules();
       foreach ($files as $file) {
         if ($file->status) {
           $searchpath[] = dirname($file->filename);
Index: includes/drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/drush.inc,v
retrieving revision 1.41
diff -u -p -r1.41 drush.inc
--- includes/drush.inc	27 May 2009 00:47:38 -0000	1.41
+++ includes/drush.inc	8 Aug 2009 02:39:04 -0000
@@ -264,7 +264,7 @@ function drush_op($function) {
  *
  * @see t()
  */
-function dt($string, $args = NULL) {
+function dt($string, $args = array()) {
   if (function_exists('t')) {
     return t($string, $args);
   }
Index: includes/environment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/environment.inc,v
retrieving revision 1.38
diff -u -p -r1.38 environment.inc
--- includes/environment.inc	7 Jul 2009 23:34:53 -0000	1.38
+++ includes/environment.inc	8 Aug 2009 02:39:04 -0000
@@ -814,3 +814,33 @@ function drush_valid_db_credentials() {
     return TRUE;
   }
 }
+
+/**
+ * Get module information for all installed modules. Wrapper for _drush_get_modules().
+ *
+ * @return
+ *   An array containing module info for all installed modules or FALSE on error.
+ */
+function drush_get_modules() {
+  if(drush_include_engine('drupal', 'environment')){
+    return _drush_get_modules();
+  }
+  else {
+    return drush_set_error('DRUSH_CORE', dt('Drush was unable to load module information.'));
+  }
+}
+
+/**
+ * Get theme information for all installed themes. Wrapper for _drush_get_themes().
+ *
+ * @return
+ *   An array containing theme info for all installed themes or FALSE on error.
+ */
+function drush_get_themes() {
+  if(drush_include_engine('drupal', 'environment')){
+    return _drush_get_themes();
+  }
+  else {
+    return drush_set_error('DRUSH_CORE', dt('Drush was unable to load theme information.'));
+  }
+}
\ No newline at end of file
