? drush_make.drush.inc.take1
Index: drush_make.drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.drush.inc,v
retrieving revision 1.11.2.83
diff -u -p -r1.11.2.83 drush_make.drush.inc
--- drush_make.drush.inc	23 Nov 2010 08:08:00 -0000	1.11.2.83
+++ drush_make.drush.inc	6 Jan 2011 08:54:53 -0000
@@ -135,6 +135,7 @@ function drush_drush_make_make($makefile
 }
 
 function drush_make_projects($recursion, $contrib_destination, $info, $build_path) {
+  static $done_projects = array();
   $projects = array();
   if (empty($info['projects'])) {
     return;
@@ -156,7 +157,18 @@ function drush_make_projects($recursion,
       'subdir'              => '',
       'directory_name'      => '',
     );
+
+    $project = drush_make_check_version($project);
+    if (!$project) {
+      // Version error, quit.
+      return FALSE;
+    }
+    elseif ($project['dont_fetch']) {
+      // Already fetched, skip it.
+      continue;
+    }
     $project = drush_make_updatexml($project);
+
     if (!empty($md5)) {
       $project['download']['md5'] = $md5;
     }
@@ -206,6 +218,47 @@ function drush_make_projects($recursion,
   }
 }
 
+function drush_make_check_version($project) {
+  static $done_projects = array();
+  static $version_types = array(
+    'branch',
+    'tag',
+    'revision',
+    'date',
+    'version',
+  );
+  // Default if no versions specified.
+  $requested_version = array('version', DRUSH_MAKE_VERSION_BEST);
+  foreach ($version_types as $type) {
+    if (isset($project[$type])) {
+      $requested_version = array($type, $project[$type]);
+      break;
+    }
+  }
+
+  $project['dont_fetch'] = $project['overwrite'] = FALSE;
+
+  if (isset($done_projects[$project['name']])) {
+    if ($done_projects[$project['name']] == $requested_version || ($requested_version == array('version', DRUSH_MAKE_VERSION_BEST))) {
+      drush_log(dt('Not downloading project %name again', array('%name' => $project['name'])), 'ok');
+      $project['dont_fetch'] = TRUE;
+    }
+    elseif ($done_projects[$project['name']] == array('version', DRUSH_MAKE_VERSION_BEST)) {
+      // Bummer, we need to 'downgrade'.
+      drush_log(dt('Fetching %project again, %type %ver requested', array('%project' => $project['name'], '%type' => $requested_version[0], '%ver' => $requested_version[1])), 'warning');
+      $project['overwrite'] = TRUE;
+    }
+    else {
+      drush_set_error(dt('Version mismatch for project %project: %type1 %ver1 <-> %type2 %ver2', array('%project' => $project['name'], '%type1' => $done_projects[$project['name']][0], '%type2' => $requested_version[0], '%ver1' => $done_projects[$project['name']][1], '%ver2' => $requested_version[1])));
+      return FALSE;
+    }
+  }
+  else {
+    $done_projects[$project['name']] = $requested_version;
+  }
+  return $project;
+}
+
 function drush_make_libraries($contrib_destination, $info, $build_path) {
   if (empty($info['libraries'])) {
     return;
Index: drush_make.project.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush_make/Attic/drush_make.project.inc,v
retrieving revision 1.1.2.53
diff -u -p -r1.1.2.53 drush_make.project.inc
--- drush_make.project.inc	12 Nov 2010 05:31:59 -0000	1.1.2.53
+++ drush_make.project.inc	6 Jan 2011 08:54:53 -0000
@@ -48,8 +48,13 @@ class DrushMakeProject {
     $this->download_location = $this->path . '/' . $this->project_directory;
     // This directory shouldn't exist yet -- if it does, stop.
     if (is_dir($this->download_location)) {
-      drush_set_error(dt('Directory not empty: %directory', array('%directory' => $this->download_location)));
-      return FALSE;
+      if (!$this->overwrite) {
+        drush_set_error(dt('Directory not empty: %directory', array('%directory' => $this->download_location)));
+        return FALSE;
+      }
+      else {
+        drush_shell_exec('rm -rf %s', $this->download_location);
+      }
     }
     else {
       drush_make_mkdir($this->download_location);
