? drush-977048.patch
? drush-977048_1.patch
? includes/table.inc
Index: commands/pm/pm.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/pm/pm.drush.inc,v
retrieving revision 1.149
diff -u -r1.149 pm.drush.inc
--- commands/pm/pm.drush.inc	3 Dec 2010 16:32:56 -0000	1.149
+++ commands/pm/pm.drush.inc	3 Dec 2010 17:10:07 -0000
@@ -313,6 +313,66 @@
 }
 
 /**
+ * Obtain an array of installed projects from the list of extensions available.
+ *
+ * If projects are checked out from CVS and 
+ * The array of projects include info on status and extensions in the project.
+ * A project is considered to be 'enabled' when any of its extensions is
+ * enabled.
+
+ *
+ * @param $extensions
+ *   A list of extensions as obtained from drush_get_extesions() or NULL to
+ * obtain it.
+ * @return
+ *   Array of installed projects with info on status and included extensions.
+ */
+function drush_get_projects($extensions = NULL) {
+  if (is_null($extensions)) {
+   $extensions = drush_get_extensions();
+  }
+
+  $projects = array();
+  foreach ($extensions as $extension) {
+    // Bypass extensions in drupal core.
+    if ($extension->info['version'] == VERSION) {
+      continue;
+    }
+    // Projects not packaged by drupal.org.
+    if (!isset($extension->info['project'])) {
+      // Checked out from CVS and cvs_deploy is not enabled ?
+      if (!module_exists('cvs_deploy')) {
+        if (is_dir(dirname($extension->filename) . '/CVS')) {
+          drush_log(dt('It seems you are using CVS version of some projects and you don\'t have cvs_deploy module enabled. It is a must to enable cvs_deploy in order to manage those projects succesfully.'), 'warning');
+          continue;
+        }
+      }
+      else {
+        // Custom project.
+        continue;
+      }
+    }
+    else {
+      $project = $extension->info['project'];
+    }
+
+    // Create/update the project in $projects with the project data.
+    if (!isset($projects[$project])) {
+      $projects[$project] = array(
+        'status' => $extension->status,
+        'extensions' => array(),
+      );
+    }
+    elseif ($extension->status != 0) {
+      $projects[$project]['status'] = $extension->status;
+    }
+    $projects[$project]['extensions'][] = $extension->name;
+  }
+
+  return $projects;
+}
+
+/**
  * @} End of "defgroup extensions".
  */
 
@@ -994,7 +1054,7 @@
 
   // Info on extensions present in the bootstrapped site will be used to
   // identify if any project release is installed.
-  $extension_info = drush_get_extensions();
+  $installed_projects = drush_get_projects();
 
   // Iterate the projects to collect relevant information.
   foreach ($info as $key => $project) {
@@ -1039,13 +1099,8 @@
       if ($release['version_extra'] == 'dev') {
         $status[] = dt('Development');
       }
-      // #TODO# Note here we suffer the project<->package-name problem:
-      // Following only works for modules/themes with name with
-      // drupal.org's project name (zen->zen but not for cck->content).
-      // See _drush_pm_releasenotes() for an option to get that info
-      // from update's project data.
-      if (isset($extension_info[$key])) {
-        if ($extension_info[$key]->info['version'] == $version) {
+      if (isset($installed_projects[$key])) {
+        if ($installed_projects[$key]->info['version'] == $version) {
           $status[] = dt('Installed');
           $info[$key]['installed'] = $version;
         }
@@ -1096,16 +1151,6 @@
 
   foreach ($info as $key => $project) {
     $selected_versions = array();
-    // #TODO# project<->package-name problem. See _drush_pm_get_releases().
-    if (!isset($project['installed'])) {
-      // Installed package's version (e.g. cck) is detected by
-      // _drush_pm_get_releases(). Attempted to obtain information
-      // about it from update_cache.
-      $cache_project_info = _update_cache_get('update_project_projects');
-      if (isset($cache_project_info->data[$key])) {
-        $project['installed'] = $cache_project_info->data[$key]['info']['version'];
-      }
-    }
     // If the request included version, only show its release notes.
     if (isset($requests[$key]['version'])) {
       $selected_versions[] = $requests[$key]['version'];
Index: commands/pm/updatecode.pm.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/commands/pm/updatecode.pm.inc,v
retrieving revision 1.25
diff -u -r1.25 updatecode.pm.inc
--- commands/pm/updatecode.pm.inc	3 Dec 2010 16:32:56 -0000	1.25
+++ commands/pm/updatecode.pm.inc	3 Dec 2010 17:10:07 -0000
@@ -31,10 +31,20 @@
 
   // Preprocess requested projects.
   if (!empty($requests)) {
-    // Check requests are installed and enabled projects and force
-    // update projects where a specific version is requested.
+    // 1. Check requests are installed projects with any extension enabled.
+    // 2. Explicitly set the version to update a project to if a specific
+    // version is requested.
+    $projects = drush_get_projects();
     foreach ($requests as $name => $request) {
-      if (!isset($update_info[$name])) {
+       if (!isset($projects[$name])) {
+        drush_set_error('DRUSH_PM_PROJECT_IS_NOT_INSTALLED', dt('Project !project is not installed so it can\'t be updated.', array('!project' => $name)));
+        unset($requests[$name]);
+      }
+      else if ($projects[$name]['status'] == 0) {
+        drush_set_error('DRUSH_PM_PROJECT_NOT_UPDATEABLE', dt('Project !project has no enabled extensions so it can\'t be updated.', array('!project' => $name)));
+        unset($requests[$name]);
+      }
+      else if (!isset($update_info[$name])) {
         // Catch projects with no version data (common for CVS checkouts
         // if you don't have CVS deploy installed).
         $update_info[$name] = array(
@@ -59,6 +69,10 @@
         $update_info[$name]['candidate_version'] = $release['version'];
       }
     }
+    // None of the requested projects is valid?
+    if (empty($requests)) {
+      return FALSE;
+    }
   }
 
   // Table headers.
@@ -67,6 +81,15 @@
   // Process releases, notifying user of status and building a list of proposed updates
   $updateable = pm_project_filter($update_info, $rows, $security_only);
 
+  // If specific project updates were requested then remove releases for all others
+  if (!empty($requests)) {
+    foreach ($updateable as $name => $project) {
+      if (!isset($requests[$name])) {
+        unset($updateable[$name]);
+      }
+    }
+  }
+
   // Pipe preparation.
   if (drush_get_context('DRUSH_PIPE')) {
     $pipe = "";
@@ -88,15 +111,6 @@
   drush_print_table($rows, TRUE);
   drush_print();
 
-  // If specific project updates were requested then remove releases for all others
-  if (!empty($requests)) {
-    foreach ($updateable as $name => $project) {
-      if (!isset($requests[$name])) {
-        unset($updateable[$name]);
-      }
-    }
-  }
-
   // If there are any locked projects that were not requested, then remove them
   if (!empty($locked_list)) {
     foreach ($updateable as $name => $project) {
