Index: /CMT/HEAD/ChangeLog
===================================================================
--- /CMT/HEAD/ChangeLog	(revision 272)
+++ /CMT/HEAD/ChangeLog	(revision 273)
@@ -1,2 +1,7 @@
+
+2006-11-17 Vincent Garonne <garonne@lal.in2p3.fr> 314
+
+    * source/cmt_project.*: Add two functions - get_project_releases, select_release    
+    * source/cmt_project.*: Add support for wildcarded project dependencies
 
 2006-10-17 Vincent Garonne <garonne@lal.in2p3.fr> 313
Index: /CMT/HEAD/source/cmt_project.cxx
===================================================================
--- /CMT/HEAD/source/cmt_project.cxx	(revision 272)
+++ /CMT/HEAD/source/cmt_project.cxx	(revision 273)
@@ -706,6 +706,6 @@
     {
       Project& p = Projects[i];
-
       if (p.m_name == name) return (&p);
+      
     }
 
@@ -1431,6 +1431,22 @@
   //   +             the new project is then parsed ... etc...
 
+  // First test it wilcard is used
+  int v = -1;
+  int r = -1;
+  int p = -1;
+  cmt_string new_release = release;
+  CmtSystem::is_version_directory (new_release, v, r, p);  
+  bool use_has_wild_card = (v == -1) || (r == -1) || (p == -1);
+  if (use_has_wild_card)
+  {
+      cmt_string selected_release = "";
+      if (select_release(name, new_release,selected_release))
+      { // yes 
+          // cout <<"selected_release: "<<selected_release<<endl;    
+          new_release = selected_release;
+      }         
+   }
+
   cmt_string cmtprojectpath = Symbol::get_env_value ("CMTPROJECTPATH");
-
   cmt_string sep;
   sep = CmtSystem::path_separator ();
@@ -1448,11 +1464,11 @@
       p += CmtSystem::file_separator ();
       p += name;
-      if (release != "")
+      if (new_release != "")
 	{
 	  p += CmtSystem::file_separator ();
-	  p += release;
-	}
-
-      if (CmtSystem::test_directory (p))
+	  p += new_release;
+	}
+
+    if (CmtSystem::test_directory (p))
 	{
 	  //cerr << "Project directory " << p << " exists " << endl;
@@ -1473,14 +1489,13 @@
 
       if (p != 0)
-	{
-	  found = true;
-
-	  p->add_parent (this);
-	  add_child (p);
-
-	  update_strategies_from_children ();
-	}
-    }
-
+	  {
+	      found = true;
+	      p->add_parent (this);
+	      add_child (p);
+
+	      update_strategies_from_children ();
+	    }
+    }
+    
   if (!found && (cmtprojectpath != ""))
     {
@@ -1489,4 +1504,134 @@
 }
 
+//---------------------------------------------------------
+bool Project::select_release(const cmt_string& name, const cmt_string& release, cmt_string& result)
+{
+    cmt_string selected_release = "";
+
+    int v = -1;
+    int r = -1;
+    int p = -1;
+    CmtSystem::is_version_directory (release, v, r, p); 
+
+    int selected_v = -1;
+    int selected_r = -1;
+    int selected_p = -1;
+    CmtSystem::cmt_string_vector releases = get_project_releases(name);
+    for (int j = 0; j < releases.size (); j++)
+    {
+         //cout <<releases[j]<<endl;  
+         int new_v = -1;
+         int new_r = -1;
+         int new_p = -1;
+         CmtSystem::is_version_directory (releases[j], new_v, new_r, new_p);
+         if (v == -1)
+         {
+             if (selected_v<new_v)
+             {
+                 selected_v       = new_v;
+                 selected_r = -1;
+                 selected_p = -1;
+                 selected_release = releases[j];
+             }
+             else if (selected_v==new_v)
+             { // We compare the r
+                 if (selected_r<new_r)
+                 {
+                     selected_r = new_r;
+                     selected_p = -1;
+                     selected_release = releases[j];                               
+                 }
+                 else if (selected_r==new_r)
+                 { // We compare the p
+                     if (selected_p<new_p)
+                     {
+                         selected_p = new_p;
+                         selected_release = releases[j];                               
+                     }
+                     // else if ? not possible                                                           
+                 }                               
+             }
+         }
+         else if (r == -1)
+         {
+             if (v==new_v)
+             { // We compare the r                                                     
+                 if (selected_r<new_r)
+                 {
+                     selected_r = new_r;
+                     selected_p = -1;
+                     selected_release = releases[j];                               
+                 }
+                 else if (selected_r==new_r)
+                 { // We compare the p
+                     if (selected_p<new_p)
+                     {
+                         selected_p = new_p;
+                         selected_release = releases[j];                               
+                     }
+                     // else if ? not possible
+                 }
+             }                                                
+         }
+         else if (p == -1)
+         {
+             if (v==new_v && r==new_r)
+                 { // We compare the p
+                     if (selected_p<new_p)
+                     {
+                         selected_p = new_p;
+                         selected_release = releases[j];                               
+                     }
+                     // else if ? not possible
+                 }        
+         }       
+         //cerr<<"v:"<<new_v<<", r:"<<new_r<<", p:"<<new_p<<endl;             
+         //cerr<<"req v:"<<v<<", req r:"<<r<<", req p:"<<p<<endl;        
+    }
+    //cerr <<"selected release: "<<selected_release<<endl;  
+    if (selected_release == "")
+        return false;
+    result = selected_release;   
+    return true;
+}
+
+//---------------------------------------------------------
+const CmtSystem::cmt_string_vector Project::get_project_releases(const cmt_string& name) const
+{
+	CmtSystem::cmt_string_vector releases;
+    cmt_string cmtprojectpath = Symbol::get_env_value ("CMTPROJECTPATH");
+    cmt_string sep;
+    sep = CmtSystem::path_separator ();
+
+    CmtSystem::cmt_string_vector items;
+    CmtSystem::split (cmtprojectpath, sep, items);    
+    for (int i = 0; i < items.size (); i++)
+    {
+        const cmt_string& item = items[i];
+        cmt_string p = item;
+        p += CmtSystem::file_separator ();
+        p += name;
+        if (CmtSystem::test_directory (p))
+	    { 
+	        CmtSystem::cmt_string_vector directories;
+            CmtSystem::scan_dir (p, directories);
+	        for (int j = 0; j < directories.size (); j++)
+	        {
+	            if  (CmtSystem::test_directory(directories[j]))
+	            {
+	                cmt_string release;
+	                CmtSystem:: basename(directories[j], release);
+	                if (CmtSystem::is_version_directory(release))
+	                {	                           
+	                     cmt_string& name_entry = releases.add ();
+	                     name_entry = release; 
+	                     //cout << release <<endl;  
+	                }             
+	            }	                    
+	        }       	                
+	    }
+    }
+    return (releases);
+}
 
 //----------------------------------------------------------
Index: /CMT/HEAD/source/cmt_project.h
===================================================================
--- /CMT/HEAD/source/cmt_project.h	(revision 272)
+++ /CMT/HEAD/source/cmt_project.h	(revision 273)
@@ -138,4 +138,8 @@
   const cmt_string& get_cmtpath_source () const;
   int get_children_size () const;
+  
+  const CmtSystem::cmt_string_vector get_project_releases(const cmt_string& name) const; 
+  bool select_release(const cmt_string& name, const cmt_string& release, cmt_string& result);
+  
   Project* get_child (int index) const;
   bool visited () const;
Index: /CMT/HEAD/source/cmt_syntax.cxx
===================================================================
--- /CMT/HEAD/source/cmt_syntax.cxx	(revision 272)
+++ /CMT/HEAD/source/cmt_syntax.cxx	(revision 273)
@@ -19,9 +19,4 @@
 #include "cmt_cmtpath_pattern.h"
 
-/*void Kwd::action (const CmtSystem::cmt_string_vector& words,
-		  Project* project,
-		  const cmt_string& file_name,
-		  int line_number)
-{}*/
 
 class KwdAction : public Kwd
