Changeset 44
- Timestamp:
- Apr 30, 2005, 10:03:05 AM (19 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/mgr/VisualC.nmake
r42 r44 64 64 cmt_installdir_excludes=$(CMTROOT)\mgr\cmt_installdir_excludes.txt 65 65 mkdir=mkdir 66 cmt_cvs_protocol_level=v1r1 66 67 cmt_installarea_prefix=InstallArea 67 68 CMT_PATH_remove_regexp=\\[^\\]*\\ -
CMT/HEAD/mgr/cmt.nmake
r42 r44 3 3 # Application cmt 4 4 # 5 # Generated Mon Apr 25 12:01:502005 by ARNAULT5 # Generated Tue Apr 26 22:57:13 2005 by ARNAULT 6 6 # 7 7 #==================================== -
CMT/HEAD/mgr/cmt_dependencies.nmake
r20 r44 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" 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" 19 cmt_cvs_cxx_dependencies = "..\source\cmt_cvs.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_awk.h" 19 cmt_cvs_cxx_dependencies = "..\source\cmt_cvs.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_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" 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_cvs.cxx
r43 r44 206 206 } 207 207 208 /** 209 Filter out the space-separated words of a text that don't match a regexp. 210 */ 208 211 void filter_list (cmt_string& text, const cmt_regexp& exp) 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 212 { 213 CmtSystem::cmt_string_vector list; 214 215 CmtSystem::split (text, " ", list); 216 217 int i; 218 219 text = ""; 220 221 for (i = 0; i < list.size (); i++) 222 { 223 const cmt_string& s = list[i]; 224 if (exp.match (s)) 225 { 226 if (i > 0) text += " "; 227 text += s; 228 } 229 } 230 } 228 231 229 232 /** … … 244 247 In this function we'll detect if the effective protocol level satisifies the 245 248 level expected for this release of CMT 249 250 In simulation mode we suppose the expected protocol has been found. 246 251 */ 247 252 bool check_protocol () … … 306 311 } 307 312 313 /** 314 Execute the CVS command that activates the CVS pluggin, ie this is a cvs import 315 using the conventional module .cmtcvsinfos/<protocol-level>/<module> 316 317 We create a temporary directory just to lauch the command. However nothing 318 should change in this temporary directory since the pluggin returns an error status. 319 */ 308 320 void retreive_cvs_infos (const cmt_string& module) 309 321 { … … 332 344 cmt_string temp = CmtSystem::get_temporary_name (); 333 345 CmtSystem::basename (temp, temp); 346 // Suppress dots for Windows 334 347 temp.replace_all (".", ""); 335 348 tmp_dir += temp; … … 370 383 # 371 384 # The script associated to such entries is supposed to : 372 # 1) extract the set of <infos> from the ${module}/cmt/requirements file 385 # 1) extract the set of <infos> from ${module}/cmt/requirements 386 # or ${module}/cmt/project.cmt 373 387 # 2) build an output of the form : 374 388 # <infos>=info1 info2 info3 ... … … 378 392 # ${CMTROOT}/cmt/cmt_buildcvsinfos2.sh 379 393 # %CMTROOT%/cmt/cmt_buildcvsinfos.py 394 # There is a C++ implementation as cmtcvs.exe 380 395 # 381 396 */ … … 435 450 } 436 451 437 //438 //This method exploits the hook installed into the loginfo script.439 //A communication is setup with a dummy CVS module named .cmtcvsinfos/<module>440 //441 //At import time, the contents of the file will be used to parameterize442 //the script named cmt_buildcvsinfos2.sh (referenced in the loginfo script)443 //444 //This script performs a scan in the CVS repository for the following types of445 //information :446 //447 //the recognized structure below this module (none, project, package)448 //all top symbolic tags installed for the module449 //all symbolic tags installed for the module450 //all branches available below this module451 //all subpackages installed below the module.452 //all subprojects installed below the module.453 //454 // In principle, only modules corresponding to true CMT packages are considered.455 // o tags are obtained from the requirementsfile456 //o branches are sub-directories which are not themselves packages457 //o subpackages are sub-directories which are CMT packages458 //(a subdirectory is always either a branch or a subpackage)459 //452 /** 453 This method exploits the hook installed into the loginfo script. 454 A communication is setup with a dummy CVS module named .cmtcvsinfos/<module> 455 456 At import time, the contents of the file will be used to parameterize 457 the script named cmt_buildcvsinfos2.sh (referenced in the loginfo script) 458 459 This script performs a scan in the CVS repository for the following types of 460 information : 461 462 the recognized structure below this module (none, project, package) 463 all top symbolic tags installed for the module 464 all symbolic tags installed for the module 465 all branches available below this module 466 all subpackages installed below the module. 467 all subprojects installed below the module. 468 469 In principle, only modules corresponding to true CMT packages or projects are considered. 470 o tags are obtained from the requirements or the project file 471 o branches are sub-directories which are not themselves packages 472 o subpackages are sub-directories which are CMT packages 473 (a subdirectory is always either a branch or a subpackage) 474 */ 460 475 void show_cvs_infos (const cmt_string& module) 461 476 { … … 599 614 600 615 grep.run (m_last_cvs_infos, "subprojects="); 601 616 602 617 if (grep.result () != "") 603 618 { … … 610 625 } 611 626 627 /** 628 The CMTCVSTAGFILTER env. var. may contain a regexp that will exclude some tags 629 from the answr of the CVS pluggin. 630 The pattern is a regexp but it may also contain the <package> template 631 */ 612 632 cmt_string tag_filter = CmtSystem::getenv ("CMTCVSTAGFILTER"); 613 633 … … 661 681 } 662 682 663 //664 // Resolve all possible "aaa/bbb/../ccc/ddd" patterns into "aaa/ccc/ddd"665 //666 void filter_dir (cmt_string& d)667 {668 while (true)669 {670 int pos = d.find ("/../");671 if (pos == cmt_string::npos) break;672 673 int slash = d.find ("/");674 if (slash < pos)675 {676 //677 // xxxxx/yyy/../zzzz -> xxxxx/zzzz678 // 01234567890123456679 // 1234567680 // pos = 9681 // slash = 5682 // length = 9+3-5683 //684 d.erase (slash + 1, pos + 3 - slash);685 }686 else687 {688 //689 // yyy/../zzzz -> zzzz690 // 01234567890691 // 1234567692 // pos = 3693 // length = 3+1+3694 //695 d.erase (0, pos + 1 + 3);696 }697 }698 }699 700 683 /** 701 684 From a space-separated list of version tags, try to find one tag … … 709 692 const cmt_regexp& version_exp, 710 693 cmt_string& version) 711 712 694 { 695 CmtSystem::cmt_string_vector vs; 713 696 714 715 716 717 718 719 720 697 CmtSystem::split (text, " \t", vs); 698 699 version = ""; 700 701 for (int i = 0; i < vs.size (); i++) 702 { 703 const cmt_string& vv = vs[i]; 721 704 722 723 724 725 726 727 728 729 730 705 if (version_exp.match (vv)) 706 { 707 version = vv; 708 return (true); 709 } 710 } 711 712 return (false); 713 } 731 714 732 715 bool get_version (const cmt_string& prefix, … … 736 719 cmt_string& version, 737 720 bool& at_head) 738 739 740 741 742 743 744 721 { 722 Grep grep; 723 cmt_string topversions; 724 cmt_string versions; 725 cmt_string requested_version = version_request; 726 727 at_head = false; 745 728 746 module = ""; 747 748 if (prefix != "") 749 { 750 module = prefix; 751 module += "/"; // This is for CVS only thus we don't use the real separator. 752 while (module.find ("//") != cmt_string::npos) 753 { 754 module.replace_all ("//", "/"); 755 } 756 } 757 758 module += package; 759 760 /** 761 * Try to figure out what is the effective version tag available 762 * for the requested version expressions (which may contain 763 * wild card) 764 * 765 * the requested version may either be in the top tags (ie those 766 * corresponding to the same most recent CVS version number before 767 * the HEAD) or not. The returned at_head flag will show this. 768 * 769 * then the requested package may either be located in the CVS repository 770 * under the prefix or not, the returned module will contain the effective 771 * location where the requested version has been found. 772 */ 773 774 if (m_verbose) 775 { 776 cout << "#CMT> requesting cvs infos onto module " << module << endl; 777 } 778 779 show_cvs_infos (module); 780 781 if (error_info != "") 782 { 783 versions = ""; 784 cout << "#CMT> Package " << package << " not found in ${CVSROOT}" << endl; 785 return (false); 786 } 787 788 versions = tags_top_info; 789 790 cmt_string v = version_request; 791 792 if (version_request.find ("*") != cmt_string::npos) 793 { 794 v.replace_all ("*", ".*"); 795 } 796 else 797 { 798 v += "$"; 799 } 800 801 if (m_cmtcvstest) cout << "## (version expression is " << v << ")" << endl; 802 803 cmt_regexp version_exp (v); 804 805 if (!match_version_request (versions, version_exp, version)) 806 { 807 if (m_cmtcvstest) cout << "## (no match in " << versions << ")" << endl; 808 809 // We try on non-top versions 810 811 versions = tags_info; 812 813 if (!match_version_request (versions, version_exp, version)) 814 { 815 if (m_cmtcvstest) cout << "## (no match in " << versions << ")" << endl; 816 817 version = requested_version; 818 int pos = 0; 819 if ((pos = version.find ("*")) != cmt_string::npos) 820 { 821 // 822 // There was a wild card but the expression does not match 823 // any of the existing tags in CVS. 824 // Things will be retreived from HEAD but we have to build 825 // a reasonable version tag from the wild card expression. 826 // If the letter before the * was a digit, then simply remove 827 // the * (v5* -> v5) otherwise add a zero (v5r* -> v5r0) 828 // 829 if (pos > 0) 830 { 831 char letter = version[pos-1]; 832 833 static const cmt_string digits = "0123456789"; 834 835 if (digits.find (letter) == cmt_string::npos) 836 { 837 // "v5r*" -> "v5r0" 838 version.replace ("*", "0"); 839 } 840 else 841 { 842 // "v5*" -> "v5" 843 version.replace ("*", ""); 844 } 845 } 846 else 847 { 848 // The expression was simply "*" !!! 849 version = "v0"; 850 } 851 } 852 at_head = true; 853 } 854 else 855 { 856 if (m_cmtcvstest) cout << "## (match in non head " << versions << ")" << endl; 857 858 at_head = false; 859 } 860 } 861 else 862 { 863 if (m_cmtcvstest) cout << "## (match in head " << versions << ")" << endl; 864 865 at_head = true; 866 } 867 868 /** 869 * Here we have at least one version matching the requested expression. 870 */ 871 872 return (true); 873 } 729 module = ""; 730 731 if (prefix != "") 732 { 733 module = prefix; 734 module += "/"; // This is for CVS only thus we don't use the real separator. 735 while (module.find ("//") != cmt_string::npos) 736 { 737 module.replace_all ("//", "/"); 738 } 739 } 740 741 module += package; 742 743 /** 744 * Try to figure out what is the effective version tag available 745 * for the requested version expressions (which may contain 746 * wild card) 747 * 748 * the requested version may either be in the top tags (ie those 749 * corresponding to the same most recent CVS version number before 750 * the HEAD) or not. The returned at_head flag will show this. 751 * 752 * then the requested package may either be located in the CVS repository 753 * under the prefix or not, the returned module will contain the effective 754 * location where the requested version has been found. 755 */ 756 757 if (m_verbose) 758 { 759 cout << "#CMT> requesting cvs infos onto module " << module << endl; 760 } 761 762 show_cvs_infos (module); 763 764 if (error_info != "") 765 { 766 versions = ""; 767 cout << "#CMT> Package " << package << " not found in ${CVSROOT}" << endl; 768 return (false); 769 } 770 771 versions = tags_top_info; 772 773 cmt_string v = version_request; 774 775 if (version_request.find ("*") != cmt_string::npos) 776 { 777 v.replace_all ("*", ".*"); 778 } 779 else 780 { 781 // this is an exact match to the end of the word since there is no wild card 782 v += "$"; 783 } 784 785 if (m_cmtcvstest) cout << "## (version expression is " << v << ")" << endl; 786 787 cmt_regexp version_exp (v); 788 789 if (!match_version_request (versions, version_exp, version)) 790 { 791 if (m_cmtcvstest) cout << "## (no match in " << versions << ")" << endl; 792 793 // We try on non-top versions 794 795 versions = tags_info; 796 797 if (!match_version_request (versions, version_exp, version)) 798 { 799 if (m_cmtcvstest) cout << "## (no match in " << versions << ")" << endl; 800 801 version = requested_version; 802 int pos = 0; 803 if ((pos = version.find ("*")) != cmt_string::npos) 804 { 805 // 806 // There was a wild card but the expression does not match 807 // any of the existing tags in CVS. 808 // Things will be retreived from HEAD but we have to build 809 // a reasonable version tag from the wild card expression. 810 // If the letter before the * was a digit, then simply remove 811 // the * (v5* -> v5) otherwise add a zero (v5r* -> v5r0) 812 // 813 if (pos > 0) 814 { 815 char letter = version[pos-1]; 816 817 static const cmt_string digits = "0123456789"; 818 819 if (digits.find (letter) == cmt_string::npos) 820 { 821 // "v5r*" -> "v5r0" 822 version.replace ("*", "0"); 823 } 824 else 825 { 826 // "v5*" -> "v5" 827 version.replace ("*", ""); 828 } 829 } 830 else 831 { 832 // The expression was simply "*" !!! 833 version = "v0"; 834 } 835 } 836 at_head = true; 837 } 838 else 839 { 840 if (m_cmtcvstest) cout << "## (match in non head " << versions << ")" << endl; 841 842 at_head = false; 843 } 844 } 845 else 846 { 847 if (m_cmtcvstest) cout << "## (match in head " << versions << ")" << endl; 848 849 at_head = true; 850 } 851 852 /** 853 * Here we have at least one version matching the requested expression. 854 */ 855 856 return (true); 857 } 874 858 875 859 cmt_string build_version_directory (const cmt_string& prefix, … … 901 885 } 902 886 887 /** 888 Specific checkout of one project 889 */ 903 890 bool really_checkout_project_contents (const cmt_string& prefix, 904 891 const cmt_string& project, … … 979 966 } 980 967 968 /** 969 Specific checkout of one package 970 971 1) get top files (no directories) 972 2) construct the directory structure (with or without version directory) 973 3) build the CVS/Entries file for subdirs and co individual subdirs 974 4) write the CVS management files if CVS did not do it. 975 */ 981 976 bool really_checkout_package_contents (const cmt_string& prefix, 982 977 const cmt_string& package, … … 1331 1326 } 1332 1327 1333 bool really_checkout_package (const cmt_string& prefix, 1334 const cmt_string& package, 1335 const cmt_string& version, 1336 const cmt_string& module, 1337 const cmt_string& basedir, 1338 bool at_head) 1328 /** 1329 Effective checkout of a package or a project 1330 */ 1331 bool really_checkout (const cmt_string& prefix, 1332 const cmt_string& package, 1333 const cmt_string& version, 1334 const cmt_string& module, 1335 const cmt_string& basedir, 1336 bool at_head) 1339 1337 { 1340 1338 cmt_string dir = basedir; … … 1477 1475 return (result); 1478 1476 } 1479 1480 void checkout_package (const cmt_string& prefix,1481 const cmt_string& package,1482 const cmt_string& specified_version)1483 {1484 if (m_verbose)1485 {1486 cout << "#CMT> checkout_package> prefix=" << prefix1487 << " " << structure_info << "=" << package1488 << " specified_version=" << specified_version1489 << endl;1490 }1491 1492 cmt_string version = specified_version;1493 cmt_string empty;1494 cmt_string full_prefix;1495 1496 full_prefix = m_offset;1497 full_prefix += prefix;1498 1499 cmt_string echo_ppath;1500 1501 if (prefix != "")1502 {1503 echo_ppath = " path ";1504 echo_ppath += prefix;1505 }1506 1507 if (version == "")1508 {1509 cout << "# ================= No version specified for " << structure_info << " " << package << endl;1510 return;1511 }1512 1513 //1514 // First make an attempt to locate the specified version of1515 // this package "as-it-is" in the work area.1516 // Since 'version' may contain wild-card, it's likely that1517 // we should not simply use CmtSystem::test_directory but1518 // use the wild-card search.1519 //1520 1521 cmt_string dir;1522 1523 dir = build_version_directory (prefix, package, version);1524 1525 if (m_cmtcvstest)1526 cout << "## (testing dir= " << dir << ")" << endl;1527 1528 bool recursive = m_recursive;1529 1530 /*1531 if (m_cmtcvstest)1532 {1533 cmt_string v = find_matching_version (dir);1534 1535 cout << "---> v=" << v << endl;1536 }1537 */1538 1539 cmt_string effective_version = find_matching_version (dir);1540 1541 if (effective_version != "")1542 {1543 version = effective_version;1544 1545 dir = build_version_directory (prefix, package, version);1546 1547 cout << "# ================= " << structure_info << " " << package1548 << " version " << version << echo_ppath1549 << " already installed in " << dir << endl;1550 1551 recursive = false;1552 }1553 else1554 {1555 bool at_head = false;1556 cmt_string module;1557 1558 //1559 // get_version attempts to find the most appropriate version1560 // tag matching the specification FROM the repository. However,1561 // we should take into account situations where some versions have1562 // already been checked out, in which case they might be sufficient1563 // (or preferred?)1564 //1565 1566 if (version.find ("*") != cmt_string::npos)1567 {1568 cout << "# ================= " << structure_info << " " << package1569 << " version " << version << echo_ppath1570 << " has wild cards and will not be considered." << endl;1571 return;1572 }1573 1574 if (!get_version (full_prefix, package, version,1575 module, version, at_head))1576 {1577 return;1578 }1579 1580 //cout << " full_prefix=[" << full_prefix << "] module=[" << module << "]" << endl;1581 1582 if (m_cmtcvstest) cout << "## after get_version at_head=" << at_head << " m_head=" << m_head << endl;1583 1584 if (m_head)1585 {1586 m_head = false;1587 1588 at_head = true;1589 }1590 else1591 {1592 at_head = false;1593 }1594 1595 //1596 // Make a second try after having selected a version from all the1597 // available versions compatible with the specified version1598 //1599 1600 dir = build_version_directory (prefix, package, version);1601 1602 if (CmtSystem::test_directory (dir))1603 {1604 cout << "# ================= " << structure_info << " " << package1605 << " version " << version << echo_ppath1606 << " already installed." << endl;1607 1608 recursive = false;1609 }1610 else1611 {1612 //1613 // Now we can say that we have to perform the real checkout.1614 //1615 1616 if (!really_checkout_package (prefix, package, version, module, dir, at_head))1617 {1618 cout << "# bad return from really_checkout_package" << endl;1619 return;1620 }1621 }1622 }1623 1624 /*1625 if (m_verbose)1626 {1627 cout << "#CMT> pwd.4=" << CmtSystem::pwd () << " structure=" << structure_info << endl;1628 }1629 */1630 1631 //1632 // Now reach the newly checked out package.1633 //1634 1635 if (m_simulation)1636 {1637 cout << "#CMT> " << structure_info << " directory not really created " << dir << endl;1638 }1639 else if (structure_info == "package")1640 {1641 if (!CmtSystem::cd (dir))1642 {1643 cout << "#CMT> Package directory not created " << dir << endl;1644 }1645 1646 1647 /*1648 if (m_verbose)1649 {1650 cout << "#CMT> pwd.4=" << CmtSystem::pwd () << endl;1651 }1652 */1653 1654 // Check if it is a true CMT package.1655 1656 cmt_string file_name;1657 1658 file_name = "cmt";1659 file_name += CmtSystem::file_separator ();1660 file_name += "requirements";1661 1662 if (CmtSystem::test_file (file_name))1663 {1664 dir += CmtSystem::file_separator ();1665 dir += "cmt";1666 CmtSystem::cd ("cmt");1667 1668 /*1669 if (m_verbose)1670 {1671 cout << "#CMT> pwd.5=" << CmtSystem::pwd () << endl;1672 }1673 */1674 1675 if (Cmt::get_current_structuring_style () == without_version_directory)1676 {1677 cmt_string text = version;1678 text += "\n";1679 text.write ("version.cmt");1680 }1681 }1682 else1683 {1684 file_name = "mgr";1685 file_name += CmtSystem::file_separator ();1686 file_name += "requirements";1687 1688 if (CmtSystem::test_file (file_name))1689 {1690 dir += CmtSystem::file_separator ();1691 dir += "mgr";1692 CmtSystem::cd ("mgr");1693 1694 /*1695 if (m_verbose)1696 {1697 cout << "#CMT> pwd.6=" << CmtSystem::pwd () << endl;1698 }1699 */1700 }1701 else1702 {1703 cout << "# " << package << " not a CMT package" << endl;1704 return;1705 }1706 }1707 1708 //cout << "# (recursive is " << recursive << ")" << endl;1709 1710 if (recursive)1711 {1712 checkout_from_requirements ("requirements");1713 }1714 }1715 else if (structure_info == "project")1716 {1717 1718 if (m_verbose)1719 {1720 cout << "#CMT> dir=" << dir << endl;1721 }1722 1723 if (!CmtSystem::cd (dir))1724 {1725 cout << "#CMT> Project directory not created " << dir << endl;1726 }1727 1728 cmt_string file_name;1729 1730 file_name = "cmt";1731 file_name += CmtSystem::file_separator ();1732 file_name += "project.cmt";1733 1734 if (!CmtSystem::test_file (file_name))1735 {1736 cout << "# " << package << " not a CMT project" << endl;1737 return;1738 }1739 1740 if (recursive)1741 {1742 checkout_from_project_file (file_name);1743 }1744 }1745 }1746 1477 1747 1478 /** … … 1783 1514 } 1784 1515 1785 void tags (const CmtSystem::cmt_string_vector& arguments) 1786 { 1787 if (arguments.size () < 1) 1788 { 1789 help (); 1790 return; 1791 } 1792 1793 if (CmtSystem::getenv ("CVSROOT") == "") 1794 { 1795 cout << "# Please set CVSROOT first !" << endl; 1796 return; 1797 } 1798 1799 if (CmtSystem::getenv ("CMTCVSTEST") != "") 1800 { 1801 m_cmtcvstest = true; 1802 } 1803 else 1804 { 1805 m_cmtcvstest = false; 1806 } 1807 1808 m_offset = CmtSystem::getenv ("CMTCVSOFFSET"); 1809 if (m_offset != "") 1810 { 1811 m_offset += "/"; 1812 m_offset.replace_all ("//", "/"); 1813 } 1814 1815 bool all = false; 1816 1817 for (int arg = 0; arg < arguments.size (); arg++) 1818 { 1819 const cmt_string& option = arguments[arg]; 1820 1821 if (option == "-all") 1822 { 1823 all = true; 1824 } 1825 else 1826 { 1827 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), option); 1828 1829 if (error_info != "") 1830 { 1831 cout << error_info << endl; 1832 } 1833 else 1834 { 1835 cmt_string tags; 1836 1837 if (all) 1838 { 1839 tags = cvsversions_top_info; 1840 tags += " "; 1841 tags += cvsversions_info; 1842 } 1843 else 1844 { 1845 tags = tags_top_info; 1846 tags += " "; 1847 tags += tags_info; 1848 } 1849 1850 CmtSystem::cmt_string_vector v; 1851 1852 CmtSystem::split (tags, " \t", v); 1853 for (int i = 0; i < v.size (); i++) 1854 { 1855 const cmt_string& s = v[i]; 1856 cout << s << endl; 1857 } 1858 } 1859 } 1860 } 1861 } 1862 1863 void branches (const cmt_string& module) 1864 { 1865 cmt_string out; 1866 1867 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), module); 1868 1869 if (error_info != "") 1870 { 1871 cout << error_info << endl; 1872 } 1873 else 1874 { 1875 cout << branches_info << endl; 1876 } 1877 } 1878 1879 void subpackages (const cmt_string& module) 1880 { 1881 cmt_string out; 1882 1883 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module); 1884 1885 if (error_info != "") 1886 { 1887 cout << error_info << endl; 1888 } 1889 else 1890 { 1891 cout << subpackages_info << endl; 1892 } 1893 } 1894 1895 void subprojects (const cmt_string& module) 1896 { 1897 cmt_string out; 1898 1899 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module); 1900 1901 if (error_info != "") 1902 { 1903 cout << error_info << endl; 1904 } 1905 else 1906 { 1907 cout << subprojects_info << endl; 1908 } 1909 } 1910 1911 void help () 1912 { 1913 cout << "> cd <some work area>" << endl; 1914 cout << "> cmt checkout [modifier ...] <package>" << endl; 1915 cout << "" << endl; 1916 cout << " modifier :" << endl; 1917 cout << " -l Do not process used packages (default)." << endl; 1918 cout << " -R Process used packages recursively." << endl; 1919 cout << " -r rev Check out version tag. (is sticky)" << endl; 1920 cout << " -d dir Check out into dir instead of module name." << endl; 1921 cout << " -o offset Offset in the CVS repository" << endl; 1922 cout << " -requirements <requirements file path> Check out packages referenced in this requirements file" << endl; 1923 cout << " -n simulation mode on" << endl; 1924 cout << " -v verbose mode on" << endl; 1925 cout << " --help print this help" << endl; 1926 cout << "" << endl; 1927 } 1928 1516 /** 1517 Internal call from the initial do_checkout or from recursive passes 1518 Prepare the directory structure for the checkout 1519 Do the checkout 1520 Check if everything was done properly, if a package or a project has been created 1521 If needed recurse from the requirements or project file 1522 1523 For projects there may be two different specifications for 1524 - the version directory 1525 - the CVS tag 1526 */ 1527 void do_checkout (const cmt_string& prefix, 1528 const cmt_string& package, 1529 const cmt_string& specified_version, 1530 const cmt_string& tag) 1531 { 1532 if (m_verbose) 1533 { 1534 cout << "#CMT> checkout_package> prefix=" << prefix 1535 << " " << structure_info << "=" << package 1536 << " specified_version=" << specified_version 1537 << endl; 1538 } 1539 1540 cmt_string version = specified_version; 1541 cmt_string empty; 1542 cmt_string full_prefix; 1543 1544 full_prefix = m_offset; 1545 full_prefix += prefix; 1546 1547 cmt_string echo_ppath; 1548 1549 if (prefix != "") 1550 { 1551 echo_ppath = " path "; 1552 echo_ppath += prefix; 1553 } 1554 1555 if (version == "") 1556 { 1557 cout << "# ================= No version specified for " << structure_info << " " << package << endl; 1558 return; 1559 } 1560 1561 // 1562 // First make an attempt to locate the specified version of 1563 // this package "as-it-is" in the work area. 1564 // Since 'version' may contain wild-card, it's likely that 1565 // we should not simply use CmtSystem::test_directory but 1566 // use the wild-card search. 1567 // 1568 1569 cmt_string dir; 1570 1571 dir = build_version_directory (prefix, package, version); 1572 1573 if (m_cmtcvstest) 1574 cout << "## (testing dir= " << dir << ")" << endl; 1575 1576 bool recursive = m_recursive; 1577 1578 /* 1579 if (m_cmtcvstest) 1580 { 1581 cmt_string v = find_matching_version (dir); 1582 1583 cout << "---> v=" << v << endl; 1584 } 1585 */ 1586 1587 cmt_string effective_version = find_matching_version (dir); 1588 1589 if (effective_version != "") 1590 { 1591 version = effective_version; 1592 1593 dir = build_version_directory (prefix, package, version); 1594 1595 cout << "# ================= " << structure_info << " " << package 1596 << " version " << version << echo_ppath 1597 << " already installed in " << dir << endl; 1598 1599 recursive = false; 1600 } 1601 else 1602 { 1603 bool at_head = false; 1604 cmt_string module; 1605 1606 // 1607 // get_version attempts to find the most appropriate version 1608 // tag matching the specification FROM the repository. However, 1609 // we should take into account situations where some versions have 1610 // already been checked out, in which case they might be sufficient 1611 // (or preferred?) 1612 // 1613 1614 if (version.find ("*") != cmt_string::npos) 1615 { 1616 cout << "# ================= " << structure_info << " " << package 1617 << " version " << version << echo_ppath 1618 << " has wild cards and will not be considered." << endl; 1619 return; 1620 } 1621 1622 if (!get_version (full_prefix, package, version, 1623 module, version, at_head)) 1624 { 1625 return; 1626 } 1627 1628 //cout << " full_prefix=[" << full_prefix << "] module=[" << module << "]" << endl; 1629 1630 if (m_cmtcvstest) cout << "## after get_version at_head=" << at_head << " m_head=" << m_head << endl; 1631 1632 if (m_head) 1633 { 1634 m_head = false; 1635 1636 at_head = true; 1637 } 1638 else 1639 { 1640 at_head = false; 1641 } 1642 1643 // 1644 // Make a second try after having selected a version from all the 1645 // available versions compatible with the specified version 1646 // 1647 1648 dir = build_version_directory (prefix, package, version); 1649 1650 if (CmtSystem::test_directory (dir)) 1651 { 1652 cout << "# ================= " << structure_info << " " << package 1653 << " version " << version << echo_ppath 1654 << " already installed." << endl; 1655 1656 recursive = false; 1657 } 1658 else 1659 { 1660 // 1661 // Now we can say that we have to perform the real checkout. 1662 // 1663 1664 if (!really_checkout (prefix, package, version, module, dir, at_head)) 1665 { 1666 cout << "# bad return from really_checkout_package" << endl; 1667 return; 1668 } 1669 } 1670 } 1671 1672 /* 1673 if (m_verbose) 1674 { 1675 cout << "#CMT> pwd.4=" << CmtSystem::pwd () << " structure=" << structure_info << endl; 1676 } 1677 */ 1678 1679 // 1680 // Now reach the newly checked out package. 1681 // 1682 1683 if (m_simulation) 1684 { 1685 cout << "#CMT> " << structure_info << " directory not really created " << dir << endl; 1686 } 1687 else if (structure_info == "package") 1688 { 1689 if (!CmtSystem::cd (dir)) 1690 { 1691 cout << "#CMT> Package directory not created " << dir << endl; 1692 } 1693 1694 1695 /* 1696 if (m_verbose) 1697 { 1698 cout << "#CMT> pwd.4=" << CmtSystem::pwd () << endl; 1699 } 1700 */ 1701 1702 // Check if it is a true CMT package. 1703 1704 cmt_string file_name; 1705 1706 file_name = "cmt"; 1707 file_name += CmtSystem::file_separator (); 1708 file_name += "requirements"; 1709 1710 if (CmtSystem::test_file (file_name)) 1711 { 1712 dir += CmtSystem::file_separator (); 1713 dir += "cmt"; 1714 CmtSystem::cd ("cmt"); 1715 1716 /* 1717 if (m_verbose) 1718 { 1719 cout << "#CMT> pwd.5=" << CmtSystem::pwd () << endl; 1720 } 1721 */ 1722 1723 if (Cmt::get_current_structuring_style () == without_version_directory) 1724 { 1725 cmt_string text = version; 1726 text += "\n"; 1727 text.write ("version.cmt"); 1728 } 1729 } 1730 else 1731 { 1732 file_name = "mgr"; 1733 file_name += CmtSystem::file_separator (); 1734 file_name += "requirements"; 1735 1736 if (CmtSystem::test_file (file_name)) 1737 { 1738 dir += CmtSystem::file_separator (); 1739 dir += "mgr"; 1740 CmtSystem::cd ("mgr"); 1741 1742 /* 1743 if (m_verbose) 1744 { 1745 cout << "#CMT> pwd.6=" << CmtSystem::pwd () << endl; 1746 } 1747 */ 1748 } 1749 else 1750 { 1751 cout << "# " << package << " not a CMT package" << endl; 1752 return; 1753 } 1754 } 1755 1756 //cout << "# (recursive is " << recursive << ")" << endl; 1757 1758 if (recursive) 1759 { 1760 checkout_from_requirements ("requirements"); 1761 } 1762 } 1763 else if (structure_info == "project") 1764 { 1765 1766 if (m_verbose) 1767 { 1768 cout << "#CMT> dir=" << dir << endl; 1769 } 1770 1771 if (!CmtSystem::cd (dir)) 1772 { 1773 cout << "#CMT> Project directory not created " << dir << endl; 1774 } 1775 1776 cmt_string file_name; 1777 1778 file_name = "cmt"; 1779 file_name += CmtSystem::file_separator (); 1780 file_name += "project.cmt"; 1781 1782 if (!CmtSystem::test_file (file_name)) 1783 { 1784 cout << "# " << package << " not a CMT project" << endl; 1785 return; 1786 } 1787 1788 if (recursive) 1789 { 1790 checkout_from_project_file (file_name); 1791 } 1792 } 1793 } 1794 1795 /** 1796 Top level of the checkout operation, initiated from the command line arguments 1797 1798 Construct an history of the checkouts to avoid duplicating the 1799 checkouts during the recursivity 1800 1801 Eventually 1802 o perform the cmt config for packages. 1803 1804 */ 1929 1805 void do_checkout (const cmt_string& module, const cmt_string& version_tag) 1930 1806 { … … 2003 1879 } 2004 1880 2005 checkout_package (prefix, package, version);1881 do_checkout (prefix, package, version, ""); 2006 1882 2007 1883 /* 2008 1884 if (m_verbose) 2009 1885 { 2010 cout << "#CMT> after checkout_packagepwd.7=" << CmtSystem::pwd () << " top_dir=" << top_dir << endl;1886 cout << "#CMT> after do_checkout pwd.7=" << CmtSystem::pwd () << " top_dir=" << top_dir << endl; 2011 1887 } 2012 1888 */ … … 2120 1996 } 2121 1997 1998 void help () 1999 { 2000 cout << "> cd <some work area>" << endl; 2001 cout << "> cmt checkout [modifier ...] <package|project>" << endl; 2002 cout << "" << endl; 2003 cout << " modifier :" << endl; 2004 cout << " -l Do not process used packages (default)." << endl; 2005 cout << " -R Process used packages recursively." << endl; 2006 cout << " -r rev Check out version tag. (is sticky)" << endl; 2007 cout << " -d dir Check out into dir instead of module name." << endl; 2008 cout << " -o offset Offset in the CVS repository" << endl; 2009 cout << " -requirements <requirements file path> Check out packages referenced in this requirements file" << endl; 2010 cout << " -n simulation mode on" << endl; 2011 cout << " -v verbose mode on" << endl; 2012 cout << " --help print this help" << endl; 2013 cout << "" << endl; 2014 cout << "> cmt cvstags <package|project>" << endl; 2015 cout << "> cmt cvssubpackages <directory>" << endl; 2016 cout << "> cmt cvssubprojects <directory>" << endl; 2017 cout << "" << endl; 2018 } 2019 2020 /** 2021 Implementation of the cmt cvstags 2022 Get the CVS tags of a module 2023 */ 2024 void tags (const CmtSystem::cmt_string_vector& arguments) 2025 { 2026 if (arguments.size () < 1) 2027 { 2028 help (); 2029 return; 2030 } 2031 2032 if (CmtSystem::getenv ("CVSROOT") == "") 2033 { 2034 cout << "# Please set CVSROOT first !" << endl; 2035 return; 2036 } 2037 2038 if (CmtSystem::getenv ("CMTCVSTEST") != "") 2039 { 2040 m_cmtcvstest = true; 2041 } 2042 else 2043 { 2044 m_cmtcvstest = false; 2045 } 2046 2047 m_offset = CmtSystem::getenv ("CMTCVSOFFSET"); 2048 if (m_offset != "") 2049 { 2050 m_offset += "/"; 2051 m_offset.replace_all ("//", "/"); 2052 } 2053 2054 bool all = false; 2055 2056 for (int arg = 0; arg < arguments.size (); arg++) 2057 { 2058 const cmt_string& option = arguments[arg]; 2059 2060 if (option == "-all") 2061 { 2062 all = true; 2063 } 2064 else 2065 { 2066 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), option); 2067 2068 if (error_info != "") 2069 { 2070 cout << error_info << endl; 2071 } 2072 else 2073 { 2074 cmt_string tags; 2075 2076 if (all) 2077 { 2078 tags = cvsversions_top_info; 2079 tags += " "; 2080 tags += cvsversions_info; 2081 } 2082 else 2083 { 2084 tags = tags_top_info; 2085 tags += " "; 2086 tags += tags_info; 2087 } 2088 2089 CmtSystem::cmt_string_vector v; 2090 2091 CmtSystem::split (tags, " \t", v); 2092 for (int i = 0; i < v.size (); i++) 2093 { 2094 const cmt_string& s = v[i]; 2095 cout << s << endl; 2096 } 2097 } 2098 } 2099 } 2100 } 2101 2102 /** 2103 Implementation of the cmt cvsbranches 2104 Get the subdirs of a module that are not subackages 2105 */ 2106 void branches (const cmt_string& module) 2107 { 2108 cmt_string out; 2109 2110 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), module); 2111 2112 if (error_info != "") 2113 { 2114 cout << error_info << endl; 2115 } 2116 else 2117 { 2118 cout << branches_info << endl; 2119 } 2120 } 2121 2122 /** 2123 Implementation of the cmt cvssubpackages 2124 Get the subdirs of a module that ARE CMT subpackages 2125 */ 2126 void subpackages (const cmt_string& module) 2127 { 2128 cmt_string out; 2129 2130 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module); 2131 2132 if (error_info != "") 2133 { 2134 cout << error_info << endl; 2135 } 2136 else 2137 { 2138 cout << subpackages_info << endl; 2139 } 2140 } 2141 2142 /** 2143 Implementation of the cmt cvssubrojects 2144 Get the subdirs of a module that ARE CMT projects 2145 */ 2146 void subprojects (const cmt_string& module) 2147 { 2148 cmt_string out; 2149 2150 show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module); 2151 2152 if (error_info != "") 2153 { 2154 cout << error_info << endl; 2155 } 2156 else 2157 { 2158 cout << subprojects_info << endl; 2159 } 2160 } 2161 2162 /** 2163 Implementation of the cmt checkout 2164 Parse the arguments 2165 Then call do_checkout for each argument 2166 */ 2122 2167 void checkout (const CmtSystem::cmt_string_vector& arguments) 2123 2168 { … … 2554 2599 else 2555 2600 { 2556 m_cvs. checkout_package (path, package, version);2601 m_cvs.do_checkout (path, package, version, ""); 2557 2602 } 2558 2603 } … … 2580 2625 need_project, 2581 2626 need_version, 2627 need_tag, 2582 2628 no_need 2583 2629 } state = need_project; … … 2585 2631 cmt_string project; 2586 2632 cmt_string version; 2633 cmt_string tag; 2587 2634 2588 2635 for (int i = 1; i < words.size (); i++) … … 2598 2645 case need_version: 2599 2646 version = s; 2647 state = need_tag; 2648 break; 2649 case need_tag: 2650 tag = s; 2600 2651 state = no_need; 2601 2652 break; … … 2670 2721 need_project, 2671 2722 need_version, 2723 need_tag, 2672 2724 no_need 2673 2725 } state = need_project; … … 2675 2727 cmt_string project; 2676 2728 cmt_string version; 2729 cmt_string tag; 2677 2730 2678 2731 for (int i = 1; i < words.size (); i++) … … 2688 2741 case need_version: 2689 2742 version = s; 2743 state = need_tag; 2744 break; 2745 case need_tag: 2746 tag = s; 2690 2747 state = no_need; 2691 2748 break; … … 2703 2760 else 2704 2761 { 2705 m_cvs. checkout_package ("", project, version);2762 m_cvs.do_checkout ("", project, version, tag); 2706 2763 } 2707 2764 }
Note: See TracChangeset
for help on using the changeset viewer.