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_project.cxx

    r629 r652  
    646646      project_use->m_hidden  = true;
    647647      project_use->selected  = true;
    648       project_use->m_located = true;
     648      project_use->change_path (project->get_cmtpath(), project);
     649      //      project_use->m_located = true;
    649650      cmt_map <Use*, bool> visited;
    650651      project_use->set_auto_imports(Unspecified, Off, visited);
     
    864865  static ProjectVector& Projects = projects ();
    865866
    866   Project* result = 0;
    867 
    868867  for (int i = (Projects.size () - 1); i >= 0; i--)
    869868    {
     
    879878        //      if (here_real.find (p.m_cmtpath_real) == 0)
    880879        {
    881           result = &p;
    882         }
    883     }
    884 
    885   return (result);
     880          return &p;
     881        }
     882    }
     883
     884  return 0;
    886885}
    887886
     
    15231522
    15241523//----------------------------------------------------------
    1525 void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections)
     1524/**
     1525 *  Fill with projects (pointers) for CMTPATH entries >=1 and <= depth
     1526 *  except for CMTUSERCONTEXT project or CMTHOME project
     1527 *  unless either is current project.
     1528 *  Special values of depth:
     1529 *   0: CMTUSERCONTEXT project only
     1530 *  -1: CMTHOME project only
     1531 *
     1532 *  @param depth in CMTPATH up to which fill
     1533 *  @param path_selections vector to fill
     1534 */
     1535void Project::fill_selection (int depth, ConstProjectPtrVector& path_selections)
     1536{
     1537  static ProjectPtrVector& Ordered = Project::ordered_projects ();
     1538  int curdepth = depth;
     1539  for (int i = 0; i < Ordered.size (); i++)
     1540    {
     1541      const Project* project = Ordered[i];
     1542      const cmt_string& src = project->get_cmtpath_source ();
     1543
     1544      if (src == "default path") continue;
     1545
     1546      if (depth > 0)
     1547        {
     1548          // project for CMTPATH entries >=1 and <= depth
     1549          // except for CMTUSERCONTEXT path or CMTHOME path
     1550          // OR
     1551          // CMTUSERCONTEXT path if it's current project
     1552          // CMTHOME        path if it's current project
     1553          if (i == 0
     1554              && !project->is_current ()
     1555              && src == "CMTUSERCONTEXT") continue;
     1556          // this is CMTUSERCONTEXT
     1557          if (i == Ordered.size () - 1
     1558              && !project->is_current ()
     1559              && src == "CMTHOME") continue;
     1560          // this is CMTHOME
     1561          path_selections.push_back (project);
     1562          //cerr << "fill: " << i << ": " << project->get_cmtpath () << ": " << curdepth << endl;
     1563          if (--curdepth == 0) break;
     1564        }
     1565      else if (depth == 0)
     1566        {
     1567          // CMTUSERCONTEXT path only
     1568          if (i == 0
     1569              && src == "CMTUSERCONTEXT")
     1570            {
     1571              path_selections.push_back (project);
     1572              break;
     1573            }
     1574        }
     1575      else if (depth == -1)
     1576        {
     1577          // CMTHOME path only
     1578          if (i == Ordered.size () - 1
     1579              && src == "CMTHOME")
     1580            {
     1581              path_selections.push_back (project);
     1582              break;
     1583            }
     1584        }
     1585    }
     1586}
     1587
     1588//----------------------------------------------------------
     1589// void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections)
     1590// {
     1591//   static ProjectPtrVector& Ordered = Project::ordered_projects ();
     1592//   int curdepth = depth;
     1593//   for (int i = 0; i < Ordered.size (); i++)
     1594//     {
     1595//       const Project* project = Ordered[i];
     1596
     1597//       const cmt_string& p = project->get_cmtpath ();
     1598//       const cmt_string& pwd = project->get_cmtpath_pwd ();
     1599//       const cmt_string& p_real = project->get_cmtpath_real ();
     1600//       const cmt_string& src = project->get_cmtpath_source ();
     1601
     1602//       if (src == "default path") continue;
     1603
     1604//       if (depth > 0)
     1605//      {
     1606//        // packages from CMTPATH entries >=1 and <= depth
     1607//        // except for CMTUSERCONTEXT path or CMTHOME path
     1608//        // OR
     1609//        // CMTUSERCONTEXT path if it's current project
     1610//        // CMTHOME        path if it's current project
     1611//        if (i == 0
     1612//            && !project->is_current ()
     1613//            && src == "CMTUSERCONTEXT") continue;
     1614//        // this is CMTUSERCONTEXT
     1615//        if (i = Ordered.size () - 1
     1616//            && !project->is_current ()
     1617//            && src == "CMTHOME") continue;
     1618//        // this is CMTHOME
     1619//        cmt_string& s1 = path_selections.add ();
     1620//        s1 = p;
     1621//        if (pwd != p)
     1622//          {
     1623//            cmt_string& s2 = path_selections.add ();
     1624//            s2 = pwd;
     1625//          }
     1626//        if (p_real != p && p_real != pwd)
     1627//          {
     1628//            cmt_string& s3 = path_selections.add ();
     1629//            s3 = p_real;
     1630//          }
     1631//        if (--curdepth == 0) break;
     1632//      }
     1633//       else if (depth == 0)
     1634//      {
     1635//        // CMTUSERCONTEXT path only
     1636//        if (i == 0
     1637//            && src == "CMTUSERCONTEXT")
     1638//          {
     1639//            cmt_string& s1 = path_selections.add ();
     1640//            s1 = p;
     1641//            if (pwd != p)
     1642//              {
     1643//                cmt_string& s2 = path_selections.add ();
     1644//                s2 = pwd;
     1645//              }
     1646//            if (p_real != p && p_real != pwd)
     1647//              {
     1648//                cmt_string& s3 = path_selections.add ();
     1649//                s3 = p_real;
     1650//              }
     1651//            break;
     1652//          }
     1653//      }
     1654//       else if (depth == -1)
     1655//      {
     1656//        // CMTHOME path only
     1657//        if (i = Ordered.size () - 1
     1658//            && src == "CMTHOME")
     1659//          {
     1660//            cmt_string& s1 = path_selections.add ();
     1661//            s1 = p;
     1662//            if (pwd != p)
     1663//              {
     1664//                cmt_string& s2 = path_selections.add ();
     1665//                s2 = pwd;
     1666//              }
     1667//            if (p_real != p && p_real != pwd)
     1668//              {
     1669//                cmt_string& s3 = path_selections.add ();
     1670//                s3 = p_real;
     1671//              }
     1672//            break;
     1673//          }
     1674//      }
     1675// //     if (depth > 0)
     1676// //       {
     1677// //         cmt_string& s1 = path_selections.add ();
     1678// //         s1 = p;
     1679// //         if (pwd != p)
     1680// //           {
     1681// //             cmt_string& s2 = path_selections.add ();
     1682// //             s2 = pwd;
     1683// //           }
     1684// //         if (p_real != p && p_real != pwd)
     1685// //           {
     1686// //             cmt_string& s3 = path_selections.add ();
     1687// //             s3 = p_real;
     1688// //           }
     1689// //         if (src != "CMTHOME" && src != "CMTUSERCONTEXT")
     1690// //           depth--;
     1691
     1692// //         if (depth == 0) break;
     1693// //       }
     1694
     1695//     }
     1696// }
     1697
     1698//----------------------------------------------------------
     1699/**
     1700 *  Fill with projects (pointers) for CMTUSERCONTEXT and CMTHOME projects
     1701 *  (if any exists)
     1702 *  unless either is current project.
     1703 * 
     1704 *  @param path_exclusions vector to fill
     1705 */
     1706void Project::fill_exclusion (ConstProjectPtrVector& path_exclusions)
    15261707{
    15271708  static ProjectPtrVector& Ordered = Project::ordered_projects ();
     
    15291710    {
    15301711      const Project* project = Ordered[i];
    1531 
    1532       const cmt_string& p = project->get_cmtpath ();
    1533       const cmt_string& pwd = project->get_cmtpath_pwd ();
    1534       const cmt_string& p_real = project->get_cmtpath_real ();
    15351712      const cmt_string& src = project->get_cmtpath_source ();
    1536       /*
    1537   static ProjectVector& Projects = projects ();
    1538 
    1539   for (int i = 0; i < Projects.size (); i++)
    1540     {
    1541       Project& project = Projects[i];
    1542 
    1543       const cmt_string& p = project.get_cmtpath ();
    1544       const cmt_string& pwd = project.get_cmtpath_pwd ();
    1545       const cmt_string& p_real = project.get_cmtpath_real ();
    1546       const cmt_string& src = project.get_cmtpath_source ();
    1547       */
    1548       if (src != "default path")
    1549         {
    1550           if (depth > 0)
    1551             {
    1552               cmt_string& s1 = path_selections.add ();
    1553               s1 = p;
    1554               if (pwd != p)
    1555                 {
    1556                   cmt_string& s2 = path_selections.add ();
    1557                   s2 = pwd;
    1558                 }
    1559               if (p_real != p && p_real != pwd)
    1560                 {
    1561                   cmt_string& s3 = path_selections.add ();
    1562                   s3 = p_real;
    1563                 }
    1564               if (src != "CMTHOME" && src != "CMTUSERCONTEXT")
    1565                 depth--;
    1566 
    1567               if (depth == 0) break;
    1568             }
    1569         }
     1713
     1714      if (!project->is_current ()
     1715          && (src == "CMTUSERCONTEXT" || src == "CMTHOME"))
     1716        path_exclusions.push_back (project);
    15701717    }
    15711718}
     
    16941841//          }
    16951842
    1696           if (path_real.find (p_real) != cmt_string::npos)
     1843          if (path_real.find (p_real) == 0) //!= cmt_string::npos)
    16971844            {
    16981845              return (p);
     
    17001847
    17011848          // To become the current area, a path must correspond to the current package
    1702           if (path.find (w) != cmt_string::npos)
     1849          if (path.find (w) == 0)// != cmt_string::npos)
    17031850            {
    17041851              return (p);
     
    17061853        }
    17071854
     1855        /* This code is never used since p is returned above
    17081856      if (p == w) continue;
    17091857
     
    17111859      //      if (CmtSystem::test_directory (w))
    17121860        {
    1713           if (path.find (w) != cmt_string::npos)
     1861          if (path.find (w) == 0)// != cmt_string::npos)
    17141862            {
    17151863              return (w);
    17161864            }
    17171865        }
     1866        */
    17181867    }
    17191868
     
    23622511  use->get_package ()->remove_use (use);
    23632512  CmtSystem::cd (m_cmtpath_pwd);
    2364   if (use->move_to ("", true) &&
    2365       !CmtSystem::absolute_path (use->real_path))
    2366     {
    2367       use->change_path (m_cmtpath_pwd);
    2368     }
     2513  if (use->move_to ("", true))
     2514    {
     2515      if (use->get_realpath ().find (this->get_cmtpath_real ()) == 0)
     2516        use->set_project (this);
     2517    }
     2518  else
     2519    if (0 == CmtSystem::getenv ("CMTPEDANTIC").size () &&
     2520        0 == CmtSystem::getenv ("PEDANTIC").size ())
     2521      CmtMessage::warning
     2522        (CmtError::get_error_name (CmtError::configuration_error)
     2523         + ": Cannot locate container: " + use->get_info ());
     2524    else
     2525      CmtError::set(CmtError::configuration_error,
     2526                    "Cannot locate container: " + use->get_info ());
     2527 
    23692528  CmtSystem::cd (m_cmtpath_pwd + CmtSystem::file_separator () + "cmt");
     2529
     2530  if (CmtError::get_last_error_code () == CmtError::configuration_error)
     2531    return;
    23702532
    23712533  set_container_name (name);
Note: See TracChangeset for help on using the changeset viewer.