Ignore:
Timestamp:
Oct 25, 2006, 6:37:07 PM (19 years ago)
Author:
garonne
Message:

LE commit du phew...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/source/cmt_use.cxx

    r280 r290  
    3535
    3636static bool add_request (const cmt_string& path,
    37                          const cmt_string& package_name,
    38                          const cmt_string& version)
     37                                     const cmt_string& package_name,
     38                                     const cmt_string& version,
     39                                     const cmt_string& native_version)
    3940{
    4041  static cmt_map <cmt_string, bool> requests;
     
    4445  request += version;
    4546  request += " ";
     47  request += native_version;
     48  request += " "; 
    4649  request += path;
    4750  static bool b = true;
     
    108111{
    109112public:
    110   Use* operate (Use* ref_use, Use* new_use);
     113  Use* operate (Use* ref_use, Use* new_use, const cmt_string& native_version);
    111114};
    112115
     
    134137static CompareStatus compare_versions (const cmt_string& ref_version, const cmt_string& new_version)
    135138{
     139 
    136140  CompareStatus result = IdenticalIds;
    137141
     
    147151
    148152  CmtSystem::is_version_directory (new_version, new_v, new_r, new_p);
     153          cout << "#1 Required version " << new_version <<
     154            " incompatible with selected version " << ref_version <<
     155            endl;
     156
    149157
    150158  if ((new_v != -1) && (old_v != -1) && (new_v != old_v))
     
    746754          {
    747755            cout << "about to add " << package << endl;
    748             show_packages ();
    749           }
     756                show_packages ();
     757              }
    750758
    751759        /// Now do create or retreive the Use object.
     
    14241432
    14251433//----------------------------------------------------------
    1426 int Use::reach_package (const cmt_string& from_path)
    1427 {
    1428   if (Cmt::get_debug ())
     1434int Use::reach_package (const cmt_string& from_path, const cmt_string& n_version)
     1435{
     1436    if (Cmt::get_debug ())
    14291437    {
    14301438      cout << "Use::reach_package> (" << get_package_name () << " "
     
    15831591      // There are alternate possibilities when it contains wild cards
    15841592      //
    1585       if ((version == "") ||
    1586           (version.find ("*") != cmt_string::npos))
     1593      if ((version == "") || (version.find ("*") != cmt_string::npos))
    15871594        {
    15881595          static CmtSystem::cmt_string_vector versions;
     
    15941601          else name += version;
    15951602
    1596           CmtSystem::scan_dir (name, versions);
     1603          CmtSystem::scan_dir (name, versions);     
     1604          if (n_version != "")
     1605          {
     1606              static CmtSystem::cmt_string_vector native_versions;           
     1607              for (int i = 0; i < versions.size (); i++)
     1608              {
     1609                  cmt_string path;
     1610                  if (CmtSystem::test_directory (versions[i]))
     1611                  {
     1612                      path  = versions[i];
     1613                      path += CmtSystem::file_separator ();
     1614                      path += "cmt";
     1615                  }
     1616                  else
     1617                  {
     1618                      path = "cmt";
     1619                  }
     1620                  path += CmtSystem::file_separator ();
     1621                  path += "native_version.cmt";       
     1622                                 
     1623                  if (CmtSystem::test_file (path))
     1624                      {
     1625                          cmt_string nv;
     1626                          nv.read (path);
     1627                          int pos;
     1628                          pos = nv.find ('\n');
     1629                          if (pos != cmt_string::npos) nv.erase (pos);
     1630                          pos = nv.find ('\r');
     1631                          if (pos != cmt_string::npos) nv.erase (pos);
     1632                     
     1633                          if (nv == n_version)
     1634                          {
     1635                               cmt_string& name_entry = native_versions.add ();
     1636                               name_entry += versions[i];
     1637                          }
     1638                      }                   
     1639              }
     1640              versions = native_versions;
     1641          }
    15971642         
    15981643          int i;
     
    16161661              if (CmtSystem::is_version_directory (name, v, r, p))
    16171662                {
     1663           
    16181664                  /*
    16191665                    This check is not sufficient !! We need to check in addition
     
    16231669
    16241670                  cmt_string req;
    1625 
    16261671                  req = name;
    16271672                  req += CmtSystem::file_separator ();
     
    17111756{
    17121757public:
    1713   UseProjectAction (Use* use) : m_use (use), m_found (false)
     1758  UseProjectAction (Use* use, const cmt_string& n_version="") : m_use (use), m_found (false)
    17141759  {
     1760      m_n_version = n_version;
    17151761  }
    17161762
     
    17271773    m_use->alternate_paths.clear ();
    17281774
    1729     if (m_use->reach_package (path))
     1775    if (m_use->reach_package (path, m_n_version))
    17301776      {
    17311777        if (Cmt::get_debug ())
     
    17601806private:
    17611807  Use* m_use;
     1808  cmt_string m_n_version;
    17621809  bool m_found;
    17631810};
    17641811
    17651812//----------------------------------------------------------
    1766 bool Use::move_to ()
     1813bool Use::move_to (const cmt_string& native_version)
    17671814{
    17681815  if (m_located)
     
    17781825        }
    17791826
    1780       reach_package (real_path);
     1827      reach_package (real_path, native_version);
    17811828
    17821829      return (true);
     
    17901837  if (expanded_path == "")
    17911838    {
    1792       if (reach_package (""))
     1839      if (reach_package ("", native_version))
    17931840        {
    17941841          if (Cmt::get_debug ())
     
    18211868  if (CmtSystem::absolute_path (expanded_path))
    18221869    {
    1823       if (reach_package (expanded_path))
     1870      if (reach_package (expanded_path, native_version))
    18241871        {
    18251872          if (Cmt::get_debug ())
     
    18491896  // Second try is among the CMTPATHs
    18501897  //
    1851      
    1852   UseProjectAction pa (this);
     1898  UseProjectAction pa (this, native_version);
    18531899
    18541900  Project::broadcast (pa);
     
    19291975        {
    19301976          version = alternate_versions[selected_index];
    1931           if (reach_package (alternate_paths[selected_index]))
     1977          if (reach_package (alternate_paths[selected_index], native_version))
    19321978            {
    19331979                /*
     
    19582004                    const cmt_string& package,
    19592005                    const cmt_string& version,
     2006                    const cmt_string& native_version,                   
    19602007                    Use** old_use,
    1961                     Use* context_use)
    1962 {
    1963   bool new_request = add_request (path, package, version);
     2008                        Use* context_use)
     2009{
     2010  bool new_request = add_request (path, package, version, native_version);
    19642011
    19652012  Use& current_use = Use::current ();
     
    19762023    }
    19772024
    1978   Package* p = Package::add (package);
    1979 
     2025  Package* p         = Package::add (package);
    19802026  UsePtrVector& uses = p->get_uses ();
    19812027
    19822028  bool do_need_new = true;
    1983   Use* found = 0;
    1984   Use* registered = 0;
     2029  Use* found       = 0;
     2030  Use* registered  = 0;
    19852031
    19862032  int req_v = -1;
     
    20612107                       << endl;
    20622108                }
    2063 
    20642109              // The registered use loses against the request
    20652110            }
     
    21002145            }
    21012146        }
     2147
     2148         
    21022149
    21032150      if (Cmt::get_debug ())
     
    21562203                  cout << "  ... requested wildcarded loses against existing explicit" << endl;
    21572204                }
    2158              
    2159               do_need_new = false; // We don't need a new one
     2205                      do_need_new = false; // We don't need a new one
    21602206            }
    21612207          else
     
    21632209              // here either !has_wild_card or use_has_wild_card
    21642210         
    2165               if ((version == use.specified_version) &&
    2166                   (path == use.specified_path))
     2211              if ((version == use.specified_version) && (path == use.specified_path))
    21672212                {
    21682213                  if (Cmt::get_debug ())
     
    23202365  Use* use = 0;
    23212366
    2322   do_need_new = need_new (path, package_name, version, &old_use, context_use);
    2323   // cout <<"native_version: "<<native_version<<" "<<version<<endl;
     2367  do_need_new = need_new (path, package_name, version, native_version, &old_use, context_use);
     2368  //cout <<"native_version: "<<native_version<<" "<<version<<" "<<do_need_new<<endl;
    23242369   
    23252370
     
    23382383    {
    23392384      use = create (path, package_name, version, version_alias, path_alias);
     2385      //cout <<"need_new native_version: "<<native_version<<" "<<version<<" "<<do_need_new<<endl;
    23402386    }
    23412387  else
     
    24122458   *         we have created a new Use (which has to be validated)
    24132459   */
    2414   bool found = use->move_to ();
     2460  bool found = use->move_to (native_version);
     2461
    24152462
    24162463  if (Cmt::get_debug ())
     
    24802527          if (use != 0) use->discard ();
    24812528          use = old_use;
    2482           found = use->move_to ();
     2529          found = use->move_to (native_version);
    24832530        }
    24842531      else
     
    24882535            // thus we have to choose
    24892536            //
    2490           static BestFitSelector selector;
    2491           Use* selected_use = selector.operate (old_use, use);
     2537              static BestFitSelector selector;
     2538          Use* selected_use = selector.operate (old_use, use, native_version);
    24922539
    24932540          if (Cmt::get_debug ())
     
    25052552          if (use != selected_use)
    25062553            {
    2507               use = use->set_selected_version (selected_use);
     2554                     use = use->set_selected_version (selected_use);
    25082555            }
    25092556         
     
    25112558          /*
    25122559           *   current directory is moved to the selected one
    2513            */
    2514           found = use->move_to ();
     2560           */       
     2561          found = use->move_to (native_version);
     2562
    25152563        }
    25162564    }
     
    38683916//
    38693917//----------------------------------------------------------
    3870 Use* BestFitSelector::operate (Use* ref_use, Use* new_use)
    3871 {
     3918Use* BestFitSelector::operate (Use* ref_use, Use* new_use, const cmt_string& native_version)
     3919{
     3920   
    38723921  Use* selected = ref_use;
    38733922
Note: See TracChangeset for help on using the changeset viewer.