Index: CMT/HEAD/ChangeLog
===================================================================
--- CMT/HEAD/ChangeLog	(revision 524)
+++ CMT/HEAD/ChangeLog	(revision 525)
@@ -1,2 +1,21 @@
+2009-11-06    <rybkin@lal.in2p3.fr> 412
+
+	* source/cmt_project.h: In class Project, introduce (static) function
+	show_container, functions get_container_name, get_container_path,
+	set_container_name, set_container_path, and drop functions get_container,
+	set_container, add and drop class members accordingly, change
+	container_action function signature to allow for the generic CMT container
+	statement syntax
+	* source/cmt_project.cxx: Implement the introduced and modified functions
+	* source/cmt_syntax.cxx: In class KwdContainer, modify function action to
+	reflect the changes above
+	* source/cmt_commands.cxx: Introduce and implement "cmt show container"
+	command making use of the functions introduced above
+	* source/cmt_parser.h: idem
+	* source/cmt_parser.cxx: idem
+	* source/cmt.h: idem
+	* src/setup.tcsh: Add completion for "cmt show container" command in TCSH
+	* src/setup.zsh: Add completion for "cmt show container" command in Z shell
+	
 2009-10-15    <rybkin@lal.in2p3.fr> 411
 
Index: CMT/HEAD/source/cmt.h
===================================================================
--- CMT/HEAD/source/cmt.h	(revision 524)
+++ CMT/HEAD/source/cmt.h	(revision 525)
@@ -165,4 +165,5 @@
   static void do_show_constituent_names (const ArgParser& ap);
   static void do_show_constituents (const ArgParser& ap);
+  static void do_show_container (const ArgParser& ap);
   static void do_show_cycles (const ArgParser& ap);
   static void do_show_fragment (const ArgParser& ap);
Index: CMT/HEAD/source/cmt_commands.cxx
===================================================================
--- CMT/HEAD/source/cmt_commands.cxx	(revision 524)
+++ CMT/HEAD/source/cmt_commands.cxx	(revision 525)
@@ -1311,4 +1311,8 @@
 	{
 	  cmt.m_action = action_show_constituents;
+	}
+      else if (arg == "container")
+	{
+	  cmt.m_action = action_show_container;
 	}
       else if (arg == "cycles")
@@ -2340,4 +2344,5 @@
   help.add (action_show_constituent_names, help_texts[action_show_constituent_names]);
   help.add (action_show_constituents, help_texts[action_show_constituents]);
+  help.add (action_show_container, help_texts[action_show_container]);
   help.add (action_show_cycles, help_texts[action_show_cycles]);
   help.add (action_show_fragment, help_texts[action_show_fragment]);
Index: CMT/HEAD/source/cmt_parser.cxx
===================================================================
--- CMT/HEAD/source/cmt_parser.cxx	(revision 524)
+++ CMT/HEAD/source/cmt_parser.cxx	(revision 525)
@@ -3932,4 +3932,10 @@
 
 //----------------------------------------------------------
+void Cmt::do_show_container (const ArgParser& /*ap*/)
+{
+  Project::show_container ();
+}
+
+//----------------------------------------------------------
 void Cmt::do_show_cycles (const ArgParser& /*ap*/)
 {
@@ -5711,4 +5717,5 @@
     case action_show_constituent_names :
     case action_show_constituents :
+    case action_show_container :
     case action_show_cycles :
     case action_show_fragment :
@@ -5823,4 +5830,5 @@
     case action_show_constituent_names :
     case action_show_constituents :
+    case action_show_container :
     case action_show_cycles :
     case action_show_fragment :
@@ -5927,4 +5935,5 @@
     case action_show_constituent_names :
     case action_show_constituents :
+    case action_show_container :
     case action_show_cycles :
     case action_show_fragment :
@@ -6041,4 +6050,5 @@
           // case action_show_cmtpath_patterns :
           // case action_show_constituent :
+          // case action_show_container :
           // case action_show_constituent_names :
           // case action_show_constituents :
@@ -6248,4 +6258,7 @@
 	case action_show_branches :
 	  do_show_branches (ap);
+	  break;
+        case action_show_container :
+	  do_show_container (ap);
 	  break;
 	case action_show_clients :
Index: CMT/HEAD/source/cmt_parser.h
===================================================================
--- CMT/HEAD/source/cmt_parser.h	(revision 524)
+++ CMT/HEAD/source/cmt_parser.h	(revision 525)
@@ -285,4 +285,5 @@
   action_show_constituent_names,
   action_show_constituents,
+  action_show_container,
   action_show_cycles,
   action_show_fragment,
Index: CMT/HEAD/source/cmt_project.cxx
===================================================================
--- CMT/HEAD/source/cmt_project.cxx	(revision 524)
+++ CMT/HEAD/source/cmt_project.cxx	(revision 525)
@@ -1120,4 +1120,66 @@
 
 /*----------------------------------------------------------*/
+void Project::show_container ()
+{
+  Project* p = get_current ();
+
+  if (p == 0) return;
+  Use* use = &(p->m_container);
+  if (use->get_package_name () == "") return;
+
+          if (!use->located ())
+            {
+	      CmtMessage::warning ("container " + use->get_package_name ()
+				   + " " + use->version + " " + use->path
+				   + " not found");
+	      /*
+              if (!Cmt::get_quiet ())
+                {
+                  cout << "# package " << use->get_package_name () <<
+		    " " << use->version << " " << use->path << 
+		    " not found" <<
+		    endl;
+                }
+	      */
+              CmtError::set (CmtError::package_not_found, use->get_package_name ());
+            }
+          else
+            {
+              static const cmt_string empty;
+              cmt_string p = use->real_path;
+              if (use->path != "")
+                {
+		  int pos = p.find_last_of (use->path);
+		  if (pos != cmt_string::npos)
+		    {
+		      p.erase (pos);
+		    }
+                }
+              
+              cout << "container " << use->get_package_name ()
+		   << " " << use->version;
+
+	      if (CmtSystem::absolute_path (use->path))
+		{
+		  if (!Cmt::get_quiet ()) 
+		    {
+		      cout << " (" << use->path << ")";
+		    }
+		}
+	      else
+		{
+		  cout << " " << use->path;
+		}
+
+              if (!Cmt::get_quiet ()) 
+                {
+                  if (p != "") cout << " (" << p << ")";
+                  if (use->auto_imports == Off) cout << " (no_auto_imports)";
+                }
+
+              cout << endl;
+            }
+}
+/*----------------------------------------------------------*/
 void Project::show_specified_strategies_for_all ()
 {
@@ -1720,7 +1782,7 @@
 
 //----------------------------------------------------------
-const cmt_string& Project::get_container () const
-{
-  return (m_container);
+const cmt_string& Project::get_container_name () const
+{
+  return (m_container_name);
 }
 
@@ -1729,4 +1791,10 @@
 {
   return (m_container_version);
+}
+
+//----------------------------------------------------------
+const cmt_string& Project::get_container_path () const
+{
+  return (m_container_path);
 }
 
@@ -1788,7 +1856,7 @@
 
 //----------------------------------------------------------
-void Project::set_container (const cmt_string& container)
-{
-  m_container = container;
+void Project::set_container_name (const cmt_string& name)
+{
+  m_container_name = name;
 }
 
@@ -1797,4 +1865,10 @@
 {
   m_container_version = container_version;
+}
+
+//----------------------------------------------------------
+void Project::set_container_path (const cmt_string& container_path)
+{
+  m_container_path = container_path;
 }
 
@@ -1954,10 +2028,77 @@
    A container statement is met in the project file
 */
-void Project::container_action (const cmt_string& name, const cmt_string& version)
-{
-  //cerr << "Container action " << name << " " << version << endl;
-
-  set_container (name);
+void Project::container_action (const CmtSystem::cmt_string_vector& words)
+//void Project::container_action (const cmt_string& name, const cmt_string& version)
+{
+  //
+  // complete syntax : "container <package> <version> <path>"  
+  // minimal syntax  : "container <package>"
+  //
+  //  o if <version> is omitted then take any version available
+  //  o <version> can be specified using "v*" or "v<n>r*" or "v<n>r<m>p*"
+  //
+  //  o the notation "v*" is preferred to omission (particularly since
+  //    omission does not permit <path>)
+  //
+  Use* use = &m_container;
+  use->~Use ();
+  if (words.size () < 2) return;
+
+  CmtSystem::cmt_string_vector ewords;
+  for (int i = 1; i < words.size (); i++)
+    {
+      const cmt_string& w = words[i];
+      cmt_string ew = w;
+
+      Symbol::expand (ew);
+      if (ew != w)
+        {
+          CmtSystem::cmt_string_vector ws;
+          CmtSystem::split (ew, " ", ws);
+
+          for (int j = 0; j < ws.size (); ++j)
+            {
+	      ewords.push_back (ws[j]);
+            }
+        }
+      else
+        {
+	  ewords.push_back (w);
+        }
+    }
+
+  cmt_string name, version, path;
+  if (ewords.size () > 0) name = ewords[0];
+  if (ewords.size () > 1) version = ewords[1];
+  if (ewords.size () > 2) path = ewords[2];
+
+  if (name != "")
+    {
+      use->set (name, version, path);
+      use->get_package ()->remove_use (use);
+      if (use->move_to ())
+	{
+	  cmt_string use_real;
+	  bool ok (false);
+	  if (!CmtSystem::absolute_path (use->path))
+	    {
+	      ok = CmtSystem::realpath_ (use->real_path, use_real);
+	    }
+	  else
+	    {
+	      ok = CmtSystem::realpath_ (use->path, use_real);
+	    }
+	  if (ok && use_real.find (m_cmtpath_real) != 0)
+	    {
+	      use->~Use ();
+	    }
+	}
+      CmtSystem::cd (m_cmtpath_pwd + CmtSystem::file_separator () + "cmt");
+    }
+  //  cerr << CmtSystem::pwd () << endl;
+
+  set_container_name (name);
   set_container_version (version);
+  set_container_path (path);
 }
 
Index: CMT/HEAD/source/cmt_project.h
===================================================================
--- CMT/HEAD/source/cmt_project.h	(revision 524)
+++ CMT/HEAD/source/cmt_project.h	(revision 525)
@@ -112,4 +112,5 @@
   static void clear_all ();
   static void show_all ();
+  static void show_container ();
   static void show_specified_strategies_for_all ();
   static void show_paths (const CmtSystem::cmt_string_vector& arguments);
@@ -136,6 +137,8 @@
   const cmt_string& get_name () const;
   const cmt_string& get_release () const;
-  const cmt_string& get_container () const;
+  const cmt_string& get_container_name () const;
   const cmt_string& get_container_version () const;
+  const cmt_string& get_container_path () const;
+  //  const Use& get_container () const;
   const cmt_string& get_cmtpath () const;
   const cmt_string& get_cmtpath_real () const;
@@ -152,6 +155,8 @@
   void set_name (const cmt_string& name);
   void set_release (const cmt_string& release);
-  void set_container (const cmt_string& container);
+  //  void set_container (const cmt_string& container);
+  void set_container_name (const cmt_string& name);
   void set_container_version (const cmt_string& version);
+  void set_container_path (const cmt_string& path);
   void set_cmtpath (const cmt_string& path);
   void set_cmtpath_real (const cmt_string& path);
@@ -166,5 +171,6 @@
   void add_child (Project* p);
 
-  void container_action (const cmt_string& name, const cmt_string& version);
+  void container_action (const CmtSystem::cmt_string_vector& words);
+  //  void container_action (const cmt_string& name, const cmt_string& version);
   void use_action (const cmt_string& name, const cmt_string& release);
 
@@ -208,6 +214,8 @@
   cmt_string m_author;
   cmt_string m_release;
-  cmt_string m_container;
+  cmt_string m_container_name;
   cmt_string m_container_version;
+  cmt_string m_container_path;
+  Use m_container;
 
   ProjectPtrVector m_parents;
Index: CMT/HEAD/source/cmt_syntax.cxx
===================================================================
--- CMT/HEAD/source/cmt_syntax.cxx	(revision 524)
+++ CMT/HEAD/source/cmt_syntax.cxx	(revision 525)
@@ -363,5 +363,6 @@
 	       int line_number)
   {
-    project->container_action (words[1], words[2]);
+    project->container_action (words);
+    //project->container_action (words[1], words[2]);
   }
 };
Index: CMT/HEAD/src/setup.tcsh
===================================================================
--- CMT/HEAD/src/setup.tcsh	(revision 524)
+++ CMT/HEAD/src/setup.tcsh	(revision 525)
@@ -8,5 +8,5 @@
 complete cmt p/1/'(broadcast build check check_files checkout co cleanup config create expand filter help lock relocate remove run setup show system unlock version cvstags cvsbranches cvssubpackages cvssubprojects)'/ \
  n/build/'(CMT_pacman constituent_makefile constituents_makefile dependencies library_links make_setup msdev os9_makefile prototype readme tag_makefile temporary_name triggers win_makefile)'/ \
- n/show/'(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
+ n/show/'(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents container cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects project_author pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
  n/check/'(configuration files version)'/ \
  n/expand/'(model)'/ \
Index: CMT/HEAD/src/setup.zsh
===================================================================
--- CMT/HEAD/src/setup.zsh	(revision 524)
+++ CMT/HEAD/src/setup.zsh	(revision 525)
@@ -26,5 +26,5 @@
    'w[1,remove] p[3]' -X '> give version tag' - \
    'w[1,remove] p[4]' -X '> give a path if not located from the current path ' - \
-   's[show],c[-1,show]' -k '(action,action_names,action_value,actions,all_tags,applied_patterns,author,branches,clients,cmtpath_patterns,constituent,constituent_names,constituents,cycles,fragment,fragments,groups,include_dirs,language,languages,macro,macro_names,macro_value,macros,manager,packages,path,pattern,patterns,projects,project_author,pwd,set,set_names,set_value,sets,strategies,tags,use_paths,uses,versions)' - \
+   's[show],c[-1,show]' -k '(action,action_names,action_value,actions,all_tags,applied_patterns,author,branches,clients,cmtpath_patterns,constituent,constituent_names,constituents,container,cycles,fragment,fragments,groups,include_dirs,language,languages,macro,macro_names,macro_value,macros,manager,packages,path,pattern,patterns,projects,project_author,pwd,set,set_names,set_value,sets,strategies,tags,use_paths,uses,versions)' - \
    'w[1,show] c[-1,constituent]' -K cmt_constituents - \
    'w[1,show] c[-1,fragment]' -K cmt_fragments - \
