Ignore:
Timestamp:
Nov 5, 2013, 3:40:52 PM (11 years ago)
Author:
rybkin
Message:

See C.L. 511

File:
1 edited

Legend:

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

    r610 r652  
    18261826  m_located = false;
    18271827  m_package = 0;
     1828  m_project = 0;
    18281829  m_index = -1;
    18291830
     
    18481849      m_package = 0;
    18491850    }
     1851  m_project = 0;
    18501852
    18511853  version   = "";
     
    19231925
    19241926//----------------------------------------------------------
    1925 void Use::change_path (const cmt_string& new_path)
     1927void Use::change_path (const cmt_string& new_path, const Project* project)
    19261928{
    19271929  //
     
    19291931  // where this package/version has been found.
    19301932  //
     1933  if (Cmt::get_debug ())
     1934    {
     1935      cout << "|Use::change_path> path: " << new_path
     1936           << ": project: " << (project ? project->get_cmtpath () : "0")
     1937           << ": " << get_info () << endl;
     1938    }
    19311939
    19321940  real_path = "";
    19331941  m_realpath = "";
    19341942
    1935   if (new_path != "")
     1943  m_project = 0;
     1944
     1945  if (new_path.size () != 0)
     1946    //  if (new_path != "")
    19361947    {
    19371948      if ((path.size () > 0) &&
     
    19511962      if (!CmtSystem::realpath_ (real_path, m_realpath))
    19521963        {
    1953           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    1954                          real_path + "'");
     1964          CmtError::set (CmtError::file_access_error,
     1965                         "Cannot compute real path `" + real_path + "': " +
     1966                         get_info ());
    19551967          CmtError::print ();
    19561968          return;
     
    19581970    }
    19591971 
     1972  if (project)
     1973    m_project = project;
     1974
    19601975  m_located = true;
     1976
     1977  if (Cmt::get_debug ())
     1978    {
     1979      cout << "<Use::change_path| real_path: " << real_path
     1980           << ": m_project: " << (m_project ? m_project->get_cmtpath () : "0")
     1981           << ": " << get_info () << endl;
     1982    }
    19611983}
    19621984
     
    23472369          }
    23482370       
    2349         m_use->change_path (path);
     2371        m_use->change_path (path, &project);
    23502372
    23512373        m_found = true;
     
    23552377    else if (m_use->alternate_versions.size () > 0)
    23562378      {
    2357         if (m_use->select_alternate ())
     2379        if (m_use->select_alternate (&project))
    23582380          {
    23592381            if (Cmt::get_debug ())
     
    24482470              cout << "move_to2> " << expanded_path << endl;
    24492471            }
    2450 
    24512472          change_path (here);
    2452 
    24532473          return (true);
    24542474        }
     
    24612481                  cout << "move_to5> " << real_path << endl;
    24622482                }
    2463              
    24642483              return (true);
    24652484            }
    24662485        }
     2486
     2487      if (!CmtSystem::cd (here))
     2488        {
     2489          CmtError::set (CmtError::file_access_error, here);
     2490        }
    24672491      return (false);
    24682492//     }
     
    24822506
    24832507//----------------------------------------------------------
    2484 bool Use::select_alternate ()
     2508bool Use::select_alternate (const Project* project)
    24852509{
    24862510  int i;
     
    25672591                }
    25682592
    2569               change_path (alternate_paths[selected_index]);
     2593              change_path (alternate_paths[selected_index], project);
    25702594              return (true);
    25712595            }
     
    35683592  offset = "";
    35693593
    3570   cmtpath = m_realpath.size ()
    3571     ? Project::find_in_cmt_paths (m_realpath, true)
    3572     : Project::find_in_cmt_paths (real_path)
    3573     ;
    3574   const Project* p = Project::find_by_cmtpath (cmtpath);
    3575 
     3594  const Project* p (0);
     3595  if (m_project)
     3596    {
     3597      p = m_project;
     3598      cmtpath = p->get_cmtpath ();
     3599    }
     3600  else
     3601    {
     3602      cmtpath = m_realpath.size ()
     3603        ? Project::find_in_cmt_paths (m_realpath, true)
     3604        : Project::find_in_cmt_paths (real_path)
     3605        ;
     3606      p = Project::find_by_cmtpath (cmtpath);
     3607  //  const Project* p = Project::find_by_cmtpath (cmtpath);
     3608    }
    35763609  //  if (cmtpath != "")
    35773610  if (p != 0)
     
    35903623      else if (!CmtSystem::realpath_ (real_path, offset))
    35913624        {
    3592           CmtError::set (CmtError::file_access_error, "Cannot compute real path `" +
    3593                          real_path + "'");
     3625          CmtError::set (CmtError::file_access_error,
     3626                         "Cannot compute real path `" + real_path + "': " +
     3627                         get_info ());
    35943628          CmtError::print ();
    35953629          return;
     
    37053739  buffer += "\n";
    37063740
    3707   if (located ())
     3741  if (m_located)
     3742    //  if (located ())
    37083743    {
    37093744      buffer += "macro ";
     
    37253760          buffer += package_name;
    37263761        }
    3727       //      if (style != no_version_style)
    37283762      if (structuring_style == with_version_directory)
    37293763        {
     
    37643798  buffer += "\n";
    37653799 
    3766   Project* p = Project::find_by_cmtpath (cmtpath);
     3800  const Project* p (m_project);
     3801  if (!p)
     3802    p = Project::find_by_cmtpath (cmtpath);
    37673803
    37683804  buffer += "macro ";
     
    48294865
    48304866  return (is_in_path);
    4831 }
    4832 
    4833 //----------------------------------------------------------
    4834 bool Use::located () const
    4835 {
    4836   return (m_located);
    48374867}
    48384868
     
    57365766
    57375767//----------------------------------------------------------
    5738 Project* Use::get_project ()
     5768const Project* Use::get_project () const
    57395769{   
     5770  if (m_project)
     5771    return m_project;
     5772
     5773  cmt_string cmtpath = m_realpath.size ()
     5774    ? Project::find_in_cmt_paths (m_realpath, true)
     5775    : Project::find_in_cmt_paths (real_path)
     5776    ;
     5777  return Project::find_by_cmtpath (cmtpath);
     5778  /*
    57405779  Project* p;
    57415780  cmt_string cmtpath = "";
     
    57445783  p = Project::find_by_cmtpath (cmtpath);
    57455784  return p;   
     5785  */
    57465786}
    57475787
Note: See TracChangeset for help on using the changeset viewer.