Index: /CMT/HEAD/ChangeLog
===================================================================
--- /CMT/HEAD/ChangeLog	(revision 567)
+++ /CMT/HEAD/ChangeLog	(revision 568)
@@ -1,2 +1,28 @@
+2011-04-20    <rybkin@lal.in2p3.fr> 451
+
+	* source/cmt_tag.h: In class Tag, in function mark, introduce mandatory
+	argument (to pass context), introduce member m_act_context to hold context
+	of tag activation, use package name, if available
+	* source/cmt_tag.cxx: In function mark, implement use of introduced
+	argument, make use of it in all function mark invocations, in functions
+	unmark_all, restore_tree, mark, add, introduce or enhance debug messages.
+	In function show_definition, print m_act_context with prefix "activated",
+	if does not duplicate already printed information, to provide tag
+	activation context in "cmt show tags" command output
+	* source/cmt_syntax.cxx: In class SyntaxParser, in function
+	parse_requirements, pass tag activation	context to class Tag function mark
+	via argument
+	* source/cmt_commands.cxx: In class ArgParser, in functions do_do,
+	option_tag, option_tag_add, option_tag_remove, idem
+	* source/cmt_project.cxx: In class Project function order_all, in class
+	Strategy function update, idem
+	* source/cmt_parser.cxx: In class Cmt, in functions configure_config_tag,
+	configure_hosttype_tag, configure_site_tag, restore_all_tags,
+	configure_tags, configure_uname_tag, configure_devenv_tag,
+	configure_version_tag, load, reach_current_package, use_extra_file, idem.
+	In class Cmt, in function do_check_configuration, for standalone package,
+	if current use is outside CMTPATH (and action is not action_setup) do not
+	issue warning or set error
+	
 2011-04-18    <rybkin@lal.in2p3.fr> 450
 
Index: /CMT/HEAD/source/cmt_commands.cxx
===================================================================
--- /CMT/HEAD/source/cmt_commands.cxx	(revision 567)
+++ /CMT/HEAD/source/cmt_commands.cxx	(revision 568)
@@ -1054,5 +1054,5 @@
 	Tag* tag;
 	tag = Tag::add (tag_name, PriorityUserTag, "action", 0);                      
-	tag->mark ();
+	tag->mark ("action");
       }
 
@@ -2041,5 +2041,5 @@
 			  
 	      tag = Tag::add (a, PriorityArgument, "arguments", 0);
-	      tag->mark ();
+	      tag->mark ("arguments");
 	      cmt.m_extra_tags += a;
 	      cmt.m_extra_tags += ",";
@@ -2079,5 +2079,5 @@
 	  tag = Tag::add (a, PriorityUserTag, "arguments", 0);
                       
-	  tag->mark ();
+	  tag->mark ("arguments");
 
 	  cmt.m_extra_tags += a;
@@ -2171,12 +2171,12 @@
 		  //<< cmt.m_current_tag << endl;
 
-		  tag = Tag::add (a, PriorityTag, "restore configuration", 0);
+		  tag = Tag::add (a, PriorityTag, "arguments", 0);
 		}
 	      else
 		{
-		  tag = Tag::add (a, PriorityUserTag, "restore configuration", 0);
+		  tag = Tag::add (a, PriorityUserTag, "arguments", 0);
 		}
 
-	      tag->mark ();
+	      tag->mark ("arguments");
 	  }
 }
Index: /CMT/HEAD/source/cmt_parser.cxx
===================================================================
--- /CMT/HEAD/source/cmt_parser.cxx	(revision 567)
+++ /CMT/HEAD/source/cmt_parser.cxx	(revision 568)
@@ -613,5 +613,5 @@
 
       tag = Tag::add (Me.m_cmt_config, PriorityConfig, "CMTCONFIG", 0);
-      tag->mark ();
+      tag->mark ("CMTCONFIG");
     }
 }
@@ -1230,5 +1230,5 @@
 
       tag = Tag::add (hosttype, PriorityUname, "HOSTTYPE", 0);
-      tag->mark ();
+      tag->mark ("HOSTTYPE");
     }
 }
@@ -1251,8 +1251,10 @@
     {
       cmt_string s = "CMTSITE";
+      cmt_string t = s;
 
       if (use != 0)
         {
-          s += " in ";
+          //s += " in ";
+	  t = use->get_package_name ();
         }
 
@@ -1260,5 +1262,5 @@
 
       tag = Tag::add (Me.m_cmt_site, PrioritySite, s, use);
-      tag->mark ();
+      tag->mark (t);
     }
 }
@@ -1278,8 +1280,10 @@
     {
       cmt_string s = "CMTEXTRATAGS";
+      cmt_string t = s;
 
       if (use != 0)
         {
-          s += " in ";
+          //s += " in ";
+	  t = use->get_package_name ();
         }
 
@@ -1302,5 +1306,5 @@
           tag = Tag::add (a, PriorityUserTag, s, use);
           
-          tag->mark ();
+          tag->mark (t);
         }
     }
@@ -1353,14 +1357,16 @@
 
   cmt_string s = "CMTCONFIG";
+  cmt_string t = s;
 
   if (use != 0)
     {
-      s += " in ";
-    }
-
+      //s += " in ";
+      t = use->get_package_name ();
+    }
+  
   Tag* tag;
 
   tag = Tag::add (config_tag, PriorityConfig, s, use);
-  tag->mark ();
+  tag->mark (t);
 
   //Me.m_current_tag = config_tag;
@@ -1379,5 +1385,5 @@
 
       tag = Tag::add (uname, PriorityUname, "uname", 0);
-      tag->mark ();
+      tag->mark ("uname");
     }
 }
@@ -1444,5 +1450,5 @@
 
       tag = Tag::add (devenv, PriorityUname, "devenv", 0);
-      tag->mark ();
+      tag->mark ("devenv");
     }
 }
@@ -1464,15 +1470,15 @@
 
   tag = Tag::add (temp, PriorityVersion, "CMTVERSION", 0);
-  tag->mark ();
+  tag->mark ("CMTVERSION");
 
   sprintf (temp, "CMTr%d", r);
 
   tag = Tag::add (temp, PriorityVersion, "CMTVERSION", 0);
-  tag->mark ();
+  tag->mark ("CMTVERSION");
 
   sprintf (temp, "CMTp%d", p);
 
   tag = Tag::add (temp, PriorityVersion, "CMTVERSION", 0);
-  tag->mark ();
+  tag->mark ("CMTVERSION");
 
 }
@@ -2709,4 +2715,5 @@
     {
       if (action_setup != get_action () &&
+	  none_style != use.style &&
 	  0 == Project::find_in_cmt_paths (use.real_path).size ())
 	{
@@ -6013,5 +6020,5 @@
 
       tag = Tag::add (tag_name, PriorityTag, "load", 0);
-      tag->mark ();
+      tag->mark ("load");
     }
 
@@ -6177,5 +6184,5 @@
 
           tag = Tag::add (env, PriorityConfig, "load", 0);
-          tag->mark ();
+          tag->mark ("load");
           Me.m_current_tag = env;
 
@@ -7836,5 +7843,5 @@
 
           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
-          tag->mark ();
+          tag->mark (use.get_package_name ());
 	  //Me.m_current_tag = env;
 
@@ -7974,5 +7981,5 @@
 
           tag = Tag::add (env, PriorityConfig, "reach current package", 0);
-          tag->mark ();
+          tag->mark (use.get_package_name ());
 	  //Me.m_current_tag = env;
 
Index: /CMT/HEAD/source/cmt_project.cxx
===================================================================
--- /CMT/HEAD/source/cmt_project.cxx	(revision 567)
+++ /CMT/HEAD/source/cmt_project.cxx	(revision 568)
@@ -1029,5 +1029,5 @@
 	  
 	  tag = Tag::add (p.get_name (), PriorityConfig, "PROJECT", 0);
-	  tag->mark ();
+	  tag->mark ("PROJECT");
 	}
       else if (p.is_current ())
@@ -3339,5 +3339,5 @@
 
   m_off_tag->unmark ();
-  m_on_tag->mark ();
+  m_on_tag->mark ("PROJECT");
 }
 
Index: /CMT/HEAD/source/cmt_syntax.cxx
===================================================================
--- /CMT/HEAD/source/cmt_syntax.cxx	(revision 567)
+++ /CMT/HEAD/source/cmt_syntax.cxx	(revision 568)
@@ -1471,5 +1471,5 @@
 	    {
   	      cmt_string name ("container_package");
-  	      cmt_string context ("PROJECT " + p->get_name () + " ");
+  	      cmt_string context (p->get_name ());
 	      Tag* tag = Tag::find (name);
 	      if (tag == 0)
@@ -1477,5 +1477,5 @@
 		  tag = Tag::add (name, PriorityUserTag, context, use);
 		}
-	      tag->mark ();
+	      tag->mark (use->get_package_name());
 	    }
         }                 
Index: /CMT/HEAD/source/cmt_tag.cxx
===================================================================
--- /CMT/HEAD/source/cmt_tag.cxx	(revision 567)
+++ /CMT/HEAD/source/cmt_tag.cxx	(revision 568)
@@ -36,4 +36,5 @@
   m_selected = false;
   m_def_use = 0;
+  //m_act_context = "";
 }
 
@@ -44,4 +45,7 @@
 
   int tag_number;
+
+  Log;
+  log << "Unmarking all tags (" << vector.size () << ")" << log_endl;
 
   for (tag_number = 0; tag_number < vector.size (); tag_number++)
@@ -62,4 +66,7 @@
 
   int tag_number;
+
+  Log;
+  log << "Restore tags tree (" << vector.size () << ")" << log_endl;
 
   for (tag_number = 0; tag_number < vector.size (); tag_number++)
@@ -77,5 +84,5 @@
 		  Tag* ref = tag->m_tag_refs[number];
 		  
-		  ref->mark ();
+		  ref->mark ("");
 		}
 	    }
@@ -85,5 +92,6 @@
 
 /*----------------------------------------------------------*/
-void Tag::mark ()
+void Tag::mark (const cmt_string& context)
+//void Tag::mark ()
 {
   if (!is_primary ()) return;
@@ -130,6 +138,9 @@
 
   m_selected = true;
-
-  log << "Marking tag[" << this << "] " << m_name << " p=" << m_priority << log_endl;
+  if (context.size () != 0)
+    m_act_context = context;
+
+  log << "Marking tag[" << this << "] " << m_name << " p=" << m_priority
+      << " context=" << context << log_endl;
 
   if (m_tag_refs.size () > 0)
@@ -141,5 +152,5 @@
           Tag* ref = m_tag_refs[number];
 
-          ref->mark ();
+          ref->mark (context);
         }
     }
@@ -181,5 +192,5 @@
       if (tag->is_selected ())  // it was previously selected
 	{
-	  ref->mark ();
+	  ref->mark (use ? use->get_package_name () : "");
 	}
     }
@@ -219,5 +230,5 @@
 	}
 
-      tag->mark ();
+      tag->mark (use ? use->get_package_name () : "");
     }
 }
@@ -434,6 +445,7 @@
         }
 
-      log << "re-adding tag[" << tag << "] " << name << " p=" << priority << log_endl;
-
+      log << "re-adding tag[" << tag << "] " << name << " p=" << priority
+	  << " context=" << context << (use != 0 ? " " + use->get_info () : "") << log_endl;
+      
       return (tag);
     }
@@ -444,6 +456,7 @@
   map.add (name, tag_object);
 
-  log << "adding tag[" << tag << "] " << name << " p=" << priority << log_endl;
-
+  log << "adding tag[" << tag << "] " << name << " p=" << priority
+      << " context=" << context << (use != 0 ? " " + use->get_info () : "") << log_endl;
+  
   tag->clear ();
 
@@ -601,4 +614,5 @@
   m_def_use (0),
   m_set_use (0),
+  m_act_context (""),
   m_priority (0)
 {
@@ -619,4 +633,5 @@
   m_def_use = other.m_def_use;
   m_set_use = other.m_set_use;
+  m_act_context = other.m_act_context;
   m_ref_uses = other.m_ref_uses;
   m_priority = other.m_priority;
@@ -636,4 +651,5 @@
   m_def_use = other.m_def_use;
   m_set_use = other.m_set_use;
+  m_act_context = other.m_act_context;
   m_ref_uses = other.m_ref_uses;
   m_priority = other.m_priority;
@@ -656,4 +672,5 @@
   m_def_use = 0;
   m_set_use = 0;
+  m_act_context = "";
   m_ref_uses.clear ();
   m_context = "";
@@ -742,5 +759,5 @@
 	    {
 	      out << " (from ";
-	      if (m_context != "use") out << m_context;
+	      if (m_context != "use") out << m_context + " in ";
 	      out << "package " << m_def_use->get_package_name () << ")";
 	    }
@@ -806,4 +823,11 @@
 	  out << "]";
 	}
+      if (m_act_context.size () != 0 &&
+	  (m_def_use != 0 &&
+	   m_act_context != m_context &&
+	   m_act_context != m_def_use->get_package_name () ||
+	   m_def_use == 0 &&
+	   m_act_context != m_context))
+	out << " activated " << m_act_context;
     }
   out << endl;
Index: /CMT/HEAD/source/cmt_tag.h
===================================================================
--- /CMT/HEAD/source/cmt_tag.h	(revision 567)
+++ /CMT/HEAD/source/cmt_tag.h	(revision 568)
@@ -51,5 +51,6 @@
   void add_ref_use (Use* use);
   void unmark ();
-  void mark ();
+  void mark (const cmt_string& context);
+  //void mark ();
   void show_definition (bool quiet, ostream& out = cout,
 			const cmt_string& prefix = "") const;
@@ -74,4 +75,5 @@
   Use* m_def_use;
   Use* m_set_use;
+  cmt_string m_act_context;
   Use::UsePtrVector m_ref_uses;
   int m_priority;
