Changeset 535
- Timestamp:
- Mar 26, 2010, 11:56:50 AM (14 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r534 r535 1 2010-03-26 <rybkin@lal.in2p3.fr> 422 2 3 * source/cmt_system.cxx: In function CMTPathManager::do_add_cmt_path, 4 ensure that projects created from CMTPATH environment variable entries do 5 not become each others children-parents automatically (that will be 6 based on use statements in project.cmt files). Ensure that command exit 7 status is returned by CmtSystem::execute (const cmt_string&, cmt_string&) 8 * source/cmt_database.h: Introduce member m_ordered_projects to keep vector 9 of pointers to the ordered projects and function ordered_projects to return 10 that 11 * source/cmt_database.cxx: Implement function ordered_projects 12 * source/cmt_project.h: Introduce functions order_all, set_is_current, 13 is_current, erase_child, and member m_is_current 14 * source/cmt_project.cxx: Implement introduced functions. In function 15 ProjectFactory::create_project, call Project::order_all () if projects 16 dependencies are updated or new project is created, call 17 Cmt::get_current_dir_real to determine (and set the project member 18 accordingly) whether project is current or not, do NOT make project that 19 has no parent the top project. In function get_current, make use of 20 is_current rather than pwd. Function Project::ordered_projects now only 21 returns ordered projects pointers vector, projects ordering is done in 22 Project::order_all. Ordering starts with current project, if exists, and 23 projects without parents, if current project does not exist or has no 24 parents and no children (the case for projects created from CMTPATH 25 environment variable entries), and aims to put parents before children 26 in projects order. If current project exists, only ordered projects are 27 present in ordered projects vector. For projects without parents and 28 without children, strategies are updated from the project next after 29 them in the ordered projects vector. In function Project::show_all, always 30 show all projects (rather than children of current or first project only), 31 first show ordered projects, then show the rest. In function Project::visit, 32 do not reorder current project if exists. Implement functions is_current, 33 set_is_current, erase_child. In function container_action, start search 34 from project m_cmtpath_pwd, if container is found, ensure its real_path is 35 absolute path 36 * source/cmt_use.h: Add helper function get_info to return use info as 37 string 38 * source/cmt_use.cxx: In function show_all, for home_package and 39 user_context_package use version assigned when they are created rather 40 than hard-wire version here, set error package_not_found if there are uses 41 that are not located. In function reach_package, consider case of empty 42 version. Implement get_info and make use of it in function Use::add 43 * source/cmt_pattern.cxx: In function ApplyPattern::action, always print 44 warning pattern_not_found, if appropriate, but do not set error (for now) 45 * source/cmt_syntax.cxx: In functions do_parse_requirements, do_parse_words, 46 clear syntax_error only, and print error messages in case of syntax_error 47 only 48 * source/cmt_log.h: Add CmtMessage::verbose function 49 * source/cmt.h: Introduce functions get_current_dir_real, get_current_path, 50 set_recursive 51 * source/cmt_parser.cxx: Implement introduced functions, in function 52 use_special_requirements, set use m_located member value to true, if 53 requirements file exists 54 * source/cmt_vcs.h: In class Vcs, introduce functions checkout_context, 55 parse_arguments, resolve_uses, introduce class IUseVisitor 56 * source/cmt_vcs.cxx: Introduce and implement class GlobalProjectAction, 57 class Packages, in order to generate uses available via current context 58 and search for specific packages among them. Rewrite class Walkthru to 59 accept an implementation of IUseVisitor interface, replace parse_checkout 60 with parse_arguments with new options -C, -i, and implement new 61 parse_checkout, in particular, in order to implement new options -C, -i. 62 Introduce helper classes VisitorForInfo, VisitorForCheckout implementing 63 IUseVisitor interface, enhance Vcs::checkout_module to allow for HEAD, 64 head, TRUNK, trunk to be used as arguments of option -r. Implement 65 functions visit, Vcs::checkout_context, Vcs::resolve_uses in order to 66 implement option -C, enhance Vcs::checkout_from_requirements in order to 67 implement option -i 68 * src/Makefile.header: Improve a diagnostic message 69 * src/Makefile.core: Do not ignore errors in command lines beginning with 70 macro echo 71 * mgr/cmt_dependencies.make: Update 72 1 73 2010-02-25 <rybkin@lal.in2p3.fr> 421 2 74 -
CMT/HEAD/mgr/cmt_dependencies.make
r528 r535 17 17 cmt_pattern_cxx_dependencies = ../source/cmt_pattern.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_parser.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_map.h ../source/cmt_pattern.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_branch.h ../source/cmt_fragment.h ../source/cmt_group.h ../source/cmt_constituent.h ../source/cmt_language.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_awk.h ../source/cmt_project.h ../source/cmt_cmtpath_pattern.h ../source/cmt_database.h ../source/cmt_error.h ../source/cmt_syntax.h ../source/cmt_log.h 18 18 cmt_language_cxx_dependencies = ../source/cmt_language.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_fragment.h ../source/cmt_language.h ../source/cmt_branch.h ../source/cmt_group.h ../source/cmt_constituent.h ../source/cmt_map.h ../source/cmt_pattern.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_awk.h ../source/cmt_project.h ../source/cmt_cmtpath_pattern.h ../source/cmt_database.h ../source/cmt_error.h 19 cmt_vcs_cxx_dependencies = ../source/cmt_vcs.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_parser.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_cvs.h ../source/cmt_ vcs.h ../source/cmt_awk.h ../source/cmt_map.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_pattern.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_project.h ../source/cmt_log.h ../source/cmt_error.h19 cmt_vcs_cxx_dependencies = ../source/cmt_vcs.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_parser.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_cvs.h ../source/cmt_map.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_pattern.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_vcs.h ../source/cmt_awk.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_project.h ../source/cmt_log.h ../source/cmt_error.h ../source/cmt_syntax.h 20 20 cmt_group_cxx_dependencies = ../source/cmt_group.cxx ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_vector.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_group.h ../source/cmt_branch.h ../source/cmt_fragment.h ../source/cmt_constituent.h ../source/cmt_language.h ../source/cmt_map.h ../source/cmt_pattern.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_awk.h ../source/cmt_project.h ../source/cmt_cmtpath_pattern.h ../source/cmt_database.h 21 21 cmt_database_cxx_dependencies = ../source/cmt_database.cxx ../source/cmt_vector.h ../source/cmt_std.h ../source/cmt_string.h ../source/cmt_regexp.h ../source/cmt_system.h ../source/cmt.h ../source/cmt_parser.h ../source/cmt_branch.h ../source/cmt_fragment.h ../source/cmt_group.h ../source/cmt_constituent.h ../source/cmt_language.h ../source/cmt_map.h ../source/cmt_pattern.h ../source/cmt_include.h ../source/cmt_script.h ../source/cmt_scope_section.h ../source/cmt_use.h ../source/cmt_tag.h ../source/cmt_symbol.h ../source/cmt_awk.h ../source/cmt_project.h ../source/cmt_cmtpath_pattern.h ../source/cmt_database.h -
CMT/HEAD/source/cmt.h
r525 r535 210 210 static const cmt_string& get_cmt_version (); 211 211 static const cmt_string& get_current_dir (); 212 static const cmt_string get_current_dir_real (); 212 213 static const cmt_string& get_current_package (); 214 static const cmt_string& get_current_path (); 213 215 static const cmt_string& get_current_cmtpath (); 214 216 static const cmt_string& get_current_offset (); … … 258 260 static void restore_all_tags (Use* use); 259 261 static void set_current_access (AccessMode mode); 262 static void set_recursive (bool mode); 260 263 static void set_scope_filtering_mode (CmtScopeFilteringMode mode); 261 264 static void set_standard_macros (); -
CMT/HEAD/source/cmt_database.cxx
r11 r535 158 158 } 159 159 160 Project::ProjectPtrVector& Database::ordered_projects () 161 { 162 static Database& db = instance (); 163 164 return (db.m_ordered_projects); 165 } 166 160 167 CmtPathPattern::CmtPathPatternVector& Database::cmtpath_patterns () 161 168 { -
CMT/HEAD/source/cmt_database.h
r11 r535 54 54 55 55 static Project::ProjectVector& projects (); 56 static Project::ProjectPtrVector& ordered_projects (); 56 57 57 58 static CmtPathPattern::CmtPathPatternVector& cmtpath_patterns (); … … 83 84 Tag::TagMap m_tag_map; 84 85 Project::ProjectVector m_projects; 86 Project::ProjectPtrVector m_ordered_projects; 85 87 86 88 CmtPathPattern::CmtPathPatternVector m_cmtpath_patterns; -
CMT/HEAD/source/cmt_log.h
r467 r535 64 64 static void set_level (const CmtMsgLevel& level); 65 65 static bool active (const CmtMsgLevel& level); 66 static void verbose (const cmt_string& message); 66 67 static void info (const cmt_string& message); 67 68 static void warning (const cmt_string& message); … … 118 119 } 119 120 121 inline void CmtMessage::verbose (const cmt_string& message) 122 { 123 if (active (Verbose)) 124 cerr << prefix () << " Verbose: " << message << endl; 125 } 126 120 127 inline void CmtMessage::info (const cmt_string& message) 121 128 { -
CMT/HEAD/source/cmt_parser.cxx
r532 r535 532 532 log << "configure_site_tag" << log_endl; 533 533 configure_site_tag (0); 534 log << "configure_current_dir" << log_endl; 535 configure_current_dir (); 534 536 log << "configure_home" << log_endl; 535 537 // CMTHOME, CMTUSERCONTEXT and CMTPATH 536 538 configure_home (0); 537 log << "configure_current_dir" << log_endl;539 // log << "configure_current_dir" << log_endl; 538 540 539 541 … … 547 549 Me.m_quiet = save_quiet; 548 550 549 configure_current_dir ();551 // configure_current_dir (); 550 552 551 553 guess_current_project (); … … 4289 4291 cout << "----------> uses" << endl; 4290 4292 do_show_uses (ap); 4293 // This is temporary to ensure that Make - which runs "cmt show setup" - 4294 // does not fail for packages with unresolved uses 4295 if (CmtError::get_last_error_code () == CmtError::package_not_found) 4296 CmtError::clear (); 4291 4297 4292 4298 cout << "----------> tags" << endl; … … 4571 4577 } 4572 4578 4579 const cmt_string Cmt::get_current_dir_real () 4580 { 4581 cmt_string current_dir_real; 4582 if (CmtSystem::realpath_ (Me.m_current_dir, current_dir_real)) 4583 return current_dir_real; 4584 return (Me.m_current_dir); 4585 } 4586 4573 4587 const cmt_string& Cmt::get_current_package () 4574 4588 { 4575 4589 return (Me.m_current_package); 4590 } 4591 4592 const cmt_string& Cmt::get_current_path () 4593 { 4594 return (Me.m_current_path); 4576 4595 } 4577 4596 … … 8562 8581 8563 8582 //---------------------------------------------------------- 8583 void Cmt::set_recursive (bool mode) 8584 { 8585 Me.m_recursive = mode; 8586 } 8587 8588 //---------------------------------------------------------- 8564 8589 void Cmt::set_scope_filtering_mode (CmtScopeFilteringMode mode) 8565 8590 { … … 8778 8803 f += CmtSystem::file_separator (); 8779 8804 f += file_name; 8805 if (CmtSystem::test_file (f)) 8806 { 8807 use->m_located = true; 8808 } 8780 8809 SyntaxParser::parse_requirements (f, use); 8781 8810 -
CMT/HEAD/source/cmt_pattern.cxx
r504 r535 844 844 if (p == 0) 845 845 { 846 CmtError::set (CmtError::pattern_not_found, name); 846 if (use->get_current_scope () != ScopeUnspecified && 847 use->get_current_scope () != ScopePublic) 848 return; 849 /* 850 cmt_string use_info (use->get_package_name () + 851 " " + use->version + 852 (use->path != "" ? " " + use->path : "") + 853 " " + use->real_path 854 ); 855 */ 856 CmtMessage::warning (CmtError::get_error_name (CmtError::pattern_not_found) + 857 ": " + name + 858 " (applied by " + use->get_package_name () + ")" 859 ); 860 /* 861 CmtError::set (CmtError::pattern_not_found, name + 862 " (applied by " + use->get_package_name () + ")" 863 ); 864 */ 865 /* 847 866 if (CmtMessage::active (Verbose)) 848 867 { 849 cmt_string cmtpath, offset; 850 use->get_cmtpath_and_offset (cmtpath, offset); 851 CmtMessage::warning ((offset != "" ? offset + "/" : "") 852 + use->get_package_name () 853 + ": " + CmtError::get_last_error ()); 854 //CmtMessage::warning (CmtError::get_last_error ()); 868 CmtMessage::warning (CmtError::get_last_error ()); 855 869 } 870 */ 856 871 return; 857 872 } -
CMT/HEAD/source/cmt_project.cxx
r528 r535 247 247 } 248 248 249 bool updated (false); 249 250 if (parent != 0) 250 251 { 252 if (!p.has_parent (parent) || !parent->has_child (&p)) 253 { 251 254 p.add_parent (parent); 252 255 parent->add_child (&p); … … 255 258 256 259 parent->update_strategies_from_children (); 260 updated = true; 261 } 262 257 263 } 258 264 259 265 CmtSystem::cd (here); 266 if (updated) Project::order_all (); 260 267 return (&p); 261 268 } … … 278 285 279 286 // In case there are symlinks 280 cmt_string here_real, pwd_real; 287 288 // cmt_string here_real, pwd_real; 281 289 //cerr << "realpath_: create_project" << endl; 290 /* 282 291 if (CmtSystem::realpath_ (here, here_real) && CmtSystem::realpath_ (pwd, pwd_real)) 283 292 { 284 293 if (here_real.find (pwd_real) == 0) is_current = true; 294 } 295 */ 296 cmt_string pwd_real; 297 if (CmtSystem::realpath_ (pwd, pwd_real)) 298 { 299 if (Cmt::get_current_dir_real ().find (pwd_real) == 0) is_current = true; 285 300 } 286 301 … … 544 559 parent->update_strategies_from_children (); 545 560 } 561 /* 546 562 else if ((name != "CMTUSERCONTEXT") && (name != "CMTHOME")) 547 563 // else … … 569 585 project->update_strategies_from_children (); 570 586 } 571 587 */ 572 588 if (source == "default path") 573 589 { … … 581 597 project->set_cmtpath_source (source); 582 598 599 project->set_is_current (is_current); 600 583 601 if (is_current) 584 602 { 603 // cerr << "current: " << project->get_name () << endl; 585 604 // 586 605 // The current project defines a tag with its name … … 594 613 595 614 615 // Project::order_all (); 596 616 597 617 if (text != "") … … 649 669 650 670 CmtSystem::cd (here); 671 Project::order_all (); 651 672 652 673 return (project); … … 820 841 Project* Project::get_current () 821 842 { 843 /* 822 844 cmt_string here = CmtSystem::pwd (); 823 845 … … 825 847 cmt_string here_real; 826 848 CmtSystem::realpath_ (here, here_real); 827 849 */ 828 850 static ProjectVector& Projects = projects (); 829 851 … … 840 862 841 863 // if (here.find (p.m_cmtpath) == 0) 842 if (here_real.find (p.m_cmtpath_real) == 0) 864 if (p.is_current ()) 865 // if (here_real.find (p.m_cmtpath_real) == 0) 843 866 { 844 867 result = &p; … … 907 930 908 931 //---------------------------------------------------------- 909 Project::ProjectPtrVector Project::ordered_projects () 910 { 911 static ProjectPtrVector OrderedProjects; 932 Project::ProjectPtrVector& Project::ordered_projects () 933 { 934 static Database& db = Database::instance (); 935 static ProjectPtrVector& Projects = db.ordered_projects (); 936 937 return (Projects); 938 } 939 940 //---------------------------------------------------------- 941 void Project::order_all () 942 //Project::ProjectPtrVector Project::ordered_projects () 943 { 944 ProjectPtrVector OrderedProjects; 945 // static ProjectPtrVector OrderedProjects; 946 static Project::ProjectPtrVector& orderedProjects = Project::ordered_projects (); 912 947 913 948 static Project::ProjectVector& Projects = Project::projects (); … … 956 991 OrderedProjects[i] = p; 957 992 } 993 /* 958 994 if (2 == offset) 959 995 { … … 962 998 OrderedProjects[0]->update_strategies_from_children (); 963 999 } 964 return OrderedProjects; 1000 */ 1001 for (int i = OrderedProjects.size () - 2; i >= 0; i--) 1002 { 1003 if (!OrderedProjects[i]->has_parents () && 1004 OrderedProjects[i]->get_children_size () == 0) 1005 { 1006 OrderedProjects[i]->add_child (OrderedProjects[i + 1]); 1007 OrderedProjects[i]->update_strategies_from_children (); 1008 OrderedProjects[i]->erase_child (OrderedProjects[i + 1]); 1009 } 1010 } 1011 1012 orderedProjects = OrderedProjects; 1013 // return OrderedProjects; 1014 return; 965 1015 } 966 1016 … … 968 1018 969 1019 // cerr << "get_current: " << p << " offset: " << offset << endl; 1020 /* 970 1021 if (p == 0) 971 1022 { … … 973 1024 // p = &(Projects[0]); 974 1025 } 1026 */ 975 1027 // cerr << "p: " << p << " offset: " << offset << " name: " << p->get_name () << endl; 976 1028 977 1029 int order (-1); 978 1030 /* 979 1031 if ((p->get_name () != "CMTUSERCONTEXT") && (p->get_name () != "CMTHOME")) 980 1032 { … … 989 1041 // cerr << "order: " << order << endl; 990 1042 // int unordered = size - offset - (order + 1); 1043 */ 1044 ProjectPtrVector projs; 1045 1046 if (p != 0 && (p->get_name () != "CMTUSERCONTEXT") && (p->get_name () != "CMTHOME")) 1047 { 1048 p->m_order = ++order; 1049 projs.push_back (p); 1050 } 1051 1052 if (p == 0 || 1053 (!p->has_parents () && p->get_children_size () == 0) 1054 // comes from CMTPATH entry 1055 ) 1056 { 1057 for (int i = offset; i < size; i++) 1058 { 1059 Project* q = &(Projects[i]); 1060 if (q != p && !q->has_parents ()) 1061 { 1062 q->m_order = ++order; 1063 projs.push_back (q); 1064 } 1065 } 1066 } 1067 1068 visit (offset, order, projs); 991 1069 992 1070 int beg (0); … … 1017 1095 */ 1018 1096 } 1097 else if (-2 != j) 1098 { 1099 OrderedProjects[beg + j] = p; 1100 } 1101 /* 1019 1102 else if (-2 == j) 1020 1103 { … … 1026 1109 // cerr << "OrderedProjects[" << beg + j << "]: " << (OrderedProjects[beg + j])->get_name () << endl; 1027 1110 } 1028 } 1029 1111 */ 1112 } 1113 1114 if (p != 0) 1115 { 1116 for (int i = 0; i < noorder; i++) 1117 OrderedProjects.pop_back (); 1118 } 1030 1119 if (-1 != ihome) 1031 1120 { 1032 OrderedProjects[size - 1] = &(Projects[ihome]); 1033 } 1034 1121 OrderedProjects[OrderedProjects.size () - 1] = &(Projects[ihome]); 1122 } 1123 /* 1124 if (p) 1125 { 1126 if (-1 != ihome) 1127 { 1128 OrderedProjects[beg + order + 1] = &(Projects[ihome]); 1129 } 1130 for (int i = 0; i < noorder; i++) 1131 OrderedProjects.pop_back (); 1132 } 1133 else 1134 { 1135 if (-1 != ihome) 1136 { 1137 OrderedProjects[size - 1] = &(Projects[ihome]); 1138 } 1139 } 1140 */ 1141 /* 1035 1142 if (-1 != iuser) 1036 1143 { … … 1039 1146 OrderedProjects[0]->update_strategies_from_children (); 1040 1147 } 1041 1042 if (-1 != ihome) 1043 { 1148 */ 1149 1150 // if (-1 != ihome) 1151 // { 1044 1152 /* 1045 1153 cerr << "beg: " << beg << " order: " << order << endl; 1046 1154 cerr << "noorder: " << noorder << " size - offset: " << size - offset << endl; 1047 1155 */ 1156 /* 1048 1157 if (noorder != size - offset) 1049 1158 { // the last ordered project … … 1058 1167 OrderedProjects[size - 2]->update_strategies_from_children (); 1059 1168 } 1060 } 1061 1062 return OrderedProjects; 1169 */ 1170 // } 1171 1172 for (int i = OrderedProjects.size () - 2; i >= 0; i--) 1173 { 1174 if (!OrderedProjects[i]->has_parents () && 1175 OrderedProjects[i]->get_children_size () == 0) 1176 { 1177 OrderedProjects[i]->add_child (OrderedProjects[i + 1]); 1178 OrderedProjects[i]->update_strategies_from_children (); 1179 OrderedProjects[i]->erase_child (OrderedProjects[i + 1]); 1180 } 1181 } 1182 1183 orderedProjects = OrderedProjects; 1184 // return OrderedProjects; 1185 return; 1063 1186 } 1064 1187 … … 1080 1203 void Project::show_all () 1081 1204 { 1082 const Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 1083 // static const Project::ProjectPtrVector Ordered = Project::ordered_projects (); 1084 1085 for (int i = 0; i < Ordered.size (); i++) 1086 { 1087 Project* p = Ordered[i]; 1088 p->m_visited = false; 1089 } 1090 1091 Project* p = get_current (); 1092 1093 if (p == 0) 1094 { 1095 if (Ordered.size () == 0) return; 1096 1097 p = Ordered[0]; 1098 } 1099 /* 1205 static const Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 1100 1206 static Project::ProjectVector& Projects = Project::projects (); 1101 1207 … … 1106 1212 } 1107 1213 1214 for (int i = 0; i < Ordered.size (); i++) 1215 Ordered[i]->show (); 1216 1217 for (int i = 0; i < Projects.size (); i++) 1218 Projects[i].show (); 1219 1220 /* 1108 1221 Project* p = get_current (); 1109 1222 1110 1223 if (p == 0) 1111 1224 { 1112 if ( Projects.size () == 0) return;1113 1114 p = &(Projects[0]);1225 if (Ordered.size () == 0) return; 1226 1227 p = Ordered[0]; 1115 1228 } 1116 1229 */ 1117 1118 p->show (); 1230 // p->show (); 1119 1231 } 1120 1232 … … 1303 1415 void Project::fill_selection (int depth, CmtSystem::cmt_string_vector& path_selections) 1304 1416 { 1305 static ProjectPtrVector Ordered = Project::ordered_projects ();1417 static ProjectPtrVector& Ordered = Project::ordered_projects (); 1306 1418 for (int i = 0; i < Ordered.size (); i++) 1307 1419 { … … 1352 1464 void Project::broadcast (IProjectAction& action) 1353 1465 { 1354 static ProjectPtrVector Projects = Project::ordered_projects (); 1466 // const ProjectPtrVector Projects = Project::ordered_projects (); 1467 static ProjectPtrVector& Projects = Project::ordered_projects (); 1355 1468 1356 1469 for (int i = 0; i < Projects.size (); i++) … … 1375 1488 void Project::reverse_broadcast (IProjectAction& action) 1376 1489 { 1377 static ProjectPtrVector Projects = Project::ordered_projects (); 1490 // const ProjectPtrVector Projects = Project::ordered_projects (); 1491 static ProjectPtrVector& Projects = Project::ordered_projects (); 1378 1492 1379 1493 for (int i = (Projects.size () - 1); i >= 0; i--) … … 1556 1670 { 1557 1671 int size = projs.size (); 1672 // cerr << "visit: " << offset << " " << order << " " << size << endl; 1558 1673 if (0 == size) return; 1559 1674 static ProjectVector& all = Project::projects (); … … 1591 1706 child->m_order = ++order; 1592 1707 } 1593 else if (0 == chorder) 1708 else if (child->is_current ()) 1709 // else if (0 == chorder) 1594 1710 { // the project we started with, i. e. the current project: 1595 1711 // o circular dependency … … 1601 1717 + " " + child->get_cmtpath ()); 1602 1718 } 1603 else if ((0 < chorder) && (chorder < porder)) 1719 else if ((0 <= chorder) && (chorder < porder)) 1720 // else if ((0 < chorder) && (chorder < porder)) 1604 1721 { // ordered already, want to put it after the parent in the order 1605 1722 for (int k = offset; k < all.size (); k++) … … 1609 1726 {// the child we are putting after the parent in the order 1610 1727 q.m_order = porder; 1611 // cerr << "Moved back: " << q.get_name () << " order: " << q.m_order << endl;1728 // cerr << "Moved back: " << q.get_name () << " order: " << q.m_order << endl; 1612 1729 } 1613 1730 else if ((chorder < q.m_order) && (q.m_order <= porder)) … … 1615 1732 } 1616 1733 } 1617 // 1734 // cerr << child->get_name () << " out: " << child->m_order << endl; 1618 1735 // child->m_visits++; 1619 1736 bool unknown (true); … … 1748 1865 start_visit (visitor); 1749 1866 */ 1750 const ProjectPtrVector Ordered = Project::ordered_projects ();1867 const ProjectPtrVector& Ordered = Project::ordered_projects (); 1751 1868 1752 1869 buffer = "path CMTPATH \"\" \n"; … … 1909 2026 1910 2027 //---------------------------------------------------------- 2028 void Project::set_is_current (bool is_current) 2029 { 2030 m_is_current = is_current; 2031 } 2032 2033 //---------------------------------------------------------- 2034 bool Project::is_current () const 2035 { 2036 return m_is_current; 2037 } 2038 2039 //---------------------------------------------------------- 1911 2040 void Project::clear () 1912 2041 { … … 1925 2054 1926 2055 m_strategies.clear (); 2056 m_is_current = false; 1927 2057 } 1928 2058 … … 2019 2149 2020 2150 m_children.push_back (p); 2151 } 2152 2153 //---------------------------------------------------------- 2154 void Project::erase_child (Project* p) 2155 { 2156 if (p == 0) return; 2157 if (p == this) return; 2158 2159 if (!has_child (p)) return; 2160 2161 const cmt_string& name = p->get_name (); 2162 2163 for (int i = 0; i < m_children.size (); i++) 2164 { 2165 const Project* child = m_children[i]; 2166 if (child == 0) continue; 2167 2168 if (child->get_name () == name) 2169 { 2170 // registered as a child 2171 m_children.erase (i); 2172 break; 2173 } 2174 } 2021 2175 } 2022 2176 … … 2088 2242 use->set (name, version, path); 2089 2243 use->get_package ()->remove_use (use); 2244 CmtSystem::cd (m_cmtpath_pwd); 2090 2245 if (use->move_to ()) 2091 2246 { … … 2103 2258 { 2104 2259 use->~Use (); 2260 } 2261 else if (!CmtSystem::absolute_path (use->real_path)) 2262 { 2263 use->change_path (m_cmtpath_pwd); 2105 2264 } 2106 2265 } … … 2382 2541 static int level = 0; 2383 2542 2384 bool is_current = false;2543 // bool is_current = false; 2385 2544 2386 2545 // cmt_string here = CmtSystem::pwd (); 2387 2546 // In case there are symlinks 2547 /* 2388 2548 cmt_string here_real; 2389 2549 CmtSystem::realpath_ (CmtSystem::pwd (), here_real); … … 2397 2557 } 2398 2558 } 2399 2559 */ 2400 2560 for (int tab = 0; tab < level; tab++) cout << " "; 2401 2561 cout << m_name << " " << (m_name != "CMTUSERCONTEXT" && m_name != "CMTHOME" ? m_release : "v0") << " (in " << m_cmtpath << ")"; 2402 2562 // cout << m_name << " " << m_release << " (in " << m_cmtpath << ")"; 2403 2563 2404 if (is_current) cout << " (current)"; 2564 if (m_is_current) cout << " (current)"; 2565 // if (is_current) cout << " (current)"; 2405 2566 2406 2567 int i; -
CMT/HEAD/source/cmt_project.h
r526 r535 109 109 110 110 static ProjectVector& projects (); 111 static ProjectPtrVector ordered_projects (); 111 static ProjectPtrVector& ordered_projects (); 112 static void order_all (); 112 113 static void clear_all (); 113 114 static void show_all (); … … 163 164 void set_cmtpath_pwd (const cmt_string& path); 164 165 void set_cmtpath_source (const cmt_string& source); 166 void set_is_current (bool is_current); 167 bool is_current () const; 165 168 void clear (); 166 169 void configure (); … … 170 173 void add_parent (Project* p); 171 174 void add_child (Project* p); 175 void erase_child (Project* p); 172 176 173 177 void container_action (const CmtSystem::cmt_string_vector& words); … … 225 229 int m_visits; 226 230 int m_order; 231 bool m_is_current; 227 232 228 233 cmt_string m_cmtpath; -
CMT/HEAD/source/cmt_syntax.cxx
r526 r535 1656 1656 cmt_string text; 1657 1657 1658 CmtError::clear (); 1658 if (CmtError::get_last_error_code () == CmtError::syntax_error) 1659 CmtError::clear (); 1659 1660 1660 1661 if (!CmtSystem::test_file (actual_file_name)) … … 1888 1889 Use* use) 1889 1890 { 1890 CmtError::clear (); 1891 if (CmtError::get_last_error_code () == CmtError::syntax_error) 1892 CmtError::clear (); 1891 1893 1892 1894 if (words.size () == 0) return; … … 1921 1923 } 1922 1924 1923 if (CmtError::has_pending_error ()) 1925 if (CmtError::get_last_error_code () == CmtError::syntax_error) 1926 // if (CmtError::has_pending_error ()) 1924 1927 { 1928 CmtError::print (); 1929 1925 1930 char num[32]; sprintf (num, "%d", line_number); 1926 1931 CmtMessage::error ("bad syntax in requirements of " + use->get_package_name () … … 1955 1960 Project* project) 1956 1961 { 1957 CmtError::clear (); 1962 if (CmtError::get_last_error_code () == CmtError::syntax_error) 1963 CmtError::clear (); 1958 1964 1959 1965 if (words.size () == 0) return; … … 1973 1979 } 1974 1980 1975 if (CmtError::has_pending_error ()) 1981 if (CmtError::get_last_error_code () == CmtError::syntax_error) 1982 // if (CmtError::has_pending_error ()) 1976 1983 { 1984 CmtError::print (); 1985 1977 1986 char num[32]; sprintf (num, "%d", line_number); 1978 1987 CmtMessage::error ("bad syntax in project file of " + project->get_name () -
CMT/HEAD/source/cmt_system.cxx
r533 r535 1413 1413 } 1414 1414 1415 m_project = factory.create_project (project_name, npath, path_source, m_project); 1415 m_project = factory.create_project (project_name, npath, path_source, 0); 1416 // m_project = factory.create_project (project_name, npath, path_source, m_project); 1417 /* 1416 1418 if ((path_source == "CMTUSERCONTEXT") || 1417 1419 (path_source == "CMTHOME")) … … 1419 1421 m_project = 0; 1420 1422 } 1423 */ 1421 1424 } 1422 1425 } … … 1646 1649 output = ""; 1647 1650 1648 // cerr << "CmtSystem::execute2> [" << command << "]" << endl;1651 // cerr << "CmtSystem::execute2> [" << command << "]" << endl; 1649 1652 1650 1653 FILE* f = popen (command.c_str (), "r"); … … 1661 1664 } 1662 1665 1663 if (pclose (f) == -1) 1666 int status = pclose (f); 1667 if (status == -1) // error reported by pclose () 1664 1668 { 1669 perror ("pclose"); 1665 1670 if (errno == ECHILD) 1666 1671 { 1667 1672 return (0); 1668 1673 } 1669 return ( 1);1674 return (-1); 1670 1675 } 1671 1672 return (0); 1673 } 1674 1675 return (1); 1676 else 1677 { 1678 return WEXITSTATUS(status); // return status of the command 1679 //return (0); 1680 } 1681 } 1682 1683 return (-2); 1676 1684 } 1677 1685 -
CMT/HEAD/source/cmt_use.cxx
r531 r535 574 574 } 575 575 576 Use* suse = Use::find (CmtSystem::get_home_package ()); 577 if (suse != 0 && !suse->discarded && !suse->m_hidden && suse->located ()) 578 { 579 cout << prefix << suse->get_package_name () 580 << " " << suse->version; 581 if (!Cmt::get_quiet ()) 582 { 583 cout << " (" << suse->path << ")"; 584 } 585 cout << endl; 586 } 587 suse = Use::find (CmtSystem::get_user_context_package ()); 588 if (suse != 0 && !suse->discarded && !suse->m_hidden && suse->located ()) 589 { 590 cout << prefix << suse->get_package_name () 591 << " " << suse->version; 592 if (!Cmt::get_quiet ()) 593 { 594 cout << " (" << suse->path << ")"; 595 } 596 cout << endl; 597 } 598 /* 576 599 if (Cmt::get_cmt_home () != "") 577 600 { … … 593 616 cout << endl; 594 617 } 618 */ 619 } 620 621 const UseVector& instances = get_instances (); 622 for (int use_index = 0; use_index < instances.size (); use_index++) 623 { 624 Use* use = &(instances[use_index]); 625 //Use* use = uses[j]; 626 627 if (use->discarded) continue; 628 if (use->m_hidden) continue; 629 630 if (!use->located ()) 631 { 632 CmtError::set (CmtError::package_not_found, use->get_info ()); 633 } 634 else 635 { 636 /* 637 CmtMessage::info ("package " + 638 use->get_package_name () + 639 " " + use->version + 640 (use->path != "" ? " " + use->path : "") + 641 " found"); 642 */ 643 } 595 644 } 596 645 } … … 854 903 } 855 904 } 905 /* 906 else // new_use == 0 907 { 908 cerr << "action: " << action << " new_use: " << new_use 909 << " package: " << package << endl; 910 911 CmtError::set (CmtError::package_not_found, package); 912 } 913 */ 856 914 857 915 return (new_use); … … 1604 1662 return (1); 1605 1663 } 1606 else if (!CmtSystem::cd (version)) 1664 else if (!CmtSystem::cd (version) || (version == "")) 1665 // else if (!CmtSystem::cd (version)) 1607 1666 { 1608 1667 // … … 1610 1669 // There are alternate possibilities when it contains wild cards 1611 1670 // 1671 if ((version.find ("*") != cmt_string::npos) || (version == "")) 1612 1672 // if ((version == "") || (version.find ("*") != cmt_string::npos)) 1613 if (version.find ("*") != cmt_string::npos)1673 // if (version.find ("*") != cmt_string::npos) 1614 1674 { 1615 1675 static CmtSystem::cmt_string_vector versions; … … 1618 1678 name = "."; 1619 1679 name += CmtSystem::file_separator (); 1620 name += version; 1680 if (version != "") name += version; 1681 else name += "*"; 1621 1682 /* 1622 1683 if (version == "") name += "*"; 1623 1684 else name += version; 1624 1685 */ 1625 1686 // name += version; 1626 1687 CmtSystem::scan_dir (name, versions); 1627 1688 if (n_version != "") … … 2506 2567 if (!found) 2507 2568 { 2569 CmtMessage::warning (CmtError::get_error_name (CmtError::package_not_found) 2570 + ": " + use->get_info () 2571 + ( (context_use != 0) ? 2572 " (requested by " + context_use->get_package_name () + ")" : 2573 "" ) 2574 ); 2575 /* 2508 2576 CmtMessage::warning ("package " + use->get_package_name () 2509 2577 + " " + use->version + " " + use->path … … 2513 2581 "" ) 2514 2582 ); 2583 */ 2515 2584 /* 2516 2585 if (!Cmt::get_quiet ()) … … 2530 2599 2531 2600 //CmtError::set (CmtError::package_not_found, use->get_package_name ()); 2601 //use->m_located = false; 2532 2602 use = 0; 2533 2603 } … … 4670 4740 return p; 4671 4741 } 4742 4743 //---------------------------------------------------------- 4744 cmt_string Use::get_info () const 4745 { 4746 return get_package_name () + " " + (version != "" ? version : "*") + 4747 (path != "" ? " " + path : "") ; 4748 // return get_package_name () + " " + version + (path != "" ? " " + path : "") ; 4749 } -
CMT/HEAD/source/cmt_use.h
r531 r535 134 134 135 135 Project* get_project (); 136 cmt_string get_info () const; 136 137 // Public attributes 137 138 public: -
CMT/HEAD/source/cmt_vcs.cxx
r534 r535 18 18 #include "cmt_error.h" 19 19 20 #include "cmt_syntax.h" 21 20 22 /** 21 23 … … 92 94 }; 93 95 96 //-------------------------------------------------------------------- 97 static void show_packages () 98 { 99 Package::PackageVector& vector = Package::packages (); 100 101 int i; 102 int j; 103 104 cout << "### Packages: "; 105 for (i = 0; i < vector.size (); i++) 106 { 107 Package& p = vector[i]; 108 cout << p.get_name () << "["; 109 Use::UsePtrVector& uses = p.get_uses (); 110 for (j = 0; j < uses.size (); j++) 111 { 112 Use* u = uses[j]; 113 cout << u << ","; 114 } 115 116 cout << "] "; 117 } 118 cout << endl; 119 120 { 121 Use::UsePtrVector& uses = Use::get_ordered_uses (); 122 // static Use::UsePtrVector& uses = Use::get_ordered_uses (); 123 124 cout << "### Uses: "; 125 for (i = 0; i < uses.size (); i++) 126 { 127 Use* u = uses[i]; 128 cout << "[" << u << "]" << u->get_package_name () << " "; 129 } 130 } 131 132 cout << endl; 133 } 134 135 //-------------------------------------------------------------------- 136 137 class GlobalProjectAction : public IProjectAction 138 { 139 public: 140 GlobalProjectAction (const cmt_string& package, 141 const cmt_string& version = "", 142 const cmt_string& path = "") 143 : m_package (package), m_version (version), m_path (path) 144 { 145 m_home_dir = CmtSystem::pwd (); 146 m_current = Use::current(); 147 m_current_name = m_current.get_package_name (); 148 m_current.set_package_name ("m_current"); 149 } 150 151 bool run (const Project& project) 152 { 153 if (project.is_current ()) return true; 154 CmtMessage::verbose ("run: " + project.get_cmtpath ()); 155 const Use* use = &(project.get_container ()); 156 if (use->get_package_name () != "" && use->located ()) 157 { 158 CmtMessage::verbose ("container " + use->get_info () + 159 " (" + use->real_path + ")"); 160 Use* cuse = Use::add (use->real_path, 161 use->get_package_name (), 162 use->version, 163 "", "", "", 0); // 0 == NOT used by current 164 if (cuse) 165 { 166 cmt_string cmt (use->get_full_path ()); 167 cmt += CmtSystem::file_separator (); 168 cmt += "cmt"; 169 if (!CmtSystem::cd (cmt)) 170 { 171 CmtMessage::error ("Cannot move to directory " + cmt); 172 CmtError::set (CmtError::file_access_error, cmt); 173 if (!CmtSystem::cd (m_home_dir)) 174 { 175 CmtMessage::error ("Cannot move to directory " + m_home_dir); 176 CmtError::set (CmtError::file_access_error, m_home_dir); 177 } 178 return true; 179 } 180 //cerr << "parsing: " << "requirements" << endl; 181 SyntaxParser::parse_requirements ("requirements", cuse); 182 //cerr << "parsed: " << "requirements" << endl; 183 //show_packages (); 184 } 185 else 186 { 187 CmtMessage::error ("Cannot add container " + use->get_package_name () + 188 " " + use->version + " " + use->real_path); 189 } 190 if (!CmtSystem::cd (m_home_dir)) 191 { 192 CmtMessage::error ("Cannot move to directory " + m_home_dir); 193 CmtError::set (CmtError::file_access_error, m_home_dir); 194 } 195 } 196 return true; 197 } 198 199 private: 200 cmt_string m_home_dir; 201 cmt_string m_package; 202 cmt_string m_version; 203 cmt_string m_path; 204 cmt_string m_cmtpath; 205 Use m_current; 206 cmt_string m_current_name; 207 }; 208 209 //-------------------------------------------------------------------- 210 /** 211 * 212 * Packages: keep info on all packages that can be found 213 * in current context - CMTPATHs. 214 * 215 */ 216 217 class Packages 218 { 219 public: 220 static Packages& instance (); 221 // void clear (); 222 // void install (const cmt_string& line); 223 // bool is_installed (const cmt_string& line); 224 225 Use* find (const cmt_string& name, 226 const cmt_string& version = "", 227 const cmt_string& path = ""); 228 229 private: 230 Packages (); 231 void exclude_current_project (); 232 void restore_current_project (); 233 234 int m_i; 235 Project* m_cur; 236 Project m_null; 237 bool m_initialized; 238 }; 239 240 //-------------------------------------------------------------------- 241 Packages::Packages () 242 : m_i (-1), m_cur (0), m_initialized (false) 243 { 244 m_null.set_cmtpath (CmtSystem::get_temporary_name ()); 245 } 246 247 //-------------------------------------------------------------------- 248 Packages& Packages::instance () 249 { 250 static Packages pkgs; 251 return (pkgs); 252 } 253 254 //-------------------------------------------------------------------- 255 Use* Packages::find (const cmt_string& name, 256 const cmt_string& version, 257 const cmt_string& path) 258 { 259 if (name == "") return 0; 260 // cerr << "find: " << name << " " << version << " " << path << endl; 261 exclude_current_project (); 262 if (path != "") 263 { 264 //cerr << "find: No need to find path: " << name << " " << path << endl; 265 // Use use_obj (name, "", path); 266 Use use_obj (name, version, path); 267 Use* use = &use_obj; 268 //use->set (name, version, path); 269 use->get_package ()->remove_use (use); 270 if (use->move_to ()) 271 { 272 CmtSystem::cd (Cmt::get_current_dir ()); 273 /* 274 cerr << "real_path: " << use->real_path 275 << " style: " << use->style 276 << " structuring_style: " << use->structuring_style 277 << " full_path: " << use->get_full_path () << endl; 278 */ 279 Use::UseVector& instances = Use::get_instances (); 280 Use& use_object = instances.add (); 281 use_object = *use; 282 /* 283 use_object.set (use->get_package_name (), use->version, use->path, 284 use->version_alias, use->path_alias); 285 use_object.get_package ()->remove_use (&use_object); 286 */ 287 restore_current_project (); 288 return (&use_object); 289 } 290 else 291 { 292 CmtSystem::cd (Cmt::get_current_dir ()); 293 CmtMessage::warning (CmtError::get_error_name (CmtError::package_not_found) 294 + ": " + use->get_info ()); 295 } 296 } 297 // 298 // Second try is among the CMTPATHs 299 // 300 if (!m_initialized) 301 { 302 m_initialized = true; 303 304 GlobalProjectAction pa (name, version, path); 305 306 Project::reverse_broadcast (pa); 307 // Project::broadcast (pa); 308 } 309 // cerr << "find: " << name << " " << version << " " << path << " Done." << endl; 310 //show_packages (); 311 312 Package* p = Package::find (name); 313 if (p == 0) 314 { 315 restore_current_project (); 316 return 0; 317 } 318 //return PackageInfo (name, version, path, ""); 319 Use::UsePtrVector& uses = p->get_uses (); 320 Use* p_use (0); 321 // cerr << "find for: " << name << endl; 322 for (int use_index = 0; use_index < uses.size (); use_index++) 323 { 324 Use* use = uses[use_index]; 325 char index[8]; 326 sprintf (index, "%d", use->m_index); 327 CmtMessage::verbose ("find: " + use->get_info () + 328 " (" + use->real_path + ")" + 329 " m_index: " + index + 330 " located: " + (use->located () ? "1" : "0")); 331 if (use->located ()) p_use = use; 332 // if (use->m_index >= 0) return use; 333 if (use->m_index >= 0) break; 334 } 335 if (p_use) 336 { 337 // cerr << "find: Try to validate: " << p_use->get_info () 338 // << ": " << p_use->real_path << endl; 339 // Use use_obj (name, "", path); 340 Use use_obj (name, version, p_use->path); 341 Use* use = &use_obj; 342 use->get_package ()->remove_use (use); 343 if (use->move_to ()) 344 { 345 CmtSystem::cd (Cmt::get_current_dir ()); 346 if (use->version == p_use->version) 347 { 348 CmtMessage::verbose ("Validated: " + p_use->get_info () + 349 " (" + p_use->real_path + ")"); 350 restore_current_project (); 351 return p_use; 352 } 353 Use* n_use = Use::add (use->real_path, 354 use->get_package_name (), 355 use->version, 356 use->version_alias, 357 use->path_alias, 358 use->native_version, 359 0); // 0 == NOT used by current 360 CmtSystem::cd (Cmt::get_current_dir ()); 361 restore_current_project (); 362 return n_use; 363 } 364 else 365 { 366 CmtSystem::cd (Cmt::get_current_dir ()); 367 CmtMessage::verbose (CmtError::get_error_name (CmtError::package_not_found) 368 + ": " + use->get_info ()); 369 restore_current_project (); 370 return 0; 371 } 372 } 373 374 restore_current_project (); 375 return p_use; 376 // return PackageInfo (name, version, path, ""); 377 // return pa.info (); 378 } 379 380 //-------------------------------------------------------------------- 381 void Packages::exclude_current_project () 382 { 383 if (m_i != -1 || m_cur != 0) return; 384 // cerr << "exclude_current_project: " << m_i << ": " << m_cur << endl; 385 Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 386 int i = -1; 387 // m_cur = 0; 388 // Project null; 389 for (i = 0; i < Ordered.size (); i++) 390 if (Ordered[i]->is_current ()) break; 391 if (i >= 0 && i < Ordered.size ()) 392 { 393 m_i = i; 394 m_cur = Ordered[i]; 395 Ordered[i] = &m_null; 396 } 397 } 398 399 //-------------------------------------------------------------------- 400 void Packages::restore_current_project () 401 { 402 Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 403 if (m_i >= 0 && m_i < Ordered.size ()) 404 { 405 Ordered[m_i] = m_cur; 406 m_i = -1; 407 m_cur = 0; 408 } 409 } 410 411 //-------------------------------------------------------------------- 412 /* 413 void Packages::clear () 414 { 415 m_installed = ""; 416 } 417 418 void Packages::install (const cmt_string& line) 419 { 420 m_installed += "|"; 421 m_installed += line; 422 m_installed += "|"; 423 } 424 425 bool Packages::is_installed (const cmt_string& line) 426 { 427 if (m_installed.find (line) != cmt_string::npos) 428 { 429 return (true); 430 } 431 432 return (false); 433 } 434 */ 435 436 //-------------------------------------------------------------------- 94 437 /** 95 438 … … 129 472 }; 130 473 131 class Walkthru : public Awk 474 //-------------------------------------------------------------------- 475 /** 476 * 477 * Helper classes 478 * 479 */ 480 481 /* 482 class SelectSubUses : public Awk 132 483 { 133 484 public: 134 Walkthru (const Vcs::Checkout& checkout, 135 bool config, bool with_version_directory, 136 Vcs::VcsType type); 137 // RecursivePass2 (CvsImplementation& cvs); 485 138 486 void begin (); 139 487 void filter (const cmt_string& line); 488 // const cmt_string& result () const; 489 bool has (const cmt_string& package) const; 140 490 141 491 private: 142 const Vcs::Checkout& m_checkout; 143 bool m_config; 144 bool m_with_version_directory; 145 Vcs::VcsType m_type; 146 // CvsImplementation& m_cvs; 492 void append (const cmt_string& package); 493 cmt_string m_result; 494 bool m_first; 147 495 }; 148 496 149 Walkthru::Walkthru (const Vcs::Checkout& checkout, 150 bool config, bool with_version_directory, 151 Vcs::VcsType type) 152 : m_checkout (checkout), 153 m_config (config), m_with_version_directory (with_version_directory), 154 m_type (type) 155 { 156 } 157 158 void Walkthru::begin () 159 { 160 } 161 162 void Walkthru::filter (const cmt_string& line) 163 { 164 // History& h = History::instance (); 165 166 // if (h.is_installed (line)) return; 167 168 // h.install (line); 169 497 void SelectSubUses::begin () 498 { 499 m_first = true; 500 m_result = ""; 501 } 502 503 void SelectSubUses::filter (const cmt_string& line) 504 { 170 505 CmtSystem::cmt_string_vector words; 171 506 … … 183 518 cmt_string version; 184 519 cmt_string path; 185 186 for (int i = 1; i < words.size (); i++)520 cerr << line; 521 for (int i = 2; i < words.size (); i++) 187 522 { 188 523 const cmt_string& s = words[i]; 189 524 cerr << " `" + s + "'"; 190 525 if (s[0] == '-') continue; 191 526 … … 201 536 break; 202 537 case need_path: 203 path = s; 538 if (s.find ("(") != 0) 539 path = s; 204 540 state = no_need; 205 541 break; 206 542 } 207 543 } 208 544 cerr << endl; 545 546 if (package == "" || 547 package == "CMT" || 548 package == "cmt") 549 return; 550 append (package); 551 } 552 553 void SelectSubUses::append (const cmt_string& package) 554 { 555 if (m_first) 556 { 557 m_first = false; 558 m_result = "|" + package + "|"; 559 } 560 else 561 { 562 if (!has (package)) 563 m_result += package + "|"; 564 } 565 cerr << "m_result: " << m_result << endl; 566 } 567 568 bool SelectSubUses::has (const cmt_string& package) const 569 { 570 return (m_result.find ("|" + package + "|") != cmt_string::npos); 571 } 572 */ 573 574 //-------------------------------------------------------------------- 575 class Walkthru : public Awk 576 { 577 public: 578 Walkthru (IUseVisitor& visitor); 579 // RecursivePass2 (CvsImplementation& cvs); 580 void begin (); 581 void filter (const cmt_string& line); 582 583 private: 584 // CvsImplementation& m_cvs; 585 IUseVisitor& m_visitor; 586 }; 587 588 //-------------------------------------------------------------------- 589 Walkthru::Walkthru (IUseVisitor& visitor) 590 : m_visitor (visitor) 591 { 592 } 593 594 //-------------------------------------------------------------------- 595 void Walkthru::begin () 596 { 597 } 598 599 //-------------------------------------------------------------------- 600 void Walkthru::filter (const cmt_string& line) 601 { 602 CmtSystem::cmt_string_vector words; 603 604 CmtSystem::split (line, " \t", words); 605 606 enum 607 { 608 need_package, 609 need_version, 610 need_path, 611 no_need 612 } state = need_package; 613 614 cmt_string package; 615 cmt_string version; 616 cmt_string path; 617 // cerr << line; 618 for (int i = 1; i < words.size (); i++) 619 { 620 const cmt_string& s = words[i]; 621 // cerr << " `" + s + "'"; 622 if (s[0] == '-') continue; 623 624 switch (state) 625 { 626 case need_package: 627 package = s; 628 state = need_version; 629 break; 630 case need_version: 631 version = s; 632 state = need_path; 633 break; 634 case need_path: 635 if (s.find ("(") != 0 && s.find ("#") != 0) 636 path = s; 637 state = no_need; 638 break; 639 } 640 } 641 // cerr << endl; 642 643 if (package == "" || 644 package == "CMT" || 645 package == "cmt" || 646 package == CmtSystem::get_home_package () || 647 package == CmtSystem::get_user_context_package () 648 ) 649 return; 650 /* 209 651 if (version == "") 210 { 211 version = "*"; 212 } 213 214 if (version.find ("*") != cmt_string::npos && 215 !m_checkout.m_context) 216 { 217 /* 218 cerr << "# ================= Package " << package 219 << " version " << version << " " << path 220 << " has wild cards and will not be considered." << endl; 221 */ 652 version = "*"; 653 */ 654 655 if (version.find ("*") != cmt_string::npos) 656 { 657 // cerr << "# ================= Package " << package 658 // << " version " << version << " " << path 659 // << " has wild cards and will not be considered." << endl; 222 660 CmtMessage::warning (package + " " + version + 223 661 (path != "" ? " " + path : "") + 224 " has wildcards in version and will not be considered."); 662 ": Skipped due to wildcards in version." 663 " Consider using -C option."); 225 664 } 226 665 else 227 666 { 667 Use use_obj (package, version, path); 668 Use* use = &use_obj; 669 //use->set (name, version, path); 670 use->get_package ()->remove_use (use); 671 m_visitor.in (use); 228 672 // static const cmt_string empty; 229 673 // m_cvs.do_checkout_phase2 (path, package, version, empty); 230 cmt_string module ((path != "") ? path + "/" + package : package); 231 Vcs::checkout_module (m_checkout, 232 m_config, m_with_version_directory, 233 module, version, 234 m_type); 235 } 236 } 674 // cmt_string module ((path != "") ? path + "/" + package : package); 675 // Vcs::checkout_module (m_checkout, 676 // m_config, m_with_version_directory, 677 // module, version, 678 // m_type); 679 } 680 681 } 682 683 //-------------------------------------------------------------------- 237 684 238 685 /** … … 1180 1627 void add_cmtpath (const cmt_string& dir) 1181 1628 { 1629 return; 1182 1630 static cmt_string CMTPATH; 1183 1631 … … 3228 3676 } 3229 3677 3678 //-------------------------------------------------------------------- 3230 3679 void Vcs::help () 3231 3680 { … … 3238 3687 cerr << " -R Process used products recursively." << endl; 3239 3688 cerr << " -r rev Check out version tag. (is sticky)" << endl; 3689 cerr << " -C Determine version tag and/or package container from context." << endl; 3690 cerr << " -i Do not check out, show package(s) information only." << endl; 3240 3691 cerr << " -vd dir Use this version directory instead of version tag." << endl; 3241 3692 cerr << " -d dir Check out into dir instead of module name." << endl; … … 3257 3708 } 3258 3709 3710 //-------------------------------------------------------------------- 3259 3711 /** 3260 3712 * When running cmt cvs commands, we stand by definition outside of any existing … … 3262 3714 * This function manually prepends CMTPATH entries to the environment variable. 3263 3715 */ 3716 //-------------------------------------------------------------------- 3264 3717 void Vcs::add_cmtpath (const cmt_string& dir) 3265 3718 { … … 3293 3746 } 3294 3747 3748 //-------------------------------------------------------------------- 3295 3749 bool Vcs::need_version_directory () 3296 3750 { … … 3312 3766 } 3313 3767 3314 int Vcs::parse_checkout (const CmtSystem::cmt_string_vector& arguments, 3315 Checkout& checkout, bool& config) 3768 //-------------------------------------------------------------------- 3769 int Vcs::parse_arguments (const CmtSystem::cmt_string_vector& arguments, 3770 Checkout& checkout, bool& config) 3316 3771 { 3317 3772 if (arguments.size () < 1) … … 3420 3875 //m_head = false; 3421 3876 } 3877 else if (option == "-C") 3878 { 3879 checkout.m_context = true; 3880 } 3881 else if (option == "-i") 3882 { 3883 checkout.m_info = true; 3884 } 3422 3885 else if (option == "-d") 3423 3886 { … … 3470 3933 else 3471 3934 { 3935 if (option.size () == 0) 3936 { 3937 CmtMessage::warning ("Skipping bad module `" + 3938 option + "'"); 3939 continue; 3940 } 3472 3941 checkout.m_modules.push_back (option); 3473 3942 } … … 3497 3966 } 3498 3967 3968 //-------------------------------------------------------------------- 3969 class Modules 3970 { 3971 public: 3972 // Use::UsePtrVector m_packages; 3973 // cmt_vector<PackageInfo> m_packages; 3974 Use::UseVector m_packages; 3975 cmt_string m_uses; 3976 }; 3977 3978 //-------------------------------------------------------------------- 3979 int Vcs::parse_checkout (Checkout& checkout, 3980 Modules& modules) 3981 // cmt_string& uses) 3982 { 3983 int retval (0); 3984 3985 if (checkout.m_requirements != "") 3986 { 3987 if (!CmtSystem::test_file (checkout.m_requirements)) 3988 { 3989 CmtError::set (CmtError::path_not_found, checkout.m_requirements); 3990 ++retval; 3991 } 3992 else 3993 { 3994 cmt_string text; 3995 if (!text.read (checkout.m_requirements)) 3996 { 3997 CmtError::set (CmtError::file_access_error, checkout.m_requirements); 3998 ++retval; 3999 } 4000 else 4001 { 4002 modules.m_uses = text; 4003 } 4004 } 4005 } 4006 4007 const cmt_string& version_tag = checkout.m_version_tag; 4008 if (version_tag == "HEAD" || version_tag == "head" || 4009 version_tag == "TRUNK" || version_tag == "trunk") 4010 checkout.m_head = true; 4011 4012 cmt_string uses; 4013 for (int arg = 0; arg < checkout.m_modules.size (); arg++) 4014 { 4015 cmt_string use ("use"); 4016 cmt_string name = checkout.m_modules[arg]; 4017 cmt_string package; 4018 cmt_string version; 4019 cmt_string path; 4020 /* 4021 if (checkout.m_context) 4022 { 4023 name.replace_all ("//", "/"); 4024 } 4025 */ 4026 while (name.size () > 0 && name[name.size () - 1] == '/') 4027 name.erase (name.size () - 1); 4028 if (name.size () == 0) 4029 { 4030 CmtError::set (CmtError::syntax_error, "Bad module name `" + 4031 checkout.m_modules[arg] + "'"); 4032 CmtError::print (); 4033 continue; 4034 } 4035 4036 int pos = name.find_last_of ('/'); 4037 if (pos != cmt_string::npos) 4038 { 4039 package = name.substr (pos + 1); 4040 path = name.substr (0, pos); 4041 } 4042 else 4043 { 4044 package = name; 4045 } 4046 if (checkout.m_context) 4047 { 4048 if (version_tag == "" || path == "") 4049 { 4050 Packages& pkgs = Packages::instance (); 4051 //if (version_tag == "") - want to find 1) version 4052 // 2) path, if (path == "") 4053 // args: package, version_tag, path 4054 //if (path == "") - want to find 1) path 4055 // 2) version, if (version_tag == "") 4056 // args: package, "", path 4057 // package, "", path 4058 Use* p_use = pkgs.find (package, "", path); 4059 if (p_use == 0) 4060 { 4061 CmtError::set (CmtError::package_not_found, package + 4062 ": Context"); 4063 CmtError::print (); 4064 ++retval; 4065 continue; 4066 } 4067 // cerr << "Obtained: " << p_use->get_info () 4068 // << " " << p_use->real_path << endl; 4069 if (version_tag == "" ) 4070 version = p_use->version; 4071 else 4072 version = version_tag; 4073 4074 path = p_use->path; 4075 } 4076 if (!checkout.m_head) 4077 { 4078 use += " " + package + " " + version + " " + path + "\n"; 4079 CmtMessage::verbose (use); 4080 uses += use; 4081 } 4082 } // end of checkout.m_context 4083 else 4084 { 4085 version = version_tag; 4086 } 4087 { 4088 Use use_obj (package, version, path); 4089 Use* use = &use_obj; 4090 use->get_package ()->remove_use (use); 4091 modules.m_packages.push_back (use_obj); 4092 } 4093 } // end of for-loop over checkout.m_modules 4094 if (checkout.m_context) 4095 { 4096 resolve_uses (checkout, uses + modules.m_uses); 4097 } 4098 4099 return retval; 4100 } 4101 4102 //-------------------------------------------------------------------- 3499 4103 void Vcs::checkout (const CmtSystem::cmt_string_vector& arguments) 3500 4104 { … … 3524 4128 bool config (true); 3525 4129 Checkout checkout; 3526 parse_ checkout(arguments, checkout, config);4130 parse_arguments (arguments, checkout, config); 3527 4131 3528 4132 if (CmtError::has_pending_error ()) return; 3529 4133 3530 add_cmtpath (CmtSystem::pwd ()); 4134 // cmt_string uses; 4135 // parse_checkout (checkout, uses); 4136 Modules modules; 4137 parse_checkout (checkout, modules); 4138 // add_cmtpath (CmtSystem::pwd ()); 3531 4139 bool with_version_directory (need_version_directory ()); 3532 4140 /* … … 3537 4145 if (svnroot != "") 3538 4146 { 3539 Svn::checkout (checkout, config, with_version_directory);4147 Svn::checkout (checkout, modules, config, with_version_directory); 3540 4148 return; 3541 4149 } 3542 4150 } 3543 4151 3544 void Svn::checkout (Vcs::Checkout checkout, 4152 //-------------------------------------------------------------------- 4153 class VisitorForInfo : public IUseVisitor 4154 { 4155 public: 4156 VisitorForInfo () 4157 { 4158 } 4159 4160 void in (Use* use) 4161 { 4162 cmt_string p = use->real_path; 4163 if (use->path != "") 4164 { 4165 int pos = p.find_last_of (use->path); 4166 if (pos != cmt_string::npos) 4167 { 4168 p.erase (pos); 4169 } 4170 } 4171 4172 cout << use->get_package_name () 4173 << " " << use->version; 4174 4175 if (CmtSystem::absolute_path (use->path)) 4176 { 4177 if (!Cmt::get_quiet ()) 4178 { 4179 cout << " (" << use->path << ")"; 4180 } 4181 } 4182 else 4183 { 4184 if (use->path != "") cout << " " << use->path; 4185 } 4186 4187 if (!Cmt::get_quiet ()) 4188 { 4189 if (p != "") cout << " (" << p << ")"; 4190 } 4191 4192 cout << endl; 4193 } 4194 }; 4195 4196 //-------------------------------------------------------------------- 4197 class VisitorForCheckout : public IUseVisitor 4198 { 4199 public: 4200 VisitorForCheckout (const Vcs::Checkout& checkout, 4201 bool config, bool with_version_directory, 4202 Vcs::VcsType type) 4203 : m_checkout (checkout), 4204 m_config (config), m_with_version_directory (with_version_directory), 4205 m_type (type) 4206 { 4207 } 4208 4209 void in (Use* use) 4210 { 4211 cmt_string module ((use->path != "") ? use->path + "/" + use->get_package_name () : 4212 use->get_package_name ()); 4213 Vcs::checkout_module (m_checkout, 4214 m_config, m_with_version_directory, 4215 // module, version, 4216 module, 4217 use->version, 4218 m_type); 4219 } 4220 4221 private: 4222 const Vcs::Checkout& m_checkout; 4223 bool m_config; 4224 bool m_with_version_directory; 4225 Vcs::VcsType m_type; 4226 }; 4227 4228 //-------------------------------------------------------------------- 4229 void Svn::checkout (Vcs::Checkout checkout, Modules modules, 3545 4230 bool config, bool with_version_directory) 3546 4231 { … … 3560 4245 3561 4246 /** 4247 * Checkout packages found in context 4248 */ 4249 if (checkout.m_context) 4250 { 4251 Vcs::checkout_context (checkout, modules, 4252 config, with_version_directory, 4253 Vcs::Svn); 4254 if (!checkout.m_head) return; 4255 } 4256 4257 /** 3562 4258 * Call checkout for each command line argument 3563 4259 */ 4260 VisitorForInfo visitor_i; 4261 VisitorForCheckout visitor_co (checkout, 4262 config, with_version_directory, 4263 Vcs::Svn); 4264 for (int i = 0; i < modules.m_packages.size (); i++) 4265 { 4266 Use* use = &(modules.m_packages[i]); 4267 if (checkout.m_info) 4268 visitor_i.in (use); 4269 else 4270 visitor_co.in (use); 4271 } 4272 /* 3564 4273 for (int arg = 0; arg < checkout.m_modules.size (); arg++) 3565 4274 { … … 3572 4281 // do_checkout_phase1 (modules[arg], m_version_dir, version_tag); 3573 4282 } 4283 */ 4284 4285 if (checkout.m_context) return; 3574 4286 3575 4287 /** 3576 4288 * Call checkout for used package in requirements file 3577 4289 */ 3578 if (checkout.m_requirements != "") 4290 if (checkout.m_requirements != "" && 4291 modules.m_uses != "") 3579 4292 Vcs::checkout_from_requirements (checkout, 3580 4293 config, with_version_directory, … … 3583 4296 } 3584 4297 4298 //-------------------------------------------------------------------- 3585 4299 void Vcs::checkout_module (const Vcs::Checkout& checkout, 3586 4300 bool config, bool with_version_directory, 3587 c onst cmt_string&module, cmt_string version_tag,4301 cmt_string module, cmt_string version_tag, 3588 4302 Vcs::VcsType type) 3589 4303 { 3590 // cmt_string checkout_command;3591 // Symbol* checkout_command_macro = Symbol::find ("svn_checkout_command");3592 // if (checkout_command_macro != 0)3593 // {3594 // checkout_command = checkout_command_macro->resolve_macro_value ();3595 // }3596 // if (checkout_command == "")3597 // {3598 // CmtError::set (CmtError::symbol_not_found,3599 // "Macro svn_checkout_command not defined");3600 // return;3601 // }3602 if (checkout.m_context)3603 {3604 int i;3605 if (version_tag == "")3606 // version tag not specified on the command line3607 {3608 }3609 else if ((i = version_tag.find ("*")) != cmt_string::npos)3610 // version has wildcards (or not specified) in requirements3611 {3612 }3613 }3614 3615 4304 History& h = History::instance (); 3616 4305 cmt_string line (module + " " + version_tag); … … 3631 4320 cmd += " --without_version_directory"; 3632 4321 3633 if (version_tag != "") 4322 if (version_tag == "" || 4323 version_tag == "HEAD" || version_tag == "head" || 4324 version_tag == "TRUNK" || version_tag == "trunk" 4325 ) 4326 { 4327 msg += (version_tag == "" ? " (HEAD)" : " (" + version_tag + ")"); 4328 version_tag = ""; 4329 } 4330 else 3634 4331 { 3635 4332 cmd += " -r " + version_tag; 3636 4333 msg += " (" + version_tag + ")"; 3637 }3638 else3639 {3640 msg += " (HEAD)";3641 4334 } 3642 4335 if (checkout.m_offset != "") … … 3656 4349 * Then call checkout for the module 3657 4350 */ 3658 // for (int arg = 0; arg < checkout.m_modules.size (); arg++)3659 // {3660 // const cmt_string& module = checkout.m_modules[arg];3661 4351 CmtMessage::info ("Working on " + module + msg); 3662 4352 // cerr << cmd + " " + module << endl; … … 3665 4355 { 3666 4356 CmtMessage::info (module + " done."); 3667 if (checkout.m_recursive) 4357 if (checkout.m_recursive && !checkout.m_context) 4358 // if (checkout.m_recursive) 3668 4359 { 3669 4360 cmt_string requirements; … … 3694 4385 { // checkout of trunk 3695 4386 // 3696 staticCmtSystem::cmt_string_vector versions;3697 staticcmt_string name;4387 CmtSystem::cmt_string_vector versions; 4388 cmt_string name; 3698 4389 3699 4390 name = requirements; … … 3750 4441 if (n < 1) 3751 4442 { 3752 CmtMessage::error ("Cannot find package in " + 3753 requirements + 3754 " for recursion"); 4443 CmtMessage::error ("Cannot find package for recursion" 4444 " in " + requirements); 3755 4445 CmtError::set (CmtError::package_not_found, 3756 4446 "in " + requirements); … … 3760 4450 } 3761 4451 } // end of with_version_directory 3762 cmt_string cmt_req = requirements + 4452 cmt_string 4453 cmt_req = requirements + 3763 4454 CmtSystem::file_separator () + 3764 4455 "cmt" + 3765 4456 CmtSystem::file_separator () + 3766 4457 "requirements"; 3767 cmt_string mgr_req = requirements + 4458 cmt_string 4459 mgr_req = requirements + 3768 4460 CmtSystem::file_separator () + 3769 4461 "mgr" + … … 3797 4489 } 3798 4490 4491 //-------------------------------------------------------------------- 4492 static void visit (const Use::UsePtrVector& uses, IUseVisitor& visitor) 4493 { 4494 for (int i = 0; i < uses.size (); i++) 4495 { 4496 Use* use = uses[i]; 4497 if (use == 0) continue; 4498 if (use->selected) continue; 4499 use->selected = true; 4500 if (use->discarded) continue; 4501 if (use->m_hidden) continue; 4502 if (!use->located ()) continue; 4503 if (use->get_package_name () == "CMT") continue; 4504 if (use->get_package_name () == "cmt_standalone") continue; 4505 if (use->get_package_name () == CmtSystem::get_home_package ()) continue; 4506 if (use->get_package_name () == CmtSystem::get_user_context_package ()) continue; 4507 4508 // visitor.in (use); 4509 visit (use->sub_uses, visitor); 4510 visitor.in (use); 4511 } 4512 } 4513 4514 //-------------------------------------------------------------------- 4515 void Vcs::checkout_context (const Vcs::Checkout& checkout, Modules modules, 4516 bool config, bool with_version_directory, 4517 Vcs::VcsType type) 4518 { 4519 VisitorForInfo visitor_i; 4520 VisitorForCheckout visitor_co (checkout, 4521 config, with_version_directory, 4522 type); 4523 4524 Use* current = &(Use::current ()); 4525 if (checkout.m_info) 4526 visit (current->sub_uses, visitor_i); 4527 else 4528 visit (current->sub_uses, visitor_co); 4529 4530 } 4531 4532 //-------------------------------------------------------------------- 4533 int Vcs::resolve_uses (const cmt_string& text, cmt_string& uses) 4534 { 4535 cerr << "Vcs::resolve_uses" << endl; 4536 cmt_string home_dir = CmtSystem::pwd (); 4537 // 4538 // Resolve uses by creating a package in a temporary directory 4539 // 4540 cmt_string tmp_dir = CmtSystem::getenv ("TMPDIR"); 4541 if (tmp_dir == "") 4542 { 4543 tmp_dir = CmtSystem::file_separator (); 4544 tmp_dir += "tmp"; 4545 } 4546 4547 if (!CmtSystem::test_directory (tmp_dir)) 4548 //if (!CmtSystem::cd (tmp_dir)) 4549 { 4550 tmp_dir = home_dir; 4551 } 4552 4553 tmp_dir += CmtSystem::file_separator (); 4554 tmp_dir += "cmtvcs"; 4555 cmt_string temp = CmtSystem::get_temporary_name (); 4556 CmtSystem::basename (temp, temp); 4557 // Suppress dots for Windows 4558 temp.replace_all (".", ""); 4559 tmp_dir += temp; 4560 4561 cerr << "tmp_dir: " << tmp_dir << endl; 4562 // tmp_dir = "/tmp/cmtvcsfileEvmagO"; 4563 4564 if (CmtSystem::test_directory (tmp_dir)) 4565 { 4566 if (!CmtSystem::remove_directory (tmp_dir)) 4567 { 4568 // CmtMessage::error ("Cannot remove temporary directory " + tmp_dir); 4569 // error message printed by CmtSystem::remove_directory 4570 return 1; 4571 } 4572 } 4573 if (!CmtSystem::mkdir (tmp_dir)) 4574 { 4575 CmtMessage::error ("Cannot create temporary directory " + tmp_dir); 4576 return 1; 4577 } 4578 4579 cmt_string pkgspec (temp + " v1 " + tmp_dir); 4580 if (0 != CmtSystem::execute ("cmt -without_version_directory create " + pkgspec)) 4581 // if (0 != CmtSystem::execute ("cmt -with_version_directory create " + pkg)) 4582 { 4583 CmtMessage::error ("Cannot create package " + pkgspec); 4584 CmtSystem::remove_directory (tmp_dir); 4585 return 1; 4586 } 4587 4588 cmt_string cmt_dir (tmp_dir + 4589 CmtSystem::file_separator () + temp + 4590 // CmtSystem::file_separator () + "v1" + 4591 CmtSystem::file_separator () + "cmt"); 4592 4593 cmt_string reqtext; 4594 cmt_string requirements (cmt_dir + 4595 CmtSystem::file_separator () + "requirements"); 4596 if (!reqtext.read (requirements)) 4597 { 4598 CmtError::set (CmtError::file_access_error, requirements); 4599 CmtSystem::remove_directory (tmp_dir); 4600 return 1; 4601 } 4602 4603 FILE* file = fopen (requirements, "wb"); 4604 if (file != NULL) 4605 { 4606 (reqtext + text).write (file); 4607 CmtSystem::close_ostream (file, requirements); 4608 // fclose (file); 4609 } 4610 else 4611 { 4612 CmtError::set (CmtError::file_access_error, requirements); 4613 CmtSystem::remove_directory (tmp_dir); 4614 return 1; 4615 } 4616 4617 if (!CmtSystem::cd (cmt_dir)) 4618 { 4619 CmtMessage::error ("Cannot move to temporary package directory " + cmt_dir); 4620 CmtSystem::remove_directory (tmp_dir); 4621 return 1; 4622 } 4623 4624 int status = CmtSystem::execute ("cmt show uses", uses); 4625 // cerr << "status: " << status << endl; 4626 if (status != 0) 4627 { 4628 CmtMessage::error ("Cannot show uses for package " + pkgspec); 4629 } 4630 // cerr << "uses:\n" + uses << endl; 4631 CmtSystem::cd (home_dir); 4632 CmtSystem::remove_directory (tmp_dir); 4633 return status == 0 ? 0 : -1; 4634 } 4635 4636 //-------------------------------------------------------------------- 4637 int Vcs::resolve_uses (const cmt_string& text, Use::UsePtrVector& uses) 4638 { 4639 cerr << "Vcs::resolve_uses NEW" << endl; 4640 cmt_string home_dir = CmtSystem::pwd (); 4641 4642 Use* current = &(Use::current()); 4643 4644 SyntaxParser::parse_requirements_text (text, "", current); 4645 4646 cerr << "recursive: " << Cmt::get_recursive () << endl; 4647 4648 Use::show_all (); 4649 4650 if (CmtError::get_last_error_code () == CmtError::package_not_found) 4651 CmtError::print (); 4652 4653 return -1; 4654 } 4655 4656 //-------------------------------------------------------------------- 4657 int Vcs::resolve_uses (const Checkout& checkout, const cmt_string& uses) 4658 //int Vcs::resolve_uses (const Checkout& checkout, const Modules& modules) 4659 { 4660 if (!checkout.m_context) return 0; 4661 4662 // cerr << "Vcs::resolve_uses NEW+" << endl; 4663 cmt_string home_dir = CmtSystem::pwd (); 4664 // 4665 // Resolve uses by creating a package in a temporary directory 4666 // 4667 cmt_string tmp_dir = CmtSystem::getenv ("TMPDIR"); 4668 if (tmp_dir == "") 4669 { 4670 tmp_dir = CmtSystem::file_separator (); 4671 tmp_dir += "tmp"; 4672 } 4673 4674 if (!CmtSystem::test_directory (tmp_dir)) 4675 //if (!CmtSystem::cd (tmp_dir)) 4676 { 4677 tmp_dir = home_dir; 4678 } 4679 4680 tmp_dir += CmtSystem::file_separator (); 4681 tmp_dir += "cmtvcs"; 4682 cmt_string temp = CmtSystem::get_temporary_name (); 4683 CmtSystem::basename (temp, temp); 4684 // Suppress dots for Windows 4685 temp.replace_all (".", ""); 4686 tmp_dir += temp; 4687 4688 if (CmtSystem::test_directory (tmp_dir)) 4689 { 4690 if (!CmtSystem::remove_directory (tmp_dir)) 4691 { 4692 CmtError::set (CmtError::file_access_error, tmp_dir); 4693 // CmtMessage::error ("Cannot remove temporary directory " + tmp_dir); 4694 // error message printed by CmtSystem::remove_directory 4695 return 1; 4696 } 4697 } 4698 if (!CmtSystem::mkdir (tmp_dir)) 4699 { 4700 CmtError::set (CmtError::file_access_error, 4701 "Cannot create temporary directory " + tmp_dir); 4702 CmtError::print (); 4703 //CmtMessage::error ("Cannot create temporary directory " + tmp_dir); 4704 return 1; 4705 } 4706 4707 if (!CmtSystem::cd (tmp_dir)) 4708 { 4709 CmtError::set (CmtError::file_access_error, 4710 "Cannot move to temporary package directory " + tmp_dir); 4711 CmtError::print (); 4712 //CmtMessage::error ("Cannot move to temporary package directory " + tmp_dir); 4713 CmtSystem::remove_directory (tmp_dir); 4714 return 1; 4715 } 4716 4717 Project::ProjectPtrVector& Ordered = Project::ordered_projects (); 4718 int i (-1); 4719 Project* cur (0); 4720 Project null; 4721 for (i = 0; i < Ordered.size (); i++) 4722 if (Ordered[i]->is_current ()) break; 4723 if (i >= 0 && i < Ordered.size ()) 4724 { 4725 cur = Ordered[i]; 4726 Ordered[i] = &null; 4727 } 4728 4729 bool cur_recursive (Cmt::get_recursive ()); 4730 CmtScopeFilteringMode 4731 cur_scope_filtering_mode (Cmt::get_scope_filtering_mode ()); 4732 if (checkout.m_recursive) 4733 { 4734 Cmt::set_recursive (true); 4735 Cmt::set_scope_filtering_mode (reach_private_uses); 4736 } 4737 4738 SyntaxParser::parse_requirements_text (uses, "", &(Use::current())); 4739 4740 if (checkout.m_recursive) 4741 { 4742 Cmt::set_recursive (cur_recursive); 4743 Cmt::set_scope_filtering_mode (cur_scope_filtering_mode); 4744 } 4745 4746 if (i >= 0 && i < Ordered.size ()) 4747 { 4748 Ordered[i] = cur; 4749 } 4750 4751 CmtSystem::cd (home_dir); 4752 CmtSystem::remove_directory (tmp_dir); 4753 4754 if (CmtError::get_last_error_code () == CmtError::package_not_found) 4755 { 4756 CmtError::print (); 4757 return -1; 4758 } 4759 4760 return 0; 4761 } 4762 4763 //-------------------------------------------------------------------- 3799 4764 void Vcs::checkout_from_requirements (const Vcs::Checkout& checkout, 3800 4765 bool config, … … 3808 4773 if (!text.read (requirements)) 3809 4774 { 3810 CmtError::set (CmtError:: path_not_found, requirements);4775 CmtError::set (CmtError::file_access_error, requirements); 3811 4776 return; 3812 4777 } 4778 3813 4779 static cmt_regexp expression ("^[ \t]*use[ \t]"); 3814 3815 // RecursivePass1 p1; 3816 // p1.run (text, expression); 3817 // bool result = (p1.result () != ""); 3818 // if (result) 3819 // cerr << p1.result () << endl; 3820 Walkthru wth (checkout, 3821 config, 3822 with_version_directory, 3823 type); 3824 wth.run (text, expression); 3825 } 4780 if (checkout.m_info) 4781 { 4782 VisitorForInfo visitor_i; 4783 Walkthru wth (visitor_i); 4784 wth.run (text, expression); 4785 } 4786 else 4787 { 4788 VisitorForCheckout visitor_co (checkout, 4789 config, with_version_directory, 4790 type); 4791 Walkthru wth (visitor_co); 4792 wth.run (text, expression); 4793 } 4794 } 4795 //-------------------------------------------------------------------- -
CMT/HEAD/source/cmt_vcs.h
r534 r535 9 9 10 10 #include "cmt_system.h" 11 #include "cmt_use.h" 11 12 13 class Modules; 12 14 class Vcs 13 15 { … … 32 34 public: 33 35 Checkout () 34 : m_ recursive (false), m_context(false)36 : m_head (false), m_recursive (false), m_context (false), m_info (false) 35 37 { } 36 38 cmt_string m_version_tag; 39 bool m_head; 37 40 cmt_string m_checkout_dir; 38 41 cmt_string m_version_dir; … … 43 46 bool m_recursive; 44 47 bool m_context; 48 bool m_info; 45 49 void print () 46 50 { 47 51 cerr << "m_version_tag: " << m_version_tag << endl; 52 cerr << "m_head: " << m_head << endl; 48 53 cerr << "m_checkout_dir: " << m_checkout_dir << endl; 49 54 cerr << "m_version_dir: " << m_version_dir << endl; … … 62 67 static void checkout_module (const Checkout& checkout, 63 68 bool config, bool with_version_directory, 64 c onst cmt_string&module, cmt_string version_tag,69 cmt_string module, cmt_string version_tag, 65 70 VcsType type); 66 71 static void checkout_from_requirements (const Checkout& checkout, … … 68 73 const cmt_string& requirements, 69 74 VcsType type); 75 static void checkout_context (const Checkout& checkout, Modules modules, 76 bool config, bool with_version_directory, 77 VcsType type); 70 78 71 79 private: … … 74 82 static void add_cmtpath (const cmt_string& dir); 75 83 static bool need_version_directory (); 76 static int parse_checkout (const CmtSystem::cmt_string_vector& arguments, 77 Checkout& checkout, bool& config); 84 static int parse_arguments (const CmtSystem::cmt_string_vector& arguments, 85 Checkout& checkout, bool& config); 86 static int parse_checkout (Checkout& checkout, Modules& modules); 87 // static int parse_checkout (const Checkout& checkout, cmt_string& uses); 88 static int resolve_uses (const cmt_string& text, cmt_string& uses); 89 static int resolve_uses (const cmt_string& text, Use::UsePtrVector& uses); 90 static int resolve_uses (const Checkout& checkout, const cmt_string& uses); 91 // static int resolve_uses (const Checkout& checkout, const Modules& modules); 92 // static void start_visit (IUseVisitor& visitor); 78 93 }; 79 94 … … 82 97 public: 83 98 84 static void checkout (Vcs::Checkout checkout, 99 static void checkout (Vcs::Checkout checkout, Modules modules, 85 100 bool config, bool with_version_directory); 86 101 }; 87 102 103 class IUseVisitor 104 { 105 public: 106 //virtual void pre (Project* p) = 0; 107 virtual void in (Use* use) = 0; 108 //virtual void in_again (Project* p) = 0; 109 //virtual void post (Project* p) = 0; 110 }; 111 88 112 #endif -
CMT/HEAD/src/Makefile.core
r483 r535 76 76 ifdef cmtmsg 77 77 export cmtmsg 78 echo = @ -echo "$(CMTMSGPREFIX)"78 echo = @echo "$(CMTMSGPREFIX)" 79 79 else 80 80 echo = @: -
CMT/HEAD/src/Makefile.header
r527 r535 42 42 $(MAKE) --no-print-directory target="all" common_target; \ 43 43 else \ 44 echo "#CMT> There are configuration errors. Please correct them before running gmake"; \ 44 test -z "$(cmtmsg)" || \ 45 echo "$(CMTMSGPREFIX)" "(Makefile.header) Configuration error(s). Please correct" >&2; \ 45 46 fi 46 47 … … 53 54 test -z "$(cmtmsg)" || \ 54 55 echo "$(CMTMSGPREFIX)" "(Makefile.header) Removing binary directory $(bin)"; \ 55 /bin/rm -rf $(bin) ; \56 \rm -rf $(bin) ; \ 56 57 fi ; \ 57 58 fi
Note: See TracChangeset
for help on using the changeset viewer.