=== modified file 'includes/module.inc'
--- includes/module.inc	2009-07-28 19:06:15 +0000
+++ includes/module.inc	2009-08-04 03:35:01 +0000
@@ -1,4 +1,4 @@
-<?php
+th<?php
 // $Id: module.inc,v 1.149 2009/07/28 19:06:15 dries Exp $
 
 /**
@@ -102,7 +102,7 @@ function _module_build_dependencies($fil
   $p_core = '(?:' . preg_quote(DRUPAL_CORE_COMPATIBILITY) . '-)?';
   $p_major = '(?P<major>\d+)';
   // By setting the minor version to x, branches can be matched.
-  $p_minor = '(?P<minor>\d+|x)';
+  $p_minor = '(?P<minor>(?:\d+|x)(?:-[A-Za-z]+\d+)?)';
   foreach ($files as $filename => $file) {
     $graph[$file->name]['edges'] = array();
     if (isset($file->info['dependencies']) && is_array($file->info['dependencies'])) {
@@ -116,17 +116,25 @@ function _module_build_dependencies($fil
             if (preg_match("/^\s*$p_op\s*$p_core$p_major\.$p_minor/", $version, $matches)) {
               $op = !empty($matches['operation']) ? $matches['operation'] : '=';
               if ($matches['minor'] == 'x') {
-                // If a module is newer than 2.x then it's at least 3.0. 
-                $matches['minor'] = 0;
-                if ($op == '>') {
+                // When specifying versions in Drupal, "2.x" means every
+                // possible release where the release string starts with a 2.
+                // and continue with numbers (and then can folow other things
+                // but those do not matter here). version_compare, however,
+                // treats "2.x" as a version string which happens to be smaller
+                // than 2.0. So when specifying >=2.x for a dependency, for
+                // every Drupal release that is compatible, version_compare
+                // will also return TRUE. For example 2.5 is a 2.x release
+                // according to Drupal and 2.5 > 2.x according to
+                // version_compare because 5 > x. When specifying >2.x,
+                // however, we require Drupal releases which start with at
+                // least 3. but version_compare will still treat 2.5 as
+                // 2.5 > 2.x so we need to adjust the major version and feed
+                // "3.x", '>" to version_compare. This will work as 2.5 < 3.x
+                // "according to version_compare so the 2.5 version will be
+                // incompatible, however, every 3.x Drupal release will be
+                // compatible.
+                if ($op == '>' || $op == '<=') {
                   $matches['major']++;
-                  $op = '>=';
-                }
-                // If a module is older or equivalent than 2.x then it is older
-                // than 3.0.
-                if ($op == '<=') {
-                  $matches['major']++;
-                  $op = '<';
                 }
                 // Equivalence is checked by preg.
                 if ($op == '=' || $op == '==') {

=== modified file 'modules/simpletest/tests/system_test.module'
--- modules/simpletest/tests/system_test.module	2009-07-28 19:06:15 +0000
+++ modules/simpletest/tests/system_test.module	2009-08-03 18:18:42 +0000
@@ -180,7 +180,7 @@ function system_test_system_info_alter(&
     }
     if ($file->name == 'common_test') {
       $info['hidden'] = FALSE;
-      $info['version'] = '7.x-2.4';
+      $info['version'] = '7.x-2.4-beta3';
     }
   }
 }

=== modified file 'modules/system/system.test'
--- modules/system/system.test	2009-07-31 11:20:42 +0000
+++ modules/system/system.test	2009-08-03 18:27:28 +0000
@@ -208,7 +208,7 @@ class ModuleVersionTestCase extends Modu
       'group' => 'Module',
     );
   }
-  
+
   function setup() {
     parent::setUp('module_test');
   }
@@ -218,7 +218,7 @@ class ModuleVersionTestCase extends Modu
    */
   function testModuleVersions() {
     $dependencies = array(
-      // Alternating between being compatible and incompatible with 7.x-2.4.
+      // Alternating between being compatible and incompatible with 7.x-2.4-beta3.
       // The first is always a compatible.
       'common_test',
       // Branch incompatibility.
@@ -236,11 +236,17 @@ class ModuleVersionTestCase extends Modu
       // Nonsense, misses a dash. Incompatible with everything.
       'common_test (=7.x2.x, >=2.4)',
       // Core version is optional. Compatible.
-      'common_test (=7.x-2.x, >=2.4)',
+      'common_test (=7.x-2.x, >=2.4-alpha2)',
       // Test !=, explicitly incompatible.
-      'common_test (=2.x, !=2.4)',
+      'common_test (=2.x, !=2.4-beta3)',
       // Three operations. Compatible.
       'common_test (=2.x, !=2.3, <2.5)',
+      // Testing extra version. Incompatible.
+      'common_test (<=2.4-beta2)',
+      // Testing extra version. Compatible.
+      'common_test (>2.4-beta2)',
+      // Testing extra version. Incompatible.
+      'common_test (>2.4-rc0)',
     );
     variable_set('dependencies', $dependencies);
     $n = count($dependencies);

