Index: cvs_deploy.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/cvs_deploy/cvs_deploy.module,v
retrieving revision 1.9.2.4
diff -u -p -r1.9.2.4 cvs_deploy.module
--- cvs_deploy.module	17 Jan 2008 19:52:41 -0000	1.9.2.4
+++ cvs_deploy.module	18 Jan 2008 02:43:37 -0000
@@ -42,6 +42,13 @@ function cvs_deploy_version_from_tag($ta
  */
 function cvs_deploy_system_info_alter(&$info, $project) {
   _cvs_deploy_version_alter($info['version'], $project);
+
+  // Now, if we don't know the 'project' attribute, fill it in based on the
+  // CVS/Repository file.
+  if (empty($info['project'])) {
+    $info['project'] = _cvs_deploy_get_project_name($project);
+  }
+
   _cvs_deploy_datestamp_alter($info['datestamp'], $project);
 }
 
@@ -96,6 +103,30 @@ function _cvs_deploy_version_alter(&$ver
 }
 
 /**
+ * Private helper to alter the 'project' of a module based on what directory
+ * in the CVS repository the module has been checked out from.
+ */
+function _cvs_deploy_get_project_name($project) {
+  static $projects = array();
+  $module_name = $project['name'];
+  if (empty($projects[$module_name])) {
+    // TODO: cache this in {cache}, too?
+    $cvs_dir = dirname($project['filename']) .'/CVS';
+    if (is_dir($cvs_dir)) {
+      $repository = '';
+      if (file_exists($cvs_dir .'/Repository')) {
+        $repo_file = trim(file_get_contents($cvs_dir .'/Repository'));
+        if ($repo_file) {
+          $parts = explode('/', $repo_file);
+          $projects[$module_name] = $parts[2];
+        }
+      }
+    }
+  }
+  return $projects[$module_name];
+}
+
+/**
  * Private helper method to alter the datestamp for a module.
  */
 function _cvs_deploy_datestamp_alter(&$datestamp, $project) {
@@ -158,11 +189,14 @@ function cvs_deploy_form_alter($form_id,
     $files = $form['validation_modules']['#value'];
     foreach ($files as $modulename => $file) {
       $project = array();
+      $project['filename'] = $file->filename;
+      $project['name'] = $file->name;
       if (function_exists('update_status_get_project')) {
         $project['project'] = update_status_get_project($file);
       }
-      $project['filename'] = $file->filename;
-      $project['name'] = $file->name;
+      if (empty($project['project'])) {
+        $project['project'] = _cvs_deploy_get_project_name($project);
+      }
       _cvs_deploy_version_alter($file->info['version'], $project);
       $form['version'][$modulename]['#value'] = $file->info['version'];
     }
