Changeset 534
- Timestamp:
- Feb 25, 2010, 10:05:31 AM (14 years ago)
- Location:
- CMT/HEAD
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
CMT/HEAD/ChangeLog
r533 r534 1 2010-02-25 <rybkin@lal.in2p3.fr> 421 2 3 * source/cmt_vcs.h: In class Vcs, introduce functions checkout_module, 4 checkout_from_requirements. In class Vcs::Checkout, introduce members 5 m_requirements, m_command, m_recursive, m_context 6 * source/cmt_vcs.cxx: Implement introduced functions so that options 7 -R (recursive checkout) and -requirements (checkout from requirements file) 8 be functional with Subversion 9 1 10 2010-02-03 <rybkin@lal.in2p3.fr> 420 2 11 -
CMT/HEAD/source/cmt_vcs.cxx
r497 r534 128 128 CvsImplementation& m_cvs; 129 129 }; 130 131 class Walkthru : public Awk 132 { 133 public: 134 Walkthru (const Vcs::Checkout& checkout, 135 bool config, bool with_version_directory, 136 Vcs::VcsType type); 137 // RecursivePass2 (CvsImplementation& cvs); 138 void begin (); 139 void filter (const cmt_string& line); 140 141 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; 147 }; 148 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 170 CmtSystem::cmt_string_vector words; 171 172 CmtSystem::split (line, " \t", words); 173 174 enum 175 { 176 need_package, 177 need_version, 178 need_path, 179 no_need 180 } state = need_package; 181 182 cmt_string package; 183 cmt_string version; 184 cmt_string path; 185 186 for (int i = 1; i < words.size (); i++) 187 { 188 const cmt_string& s = words[i]; 189 190 if (s[0] == '-') continue; 191 192 switch (state) 193 { 194 case need_package: 195 package = s; 196 state = need_version; 197 break; 198 case need_version: 199 version = s; 200 state = need_path; 201 break; 202 case need_path: 203 path = s; 204 state = no_need; 205 break; 206 } 207 } 208 209 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 */ 222 CmtMessage::warning (package + " " + version + 223 (path != "" ? " " + path : "") + 224 " has wildcards in version and will not be considered."); 225 } 226 else 227 { 228 // static const cmt_string empty; 229 // 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 } 130 237 131 238 /** … … 3128 3235 cerr << "" << endl; 3129 3236 cerr << " modifier :" << endl; 3130 cerr << " -l Do not process used packages (default)." << endl;3131 //cerr << " -RProcess used products recursively." << endl;3132 cerr << " -r rev Check out version tag. (is sticky)" << endl;3133 cerr << " -vd dir Use this version directory instead of version tag." << endl;3134 cerr << " -d dir Check out into dir instead of module name." << endl;3135 cerr << " -o offset Offset in the repository" << endl;3136 //cerr << " -requirements <requirements file path> Check out packages referenced in this requirements file" << endl;3237 cerr << " -l Do not process used packages (default)." << endl; 3238 cerr << " -R Process used products recursively." << endl; 3239 cerr << " -r rev Check out version tag. (is sticky)" << endl; 3240 cerr << " -vd dir Use this version directory instead of version tag." << endl; 3241 cerr << " -d dir Check out into dir instead of module name." << endl; 3242 cerr << " -o offset Offset in the repository" << endl; 3243 cerr << " -requirements <requirements file path> Check out packages referenced in this requirements file" << endl; 3137 3244 //cerr << " -t Change file timestamps to the date of checkout" << endl; 3138 3245 //cerr << " -n simulation mode on" << endl; … … 3140 3247 //cerr << " -v verbose mode on" << endl; 3141 3248 cerr << " -rs suffix Same as -r <packagename|projectname>suffix" << endl; 3142 cerr << " --help print this help" << endl;3249 cerr << " --help Print this help" << endl; 3143 3250 cerr << "" << endl; 3144 3251 cerr << "(Modifiers are recognised anywhere on the command line.)" << endl; … … 3282 3389 //m_head = false; 3283 3390 //checkout_from_requirements (option); 3391 checkout.m_requirements = option; 3284 3392 } 3285 3393 else if (need_version_tag_suffix) … … 3292 3400 if (option == "-R") 3293 3401 { 3294 CmtMessage::warning ("Option " + option + " not implemented"); 3402 //CmtMessage::warning ("Option " + option + " not implemented"); 3403 //CmtMessage::warning ("Option " + option + " under testing"); 3295 3404 //m_recursive = true; 3405 checkout.m_recursive = true; 3296 3406 } 3297 3407 else if (option == "-t") … … 3302 3412 else if (option == "-l") 3303 3413 { 3414 checkout.m_recursive = false; 3304 3415 //m_recursive = false; 3305 3416 } … … 3337 3448 else if (option == "-requirements") 3338 3449 { 3339 CmtMessage::warning ("Option " + option + " not implemented");3450 //CmtMessage::warning ("Option " + option + " under testing"); 3340 3451 need_requirements_file = true; 3341 3452 } … … 3374 3485 } 3375 3486 3376 if (checkout.m_modules.size () < 1) 3487 if (checkout.m_modules.size () < 1 && 3488 checkout.m_requirements == "") 3377 3489 { 3378 3490 CmtError::set (CmtError::syntax_error, "No module to checkout specified"); … … 3381 3493 return 2; 3382 3494 } 3383 // 3495 //checkout.print (); 3384 3496 return 0; 3385 3497 } … … 3430 3542 } 3431 3543 3432 void Svn::checkout ( const Vcs::Checkout&checkout,3544 void Svn::checkout (Vcs::Checkout checkout, 3433 3545 bool config, bool with_version_directory) 3434 3546 { … … 3445 3557 return; 3446 3558 } 3447 3448 cmt_string cmd (checkout_command); 3559 checkout.m_command = checkout_command; 3560 3561 /** 3562 * Call checkout for each command line argument 3563 */ 3564 for (int arg = 0; arg < checkout.m_modules.size (); arg++) 3565 { 3566 const cmt_string& module = checkout.m_modules[arg]; 3567 const cmt_string& version_tag = checkout.m_version_tag; 3568 Vcs::checkout_module (checkout, 3569 config, with_version_directory, 3570 module, version_tag, 3571 Vcs::Svn); 3572 // do_checkout_phase1 (modules[arg], m_version_dir, version_tag); 3573 } 3574 3575 /** 3576 * Call checkout for used package in requirements file 3577 */ 3578 if (checkout.m_requirements != "") 3579 Vcs::checkout_from_requirements (checkout, 3580 config, with_version_directory, 3581 checkout.m_requirements, 3582 Vcs::Svn); 3583 } 3584 3585 void Vcs::checkout_module (const Vcs::Checkout& checkout, 3586 bool config, bool with_version_directory, 3587 const cmt_string& module, cmt_string version_tag, 3588 Vcs::VcsType type) 3589 { 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 line 3607 { 3608 } 3609 else if ((i = version_tag.find ("*")) != cmt_string::npos) 3610 // version has wildcards (or not specified) in requirements 3611 { 3612 } 3613 } 3614 3615 History& h = History::instance (); 3616 cmt_string line (module + " " + version_tag); 3617 //cerr << "get: " << line << endl; 3618 if (h.is_installed (line)) return; 3619 h.install (line); 3620 //cerr << "install: " << line << endl; 3621 3622 cmt_string cmd (checkout.m_command); 3449 3623 cmt_string msg; 3450 3624 … … 3457 3631 cmd += " --without_version_directory"; 3458 3632 3459 if ( checkout.m_version_tag != "")3460 { 3461 cmd += " -r " + checkout.m_version_tag;3462 msg += " (" + checkout.m_version_tag + ")";3633 if (version_tag != "") 3634 { 3635 cmd += " -r " + version_tag; 3636 msg += " (" + version_tag + ")"; 3463 3637 } 3464 3638 else … … 3480 3654 3481 3655 /** 3482 * Then call checkout for each argument3656 * Then call checkout for the module 3483 3657 */ 3484 for (int arg = 0; arg < checkout.m_modules.size (); arg++) 3485 { 3486 const cmt_string& module = checkout.m_modules[arg]; 3487 CmtMessage::info ("Working on " + module + msg); 3488 // cerr << cmd + " " + module << endl; 3489 int status = CmtSystem::execute (cmd + " " + module); 3490 if (0 == status) 3658 // for (int arg = 0; arg < checkout.m_modules.size (); arg++) 3659 // { 3660 // const cmt_string& module = checkout.m_modules[arg]; 3661 CmtMessage::info ("Working on " + module + msg); 3662 // cerr << cmd + " " + module << endl; 3663 int status = CmtSystem::execute (cmd + " " + module); 3664 if (0 == status) 3665 { 3666 CmtMessage::info (module + " done."); 3667 if (checkout.m_recursive) 3491 3668 { 3492 CmtMessage::info (module + " done."); 3493 } 3494 else 3495 { 3496 CmtError::set (CmtError::execution_failed, cmd + " " + module, status); 3497 } 3498 // do_checkout_phase1 (modules[arg], m_version_dir, version_tag); 3499 } 3500 } 3669 cmt_string requirements; 3670 if (checkout.m_checkout_dir != "") 3671 { 3672 requirements = checkout.m_checkout_dir; 3673 } 3674 else 3675 { 3676 requirements = module; 3677 requirements.replace_all ("/", CmtSystem::file_separator ()); 3678 } 3679 if (with_version_directory) 3680 { 3681 if (checkout.m_version_dir != "") 3682 { 3683 requirements += CmtSystem::file_separator (); 3684 requirements += checkout.m_version_dir; 3685 } 3686 else 3687 { 3688 if (version_tag != "") 3689 { 3690 requirements += CmtSystem::file_separator (); 3691 requirements += version_tag; 3692 } 3693 else 3694 { // checkout of trunk 3695 // 3696 static CmtSystem::cmt_string_vector versions; 3697 static cmt_string name; 3698 3699 name = requirements; 3700 name += CmtSystem::file_separator (); 3701 name += "*"; 3702 CmtSystem::scan_dir (name, versions); 3703 3704 int n (0); 3705 for (int i = 0; i < versions.size (); i++) 3706 { 3707 const cmt_string& vers = versions[i]; 3708 3709 if (Cmt::get_debug ()) 3710 { 3711 cout << " ... version " << vers << " exists" << endl; 3712 } 3713 /* 3714 This check is not sufficient !! We need to check in addition 3715 that the selected directory is really the start of a true CMT 3716 package (ie with either /mgr/requirements or /cmt/requirements below) 3717 */ 3718 3719 cmt_string req; 3720 req = vers; 3721 //req = name; 3722 req += CmtSystem::file_separator (); 3723 req += "mgr"; 3724 req += CmtSystem::file_separator (); 3725 req += "requirements"; 3726 3727 if (!CmtSystem::test_file (req)) 3728 { 3729 req = vers; 3730 //req = name; 3731 req += CmtSystem::file_separator (); 3732 req += "cmt"; 3733 req += CmtSystem::file_separator (); 3734 req += "requirements"; 3735 3736 if (!CmtSystem::test_file (req)) continue; 3737 } 3738 n += 1; 3739 if (n > 1) 3740 { 3741 CmtMessage::warning (requirements + 3742 ": Ambiguous choice" 3743 " for recursion"); 3744 break; 3745 } 3746 CmtSystem::basename (vers, name); 3747 requirements += CmtSystem::file_separator (); 3748 requirements += name; 3749 } // end of for versions loop 3750 if (n < 1) 3751 { 3752 CmtMessage::error ("Cannot find package in " + 3753 requirements + 3754 " for recursion"); 3755 CmtError::set (CmtError::package_not_found, 3756 "in " + requirements); 3757 return; 3758 } 3759 } // end of checkout of trunk 3760 } 3761 } // end of with_version_directory 3762 cmt_string cmt_req = requirements + 3763 CmtSystem::file_separator () + 3764 "cmt" + 3765 CmtSystem::file_separator () + 3766 "requirements"; 3767 cmt_string mgr_req = requirements + 3768 CmtSystem::file_separator () + 3769 "mgr" + 3770 CmtSystem::file_separator () + 3771 "requirements"; 3772 if (CmtSystem::test_file (cmt_req)) 3773 { 3774 requirements = cmt_req; 3775 } 3776 else if (CmtSystem::test_file (mgr_req)) 3777 { 3778 requirements = mgr_req; 3779 } 3780 else 3781 { 3782 CmtError::set (CmtError::path_not_found, 3783 cmt_req + " or " + mgr_req); 3784 return; 3785 } 3786 Vcs::checkout_from_requirements (checkout, 3787 config, with_version_directory, 3788 requirements, 3789 type); 3790 } // end of checkout.m_recursive 3791 } 3792 else 3793 { 3794 CmtError::set (CmtError::execution_failed, cmd + " " + module, status); 3795 } 3796 // do_checkout_phase1 (modules[arg], m_version_dir, version_tag); 3797 } 3798 3799 void Vcs::checkout_from_requirements (const Vcs::Checkout& checkout, 3800 bool config, 3801 bool with_version_directory, 3802 const cmt_string& requirements, 3803 Vcs::VcsType type) 3804 { 3805 CmtMessage::info ("Processing " + requirements); 3806 3807 cmt_string text; 3808 if (!text.read (requirements)) 3809 { 3810 CmtError::set (CmtError::path_not_found, requirements); 3811 return; 3812 } 3813 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 } -
CMT/HEAD/source/cmt_vcs.h
r496 r534 13 13 { 14 14 public: 15 16 typedef enum 17 { 18 Cvs, 19 Svn 20 } VcsType; 21 22 public: 15 23 16 24 /* static void tags (const CmtSystem::cmt_string_vector& arguments); */ … … 23 31 { 24 32 public: 33 Checkout () 34 : m_recursive (false), m_context (false) 35 { } 25 36 cmt_string m_version_tag; 26 37 cmt_string m_checkout_dir; … … 28 39 cmt_string m_offset; 29 40 CmtSystem::cmt_string_vector m_modules; 41 cmt_string m_requirements; 42 cmt_string m_command; 43 bool m_recursive; 44 bool m_context; 30 45 void print () 31 46 { … … 38 53 cerr << "m_modules[" << arg << "]: " << m_modules[arg] << endl; 39 54 } 55 cerr << "m_requirements: " << m_requirements << endl; 56 cerr << "m_command: " << m_command << endl; 57 cerr << "m_recursive: " << m_recursive << endl; 58 cerr << "m_context: " << m_context << endl; 40 59 } 41 60 }; 61 62 static void checkout_module (const Checkout& checkout, 63 bool config, bool with_version_directory, 64 const cmt_string& module, cmt_string version_tag, 65 VcsType type); 66 static void checkout_from_requirements (const Checkout& checkout, 67 bool config, bool with_version_directory, 68 const cmt_string& requirements, 69 VcsType type); 42 70 43 71 private: … … 54 82 public: 55 83 56 static void checkout ( const Vcs::Checkout&checkout,84 static void checkout (Vcs::Checkout checkout, 57 85 bool config, bool with_version_directory); 58 86 };
Note: See TracChangeset
for help on using the changeset viewer.