Index: /CMT/HEAD/ChangeLog
===================================================================
--- /CMT/HEAD/ChangeLog	(revision 580)
+++ /CMT/HEAD/ChangeLog	(revision 581)
@@ -1,2 +1,16 @@
+2011-06-08    <rybkin@lal.in2p3.fr> 459
+
+	* source/cmt_regexp.h: In class cmt_regexp, introduce clear function
+	* source/cmt_regexp.cxx: In class cmt_regexp, implement clear function
+	* source/cmt_use.h: In class Use, make class Project friend (to give access
+	to function clear)
+	* source/cmt_use.cxx: In class Use, function clear, clear new members
+	alternate_is_head_versions and m_head_version, in class UseProjectAction,
+	function run, clear Use new member alternate_is_head_versions
+	* source/cmt_project.h: In class Project, make copy constructor and
+	assignment operator private
+	* source/cmt_project.cxx: In class Project, function container_action,
+	invoke clear function on container (rather than destructor)
+	
 2011-05-10    <rybkin@lal.in2p3.fr> 458
 
Index: /CMT/HEAD/source/cmt_project.cxx
===================================================================
--- /CMT/HEAD/source/cmt_project.cxx	(revision 580)
+++ /CMT/HEAD/source/cmt_project.cxx	(revision 581)
@@ -2305,6 +2305,4 @@
   //    omission does not permit <path>)
   //
-  Use* use = &m_container;
-  use->~Use ();
   if (words.size () < 2) return;
 
@@ -2337,16 +2335,21 @@
   if (ewords.size () > 2) path = ewords[2];
 
-  if (name != "")
-    {
-      use->set (name, version, path);
-      use->get_package ()->remove_use (use);
-      CmtSystem::cd (m_cmtpath_pwd);
-      if (use->move_to ("", true) &&
-	  !CmtSystem::absolute_path (use->real_path))
-	{
-	  use->change_path (m_cmtpath_pwd);
-	}
-      CmtSystem::cd (m_cmtpath_pwd + CmtSystem::file_separator () + "cmt");
-    }
+  Use* use = &m_container;
+  if (name == "")
+    {
+      use->clear ();
+      return;
+    }
+  if (version == "") version = "*";
+
+  use->set (name, version, path);
+  use->get_package ()->remove_use (use);
+  CmtSystem::cd (m_cmtpath_pwd);
+  if (use->move_to ("", true) &&
+      !CmtSystem::absolute_path (use->real_path))
+    {
+      use->change_path (m_cmtpath_pwd);
+    }
+  CmtSystem::cd (m_cmtpath_pwd + CmtSystem::file_separator () + "cmt");
 
   set_container_name (name);
Index: /CMT/HEAD/source/cmt_project.h
===================================================================
--- /CMT/HEAD/source/cmt_project.h	(revision 580)
+++ /CMT/HEAD/source/cmt_project.h	(revision 581)
@@ -180,5 +180,5 @@
   void use_action (const cmt_string& name, const cmt_string& release);
 
-  Project& operator = (const Project& other);
+  //  Project& operator = (const Project& other);
   bool operator == (const cmt_string& name) const;
   bool operator != (const cmt_string& name) const;
@@ -215,4 +215,7 @@
 private:
 
+  Project& operator = (const Project& other);
+  Project (const Project& other);
+
   void fill_cmtpath (cmt_string& buffer);
 
Index: /CMT/HEAD/source/cmt_regexp.cxx
===================================================================
--- /CMT/HEAD/source/cmt_regexp.cxx	(revision 580)
+++ /CMT/HEAD/source/cmt_regexp.cxx	(revision 581)
@@ -1581,4 +1581,15 @@
 }
 
+//----------------------------------------------------------
+void cmt_regexp::clear ()
+{
+  if (_root != 0)
+    {
+      delete _root;
+      _root = 0;
+    }
+}
+
+//----------------------------------------------------------
 bool cmt_regexp::is_valid () const
 {
Index: /CMT/HEAD/source/cmt_regexp.h
===================================================================
--- /CMT/HEAD/source/cmt_regexp.h	(revision 580)
+++ /CMT/HEAD/source/cmt_regexp.h	(revision 581)
@@ -18,4 +18,5 @@
   cmt_regexp (const cmt_string& expression);
   ~cmt_regexp ();
+  void clear ();
 
   void set (const cmt_string& expression);
Index: /CMT/HEAD/source/cmt_use.cxx
===================================================================
--- /CMT/HEAD/source/cmt_use.cxx	(revision 580)
+++ /CMT/HEAD/source/cmt_use.cxx	(revision 581)
@@ -1869,4 +1869,7 @@
   alternate_versions.clear ();
   alternate_paths.clear ();
+  alternate_is_head_versions.clear ();
+
+  m_head_version.clear (); 
 
   version_alias = "";
@@ -2293,4 +2296,5 @@
     m_use->alternate_versions.clear ();
     m_use->alternate_paths.clear ();
+    m_use->alternate_is_head_versions.clear ();
 
     if (m_use->reach_package (path, this->native_version))
Index: /CMT/HEAD/source/cmt_use.h
===================================================================
--- /CMT/HEAD/source/cmt_use.h	(revision 580)
+++ /CMT/HEAD/source/cmt_use.h	(revision 581)
@@ -17,4 +17,5 @@
 class Package;
 class UseProjectAction;
+class Project;
 
 class Use
@@ -240,4 +241,5 @@
 
   friend class UseProjectAction;
+  friend class Project;
 };
 
