Changeset 45


Ignore:
Timestamp:
May 2, 2005, 9:31:23 AM (19 years ago)
Author:
arnault
Message:

cmt cvs operations - See CL 272

Location:
CMT/HEAD
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • CMT/HEAD/ChangeLog

    r43 r45  
     12005-05-02  Christian Arnault  <arnault@lal.in2p3.fr> 272
     2
     3        * source/cmt_cvs.cxx: Adding CMTPATH internal management
     4        Improve broadcast operation after recursive checkouts
     5
     62005-05-01  Christian Arnault  <arnault@lal.in2p3.fr> 272
     7
     8        * mgr/Makefile (pacman): Create the pacman file for that version.
     9
     10        * mgr/CMT.pacman: Migrate to Pacman3
     11
     12        * source/cmt_cvs.cxx: Supporting project checkout
     13        recursive project checkouts
     14        without_version_directory mode
     15        container statements in project files.
     16        alias version directory
     17        Various cleanup and restructuring operations
     18
     19        * mgr/requirements: Adapt for shared libs on CYGWIN (thanks to Guy Barrand)
     20
     21        * src/setup.zsh: Add cmt subprojects command
     22
     23        * src/setup.tcsh: Add cmt subprojects command
     24
    1252005-04-26  Christian Arnault  <arnault@lal.in2p3.fr> 271
    226
  • CMT/HEAD/mgr/CMT.pacman

    r11 r45  
    55#-----------------------------------------------------------
    66
    7 #
    8 #   CMT installation and setup.
    9 #
    10 #      (from Saul Youssef himself)
    11 #
    12 description  = 'CMT <version>'
    13 url          = 'http://www.cmtsite.org'
     7description ('CMT <version>')
     8packageName ('CMT')
     9version ('<version>')
    1410
    15 download     = {'unix':'CMT<version>.tar.gz'}
    16 source       = 'http://www.cmtsite.org/<version>/'
     11{
     12    platformGE ('Linux') ; downloadUntar ('http://www.cmtsite.org/<version>/CMT<version>Linux-i686.tar.gz', 'CMTBASE')
     13  OR
     14    platformGE ('Cygwin') ; downloadUntar ('http://www.cmtsite.org/<version>/CMT<version>CYGWIN_NT-5.1-i686', 'CMTBASE')
     15  OR
     16    downloadUntar ('http://www.cmtsite.org/<version>/CMT<version>.tar.gz', 'CMTBASE')
     17}
    1718
    18 inpath       = ['gcc','make']
     19cd ('$CMTBASE/<version>/mgr')
     20shellOutputContains ('INSTALL', 'CMT installation terminated')
     21{
     22  shellOutputContains ('. setup.sh; cmt version', '<version>')
     23    OR shell ('. setup.sh; gmake')
     24}
     25shellOutputContains ('. setup.sh; cmt version', '<version>')
     26cd ()
    1927
    20 #paths        = [['PATH','$PACMAN_INSTALLATION/CMT/<version>/mgr']]
    21 enviros      = [['CMTROOT',''],['CMTCONFIG','i386_linux24'],['CMTBIN','Linux'],['CLASSPATH','java']]
    22 localdoc     = 'doc/CMT.htm'
    23 #
    24 #   This turns off using the root directory extracted from tar.
    25 #
    26 usePackageRoot = 0
    27 #
    28 #   ...so I cd from the installation area by hand before each shell command.
    29 #
    30 install      = { '*': ['cd CMT/<version>/mgr; ./INSTALL'] }
    31 setup         = ["source ${PACMAN_INSTALLATION}/CMT/<version>/mgr/setup.SHELL"]
    32 #
    33 #  since usePackageRoot=0, I have to clean up by hand
    34 #
    35 uninstall    = ['rm -r -f CMT CMT<version>.tar']
  • CMT/HEAD/mgr/Makefile

    r32 r45  
    209209#        echo '  <tr><td><a href="CMT-'$${version}'-1.i386.rpm">RPM for redhat 7.2</a></td></tr>' >>doc/CMTDownload.html;
    210210
     211#---------------------------------------------------------
     212# Construct the pacman file from the generic form
     213#---------------------------------------------------------
     214pacman ::
     215        version=`cmt version`; \
     216        sed -e 's#<version>#'"$${version}"'#g' CMT.pacman >CMT-$${version}.pacman
    211217
    212218#---------------------------------------------------------
  • CMT/HEAD/mgr/cmt_dependencies.make

    r43 r45  
    1717cmt_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
    1818cmt_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   ../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
     19cmt_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   ../source/cmt_project.h
    2020cmt_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
    2121cmt_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/mgr/requirements

    r43 r45  
    6767tag SunOS          Unix
    6868
    69 tag CYGWIN_NT-5.1  Unix CYGWIN Linux
     69tag CYGWIN_NT-5.1  Unix CYGWIN
    7070
    7171tag alpha          OSF1
     
    365365      OSF1          "${CMTROOT}/mgr/cmt_make_shlib_common.sh noextract" \
    366366      Linux         "${CMTROOT}/mgr/cmt_make_shlib_common.sh extract" \
     367      CYGWIN        "${CMTROOT}/mgr/cmt_make_shlib_common.sh extract" \
    367368      SunOS         "${CMTROOT}/mgr/cmt_make_shlib_common.sh extract" \
    368369      Darwin        "${CMTROOT}/mgr/cmt_make_shlib_common.sh extract" \
     
    374375      SunOS         "so" \
    375376      Linux         "so" \
     377      CYGWIN        "dll" \
    376378      Darwin        "dylib" \
    377379      WIN32         "dll"
     
    382384      SunOS         "CC" \
    383385      Linux         "g++" \
     386      CYGWIN        "g++" \
    384387      Darwin        "c++"
    385388
     
    388391      OSF1          "-shared -expect_unresolved '*'" \
    389392      Linux         "-shared" \
     393      CYGWIN        "-shared" \
    390394      SunOS         "$(debug_option)" \
    391395      VisualC       "" \
     
    437441
    438442macro application_suffix ".exe"
    439 macro library_prefix "lib" WIN32 ""
     443macro library_prefix "lib" WIN32 "" CYGWIN ""
    440444macro library_suffix ""
    441445
  • CMT/HEAD/source/cmt_cvs.cxx

    r44 r45  
    1212#include "cmt_awk.h"
    1313#include "cmt_symbol.h"
     14#include "cmt_project.h"
    1415
    1516/**
     
    6970/**
    7071
    71       History : maintains the history of checkout packages during a
     72      History : maintains the history of checkouts during a
    7273                recursive checkout, so as to avoid double checkouts.
    7374
     
    173174  CvsImplementation ()
    174175  {
    175     m_recursive = false;
    176     m_head = false;
    177     m_cmtcvstest = false;
    178     m_verbose = false;
     176    clear ();
     177  }
     178
     179  void clear ()
     180  {
     181    m_recursive  = false;
     182    m_head       = false;
     183    m_verbose    = false;
    179184    m_simulation = false;
    180185
    181     m_home_dir = "";
     186    m_home_dir     = "";
    182187    m_checkout_dir = "";
    183     m_offset = "";
    184     m_branch_suffix = "";
    185 
    186     m_last_module = "";
    187     m_last_cvs_infos = "";
    188     structure_info = "";
    189     error_info = "";
    190     tags_top_info = "";
    191     tags_info = "";
     188    m_version_dir = "";
     189    m_cvs_offset  = "";
     190
     191    m_last_module        = "";
     192    m_last_cvs_infos     = "";
     193    structure_info       = "";
     194    error_info           = "";
     195    tags_top_info        = "";
     196    tags_info            = "";
    192197    cvsversions_top_info = "";
    193     cvsversions_info = "";
    194     branches_info = "";
    195     subpackages_info = "";
    196     subprojects_info = "";
    197 
    198     m_protocol_level = "";
     198    cvsversions_info     = "";
     199    branches_info        = "";
     200    subpackages_info     = "";
     201    subprojects_info     = "";
     202
     203    m_protocol_level     = "";
    199204
    200205    Symbol* symbol = Symbol::find ("cmt_cvs_protocol_level");
     
    204209        Symbol::expand (m_protocol_level);
    205210      }
     211  }
     212
     213  CvsImplementation& operator = (const CvsImplementation& other)
     214  {
     215    m_recursive  = other.m_recursive;
     216    m_head       = other.m_head;
     217    m_verbose    = other.m_verbose;
     218    m_simulation = other.m_simulation;
     219
     220    m_home_dir       = other.m_home_dir;
     221    m_checkout_dir   = other.m_checkout_dir;
     222    m_version_dir    = other.m_version_dir;
     223    m_cvs_offset     = other.m_cvs_offset;
     224    m_protocol_level = other.m_protocol_level;
     225    m_last_module    = other.m_last_module;
     226    m_last_cvs_infos = other.m_last_cvs_infos;
     227
     228    structure_info       = other.structure_info;
     229    error_info           = other.error_info;
     230    tags_top_info        = other.tags_top_info;
     231    tags_info            = other.tags_info;
     232    cvsversions_top_info = other.cvsversions_top_info;
     233    cvsversions_info     = other.cvsversions_info;
     234    branches_info        = other.branches_info;
     235    subpackages_info     = other.subpackages_info;
     236    subprojects_info     = other.subprojects_info;
     237
     238    return (*this);
    206239  }
    207240
     
    229262      }
    230263  }
     264
     265  int execute (const cmt_string& command)
     266  {
     267    int status = 0;
     268
     269    if (m_verbose || m_simulation)
     270      {
     271        cout << "#CMT> Executing [" << command << "]" << endl;
     272      }
     273   
     274    if (!m_simulation)
     275      {
     276        status = CmtSystem::execute (command);
     277      }
     278
     279    return (status);
     280  }
     281
     282  void execute_and_retry (const cmt_string& command, const cmt_string& message)
     283  {
     284    int status;
     285    int retry = 0;
     286
     287    for (;;)
     288      {
     289        status = execute (command);
     290       
     291        if (status != 0)
     292          {
     293            retry++;
     294           
     295            cout << "# " << message << ": status=" << status << endl;
     296            cout << "#---------------------------------------------------------" << endl;
     297           
     298            if (retry > 5) exit(0);
     299          }
     300        else
     301          {
     302            break;
     303          }
     304      }
     305  }
     306
     307  int execute (const cmt_string& command, cmt_string& out)
     308  {
     309    int status = 0;
     310
     311    if (m_verbose || m_simulation)
     312      {
     313        cout << "#CMT> Executing [" << command << "]" << endl;
     314      }
     315   
     316    if (!m_simulation)
     317      {
     318        status = CmtSystem::execute (command, out);
     319      }
     320
     321    return (status);
     322  }
     323
    231324
    232325  /**
     
    272365    command += " -Q co -p CVSROOT/loginfo ";
    273366
    274     if (m_verbose || m_simulation)
    275       {
    276         cout << "#CMT> Executing [" << command << "]" << endl;
    277       }
    278    
    279     if (!m_simulation)
    280       {
    281         found = false;
    282 
    283         cmt_string loginfo;
    284 
    285         CmtSystem::execute (command, loginfo);
    286 
    287         cmt_string pattern = ".cmtcvsinfos/";
    288         pattern += m_protocol_level;
    289 
    290         int pos = loginfo.find (pattern);
    291 
    292         if (pos != cmt_string::npos)
    293           {
    294             found = true;
    295           }
     367    found = false;
     368
     369    cmt_string pattern = ".cmtcvsinfos/";
     370    pattern += m_protocol_level;
     371
     372    cmt_string loginfo;
     373
     374    if (m_simulation)
     375      {
     376        loginfo = pattern;
     377      }
     378
     379    execute (command, loginfo);
     380
     381    int pos = loginfo.find (pattern);
     382
     383    if (pos != cmt_string::npos)
     384      {
     385        found = true;
    296386      }
    297387
     
    353443        if (!CmtSystem::mkdir (tmp_dir))
    354444          {
    355             cout << "#CMT> Cannot create the temporary directory ["
    356                  << tmp_dir << "]" << endl;
     445            cout << "#CMT> Cannot create the temporary directory [" << tmp_dir << "]" << endl;
    357446            return;
    358447          }
     
    380469      }
    381470   
    382     /*
    383       #
    384       # The script associated to such entries is supposed to :
    385       #  1) extract the set of <infos> from ${module}/cmt/requirements
    386       #                                  or ${module}/cmt/project.cmt
    387       #  2) build an output of the form :
    388       #      <infos>=info1 info2 info3 ...
    389       #
    390       # Currently this script can be found in
    391       #
    392       # ${CMTROOT}/cmt/cmt_buildcvsinfos2.sh
    393       # %CMTROOT%/cmt/cmt_buildcvsinfos.py
    394       # There is a C++ implementation as cmtcvs.exe
    395       #
     471    /**
     472       The script associated to such entries is supposed to :
     473        1) extract the set of <infos> from ${module}/cmt/requirements
     474                                        or ${module}/cmt/project.cmt
     475        2) build an output of the form :
     476            <infos>=info1 info2 info3 ...
     477     
     478       Currently this script can be found in
     479     
     480       ${CMTROOT}/cmt/cmt_buildcvsinfos2.sh
     481       %CMTROOT%/cmt/cmt_buildcvsinfos.py
     482       There is a C++ implementation as cmtcvs.exe
     483     
    396484    */
    397485   
     
    418506   
    419507    command += cmtcvsinfos;
    420    
    421     if (m_cmtcvstest)
    422       {
    423         command += "/cmtcvstest";
    424       }
    425508   
    426509    if (m_protocol_level != "")
     
    433516    command += " CMT v1";
    434517   
    435     if (m_verbose || m_simulation)
    436       {
    437         cout << "#CMT> Executing [" << command << "]" << endl;
    438       }
    439    
    440518    m_last_cvs_infos = "";
    441     CmtSystem::execute (command, m_last_cvs_infos);
     519
     520    execute (command, m_last_cvs_infos);
    442521   
    443522    if (m_verbose)
     
    467546       all subprojects installed below the module.
    468547   
    469         In principle, only modules corresponding to true CMT packages or projects are considered.
     548        In principle, only modules corresponding to true CMT products (packages or projects) are considered.
    470549          o tags are obtained from the requirements or the project file
    471550          o branches are sub-directories which are not themselves packages
     
    473552            (a subdirectory is always either a branch or a subpackage)
    474553  */
    475   void show_cvs_infos (const cmt_string& module)
     554  void get_cvs_infos_with_offset (const cmt_string& module)
    476555  {
    477556    if (!check_protocol ())
     
    503582    /**
    504583       Now retrieve all info fields :
    505        
    506        structure=
    507        error=
    508        tags_top=
    509        tags=
    510        branches=
    511        subpackages=
    512        subprojects=
    513        
    514584    */
    515585
     
    650720        filter_list (cvsversions_info, exp);
    651721      }
    652    
    653     if (m_cmtcvstest)
    654       {
    655         cout << "## tags_top_info=" << tags_top_info << endl;
    656         cout << "## tags_info=" << tags_info << endl;
    657         cout << "## cvsversions_top_info=" << cvsversions_top_info << endl;
    658         cout << "## cvsversions_info=" << cvsversions_info << endl;
    659       }
    660    
    661   }
    662  
    663   void show_cvs_infos (const cmt_string& offset,
    664                        const cmt_string& module)
     722  }
     723 
     724  void get_cvs_infos (const cmt_string& cvs_offset, const cmt_string& module)
    665725  {
    666726    cmt_string full_name;
    667727
    668     if (offset != "")
    669       {
    670         full_name = offset;
     728    if (cvs_offset != "")
     729      {
     730        full_name = cvs_offset;
    671731        full_name += "/";
    672732        while (full_name.find ("//") != cmt_string::npos)
     
    678738    full_name += module;
    679739
    680     show_cvs_infos (full_name);
     740    get_cvs_infos_with_offset (full_name);
    681741  }
    682742
     
    713773  }
    714774
    715   bool get_version (const cmt_string& prefix,
    716                     const cmt_string& package,
     775  bool get_version (const cmt_string& offset,
     776                    const cmt_string& product,
    717777                    const cmt_string& version_request,
    718778                    cmt_string& module,
     
    729789    module = "";
    730790
    731     if (prefix != "")
    732       {
    733         module = prefix;
     791    if (offset != "")
     792      {
     793        module = offset;
    734794        module += "/"; // This is for CVS only thus we don't use the real separator.
    735795        while (module.find ("//") != cmt_string::npos)
     
    739799      }
    740800
    741     module += package;
     801    module += product;
    742802
    743803    /**
     
    750810     *     the HEAD) or not. The returned at_head flag will show this.
    751811     *
    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
     812     *     then the requested product may either be located in the CVS repository
     813     *     under the offset or not, the returned module will contain the effective
    754814     *     location where the requested version has been found.
    755815     */
     
    760820      }
    761821   
    762     show_cvs_infos (module);
     822    get_cvs_infos_with_offset (module);
    763823   
    764824    if (error_info != "")
    765825      {
    766826        versions = "";
    767         cout << "#CMT> Package " << package << " not found in ${CVSROOT}" << endl;
     827        cout << "#CMT> Product " << product << " not found in ${CVSROOT}" << endl;
    768828        return (false);
    769829      }
     
    783843      }
    784844   
    785     if (m_cmtcvstest) cout << "##    (version expression is " << v << ")" << endl;
    786        
    787845    cmt_regexp version_exp (v);
    788846   
    789847    if (!match_version_request (versions, version_exp, version))
    790848      {
    791         if (m_cmtcvstest) cout << "##    (no match in " << versions << ")" << endl;
    792 
    793849        // We try on non-top versions
    794850
     
    797853        if (!match_version_request (versions, version_exp, version))
    798854          {
    799             if (m_cmtcvstest) cout << "##    (no match in " << versions << ")" << endl;
    800            
    801855            version = requested_version;
    802856            int pos = 0;
     
    838892        else
    839893          {
    840             if (m_cmtcvstest) cout << "##    (match in non head " << versions << ")" << endl;
    841            
    842894            at_head = false;
    843895          }
     
    845897    else
    846898      {
    847         if (m_cmtcvstest) cout << "##    (match in head " << versions << ")" << endl;
    848        
    849899        at_head = true;
    850900      }
     
    857907  }
    858908
    859   cmt_string build_version_directory (const cmt_string& prefix,
    860                                       const cmt_string& package,
     909  /**
     910     Take care of structuring style for packages and of project vs package conventions
     911   */
     912  cmt_string build_version_directory (const cmt_string& offset,
     913                                      const cmt_string& product,
    861914                                      const cmt_string& version)
    862915  {
     
    865918    if (m_checkout_dir != "")
    866919      {
     920        // consider the usual -d option
     921 
    867922        dir += CmtSystem::file_separator ();
    868923        dir += m_checkout_dir;
     
    870925   
    871926    dir += CmtSystem::file_separator ();
    872     dir += prefix;
     927    dir += offset;
    873928    dir += CmtSystem::file_separator ();
    874     dir += package;
    875    
    876     if (Cmt::get_current_structuring_style () == with_version_directory)
     929    dir += product;
     930   
     931    if ((structure_info == "project") || (Cmt::get_current_structuring_style () == with_version_directory))
    877932      {
    878933        dir += CmtSystem::file_separator ();
     
    883938   
    884939    return (dir);
     940  }
     941
     942  /**
     943     Wrapper to mkdir handling simulation and verbose options.
     944   */
     945  bool mkdir (const cmt_string& dir)
     946  {
     947    if (m_simulation)
     948      {
     949        cout << "#CMT> Would create the " << dir << " directory" << endl;
     950      }
     951    else
     952      {
     953        if (!CmtSystem::cd (dir))
     954          {
     955            if (m_verbose)
     956              {
     957                cout << "#CMT> About to mkdir " << dir << endl;
     958              }
     959
     960            CmtSystem::mkdir (dir);
     961            if (!CmtSystem::cd (dir))
     962              {
     963                cout << "# Error creating the directory :" << dir << endl;
     964                cout << "#---------------------------------------------------------" << endl;
     965                return (false);
     966              }
     967          }
     968      }
     969    return (true);
     970  }
     971
     972  /**
     973     When running cmt cvs commands, we stand by definition outside of any existing
     974     package context. Thus it's likely that CMTPATH are not completely defined.
     975     This function manually prepends CMTPATH entries to the environment variable.
     976   */
     977  void add_cmtpath (const cmt_string& dir)
     978  {
     979    static cmt_string CMTPATH;
     980
     981    cmt_string cmtpath = CmtSystem::getenv ("CMTPATH");
     982
     983    if (cmtpath.find (dir) == cmt_string::npos)
     984      {
     985        CMTPATH = "CMTPATH=";
     986        CMTPATH += dir;
     987        CMTPATH += ":";
     988        CMTPATH += cmtpath;
     989       
     990        CmtSystem::putenv (CMTPATH);
     991      }
     992
     993    if (m_verbose)
     994      {
     995        cout << "#CMT> CMTPATH=" << CmtSystem::getenv ("CMTPATH") << endl;
     996      }
     997  }
     998
     999  /**
     1000     Construct CVS management files in the top directory. This is needed
     1001     if the top directory of a product is empty. (In this case the
     1002     co -l results in nothing)
     1003   */
     1004  void make_management_files (const cmt_string& module,
     1005                              const cmt_string& entries_text)
     1006  {
     1007    if (!CmtSystem::test_directory ("CVS"))
     1008      {
     1009        /**
     1010         * The CVS repository had not been created (this is generally
     1011         * due to the lack of top files)
     1012         */
     1013
     1014        if (!mkdir ("CVS")) return;
     1015
     1016        CmtSystem::cd ("..");
     1017
     1018        cmt_string s;
     1019       
     1020        // Let's create first the CVS/Root file.
     1021       
     1022        CmtSystem::get_cvsroot (s);
     1023        s += "\n";
     1024       
     1025        cmt_string f;
     1026       
     1027        f = "CVS";
     1028        f += CmtSystem::file_separator ();
     1029        f += "Root";
     1030       
     1031        if (m_simulation)
     1032          {
     1033            cout << "#CMT> Would fill in the CVS/Root file with " << endl;
     1034            cout << s << endl;
     1035          }
     1036        else
     1037          {
     1038            if (m_verbose)
     1039              {
     1040                cout << "#CMT> Fill in the CVS/Root file with " << endl;
     1041                cout << s << endl;
     1042              }
     1043            s.write (f);
     1044          }
     1045       
     1046        // Now we create the CVS/Repository file
     1047       
     1048        f = "CVS";
     1049        f += CmtSystem::file_separator ();
     1050        f += "Repository";
     1051       
     1052        CmtSystem::get_cvsroot (s);
     1053        if (s[0] == ':')
     1054          {
     1055            int pos = s.find (1, ":");
     1056            s.erase (0, pos+1);
     1057            pos = s.find (0, ":");
     1058            s.erase (0, pos+1);
     1059          }
     1060        s += "/";
     1061        s += module;
     1062        s += "\n";
     1063       
     1064        if (m_simulation)
     1065          {
     1066            cout << "#CMT> Would fill in the CVS/Repository file with " << endl;
     1067            cout << s << endl;
     1068          }
     1069        else
     1070          {
     1071            if (m_verbose)
     1072              {
     1073                cout << "#CMT> Fill in the CVS/Repository file with " << endl;
     1074                cout << s << endl;
     1075              }
     1076            s.write (f);
     1077          }
     1078      }
     1079   
     1080    if (m_simulation)
     1081      {
     1082        cout << "#CMT> Would write the top CVS/Entries file with " << endl;
     1083        cout << entries_text << endl;
     1084      }
     1085    else
     1086      {
     1087        cmt_string entries_file_name;
     1088
     1089        entries_file_name = "CVS";
     1090        entries_file_name += CmtSystem::file_separator ();
     1091        entries_file_name += "Entries";
     1092   
     1093        cmt_string text;
     1094
     1095        if (!text.read (entries_file_name))
     1096          {
     1097            // This happens when there were no top files
     1098          }
     1099
     1100        text += entries_text;
     1101
     1102        // Now the CVS/Entries is ready to be created.
     1103        if (m_verbose)
     1104          {
     1105            cout << "#CMT> Fill in the top CVS/Entries file with " << endl;
     1106            cout << text << endl;
     1107          }
     1108
     1109        text.write (entries_file_name);
     1110      }
     1111
    8851112  }
    8861113
     
    8881115     Specific checkout of one project
    8891116   */
    890   bool really_checkout_project_contents (const cmt_string& prefix,
     1117  bool really_checkout_project_contents (const cmt_string& offset,
    8911118                                         const cmt_string& project,
    8921119                                         const cmt_string& version,
     1120                                         const cmt_string& tag,
    8931121                                         const cmt_string& module,
    8941122                                         const cmt_string& basedir,
     
    9001128    cout << "  # get project files into " << dir << endl;
    9011129
    902     if (m_simulation)
    903       {
    904         cout << "#CMT> Would mkdir " << version << endl;
    905       }
    906     else
    907       {
    908         if (m_verbose)
    909           {
    910             cout << "#CMT> About to mkdir " << version << endl;
    911           }
    912 
    913         CmtSystem::mkdir (version);
    914         CmtSystem::cd (version);
    915       }
     1130    cmt_string version_dir = version;
     1131
     1132    if (!mkdir (version_dir)) return (false);
    9161133
    9171134    dir += CmtSystem::file_separator ();
    918     dir += version;
    919 
     1135    dir += version_dir;
    9201136   
    9211137    cmt_string command = "cvs -Q co -P ";
     
    9231139      {
    9241140        command += "-r ";
    925         command += version;
    926       }
    927 
    928     command += "-d cmt ";
     1141        command += (tag != "") ? tag : version;
     1142      }
     1143
     1144    command += " -d cmt ";
    9291145
    9301146    command += " ";
     
    9321148    command += "/cmt";
    9331149
    934     int status = 0;
    935     int retry = 0;
    936    
    937     for (;;)
    938       {
    939         if (m_verbose || m_simulation)
    940           {
    941             cout << "#CMT> Executing [" << command << "]" << endl;
    942           }
    943        
    944         if (!m_simulation)
    945           {
    946             //status = CmtSystem::execute (command, out);
    947             status = CmtSystem::execute (command);
    948           }
    949        
    950         if (status != 0)
    951           {
    952             retry++;
    953            
    954             cout << "# Error getting project CMT contents: status=" << status << endl;
    955             cout << "#---------------------------------------------------------" << endl;
    956            
    957             if (retry > 5) exit(0);
    958           }
    959         else
    960           {
    961             break;
    962           }
    963       }
     1150    execute_and_retry (command, "Error getting project CMT contents");
     1151
     1152    make_management_files (module, "D/cmt////\n");
    9641153
    9651154    return (true);
     
    9741163     4) write the CVS management files if CVS did not do it.
    9751164   */
    976   bool really_checkout_package_contents (const cmt_string& prefix,
     1165  bool really_checkout_package_contents (const cmt_string& offset,
    9771166                                         const cmt_string& package,
    9781167                                         const cmt_string& version,
     
    10021191        command += " -d ";
    10031192        command += package;
     1193
     1194        // Must stand just above the package directory
     1195        CmtSystem::cd ("..");
     1196        CmtSystem::dirname (dir, dir);
    10041197      }
    10051198   
     
    10071200    command += module;
    10081201   
    1009     if (m_cmtcvstest)
    1010       {
    1011         cmt_string cvsroot;
    1012        
    1013         CmtSystem::get_cvsroot (cvsroot);
    1014        
    1015         cout << "## cvsroot=" << cvsroot << " command[" << command << "]" << endl;
    1016       }
    1017    
    1018     int status = 0;
    1019     int retry = 0;
    1020    
    1021     for (;;)
    1022       {
    1023         if (m_verbose || m_simulation)
    1024           {
    1025             cout << "#CMT> Executing [" << command << "]" << endl;
    1026           }
    1027        
    1028         if (!m_simulation)
    1029           {
    1030             //status = CmtSystem::execute (command, out);
    1031             status = CmtSystem::execute (command);
    1032           }
    1033        
    1034         if (status != 0)
    1035           {
    1036             retry++;
    1037            
    1038             cout << "# Error getting package CMT contents: status=" << status << endl;
    1039             cout << "#---------------------------------------------------------" << endl;
    1040            
    1041             if (retry > 5) exit(0);
    1042            
    1043           }
    1044         else
    1045           {
    1046             break;
    1047           }
    1048       }
     1202    execute_and_retry (command, "Error getting package CMT contents");
    10491203
    10501204    if (Cmt::get_current_structuring_style () == with_version_directory)
    10511205      {
    1052         if (m_simulation)
    1053           {
    1054             cout << "#CMT> Would mkdir " << version << endl;
    1055           }
    1056         else
    1057           {
    1058             if (m_verbose)
    1059               {
    1060                 cout << "#CMT> About to mkdir " << version << endl;
    1061               }
    1062 
    1063             if (!CmtSystem::cd (version))
    1064               {
    1065                 CmtSystem::mkdir (version);
    1066                 if (!CmtSystem::cd (version))
    1067                   {
    1068                     cout << "# Error creating the version directory :" << version << endl;
    1069                     cout << "#---------------------------------------------------------" << endl;
    1070                     return (false);
    1071                   }
    1072               }
    1073            
    1074             /*
    1075               if (m_verbose)
    1076               {
    1077               cout << "#CMT> pwd.2=" << CmtSystem::pwd () << endl;
    1078               }
    1079             */
    1080           }
     1206        if (!mkdir (version)) return (false);
    10811207       
    10821208        dir += CmtSystem::file_separator ();
     
    10851211    else
    10861212      {
    1087         if (m_simulation)
    1088           {
    1089             cout << "#CMT> will mkdir " << package << endl;
    1090           }
    1091         else
    1092           {
    1093             if (!CmtSystem::cd (package))
    1094               {
    1095                 if (m_verbose)
    1096                   {
    1097                     cout << "#CMT> About to mkdir " << package << endl;
    1098                   }
    1099                 CmtSystem::mkdir (package);
    1100                 if (!CmtSystem::cd (package))
    1101                   {
    1102                     cout << "# Error creating the package directory :" << package << endl;
    1103                     cout << "#---------------------------------------------------------" << endl;
    1104                     return (false);
    1105                   }
    1106               }
    1107            
    1108             /*
    1109               if (m_verbose)
    1110               {
    1111               cout << "#CMT> pwd.3=" << CmtSystem::pwd () << endl;
    1112               }
    1113             */
    1114           }
     1213        if (!mkdir (package)) return (false);
    11151214       
    11161215        dir += CmtSystem::file_separator ();
     
    11181217      }
    11191218   
    1120     cmt_string entries_file_name;
    1121     cmt_string text;
    1122    
     1219    if (m_verbose)
     1220      {
     1221        cout << "#CMT> Now getting subdirectories pwd=" << CmtSystem::pwd () << " dir=" << dir << endl;
     1222      }
     1223
    11231224    cmt_string branches = CmtSystem::getenv ("CMTCVSBRANCHES");
    11241225   
     
    11321233    CmtSystem::split (branches, " \t", branch_vector);
    11331234   
     1235    cout << "  # get branches " << branches << endl;
     1236   
     1237    cmt_string text = "";
     1238   
     1239    command = "";
     1240   
    11341241    int i;
    11351242   
    1136     cout << "  # get branches " << branches << endl;
    1137    
    1138     //command = "(";
    1139     command = "";
    1140    
    1141     entries_file_name = "CVS";
    1142     entries_file_name += CmtSystem::file_separator ();
    1143     entries_file_name += "Entries";
    1144    
    1145     if (!text.read (entries_file_name))
    1146       {
    1147         // This happens when there were no top files
    1148       }
    1149    
    11501243    for (i = 0; i < branch_vector.size (); i++)
    11511244      {
     
    11571250          }
    11581251       
    1159         //command += "cvs -Q co -P ";
    11601252        command += "cvs -Q co ";
    11611253       
    1162         //            if (branch != "cmt")
    1163         //              {
    11641254        if (!at_head)
    11651255          {
     
    11671257            command += version;
    11681258          }
    1169         //              }
    11701259       
    11711260        command += " -d ";
     
    11751264        command += "/";    // CVS uses the '/' notation on all platforms!!
    11761265        command += branch;
    1177         //command += "\n";
    11781266       
    11791267        text += "D/";
     
    11821270      }
    11831271   
    1184     //command += "; echo cmtcvsstatus=$?) 2>&1 ";
    1185    
    1186     if (m_cmtcvstest)
    1187       {
    1188         cmt_string cvsroot;
    1189        
    1190         CmtSystem::get_cvsroot (cvsroot);
    1191        
    1192         cout << " cvsroot=" << cvsroot << " command[" << command << "]" << endl;
    1193       }
    1194    
    1195     status = 0;
    1196     retry = 0;
    1197    
    1198     for (;;)
    1199       {
    1200         if (m_verbose || m_simulation)
    1201           {
    1202             cout << "#CMT> Executing [" << command << "]" << endl;
    1203           }
    1204        
    1205         if (!m_simulation)
    1206           {
    1207             //status = CmtSystem::execute (command, out);
    1208             status = CmtSystem::execute (command);
    1209           }
    1210        
    1211         if (status != 0)
    1212           {
    1213             retry++;
    1214            
    1215             cout << "# Error getting package contents: status=" << status << endl;
    1216             cout << "#---------------------------------------------------------" << endl;
    1217            
    1218             if (retry > 5) exit(0);
    1219            
    1220           }
    1221         else
    1222           {
    1223             break;
    1224           }
    1225       }
    1226    
    1227     if (!CmtSystem::test_directory ("CVS"))
    1228       {
    1229         /**
    1230          * The CVS repository had not been created (this is generally
    1231          * due to the lack of top files)
    1232          */
    1233        
    1234         if (m_simulation)
    1235           {
    1236             cout << "#CMT> Would create the CVS directory" << endl;
    1237           }
    1238         else
    1239           {
    1240             if (m_verbose)
    1241               {
    1242                 cout << "#CMT> About to mkdir " << "CVS" << endl;
    1243               }
    1244             CmtSystem::mkdir ("CVS");
    1245           }
    1246        
    1247         cmt_string s;
    1248        
    1249         // Let's create first the CVS/Root file.
    1250        
    1251         CmtSystem::get_cvsroot (s);
    1252         s += "\n";
    1253        
    1254         cmt_string f;
    1255        
    1256         f = "CVS";
    1257         f += CmtSystem::file_separator ();
    1258         f += "Root";
    1259        
    1260         if (m_simulation)
    1261           {
    1262             cout << "#CMT> Would fill in the CVS/Root file with " << endl;
    1263             cout << s << endl;
    1264           }
    1265         else
    1266           {
    1267             if (m_verbose)
    1268               {
    1269                 cout << "#CMT> Fill in the CVS/Root file with " << endl;
    1270                 cout << s << endl;
    1271               }
    1272             s.write (f);
    1273           }
    1274        
    1275         // Now we create the CVS/Repository file
    1276        
    1277         f = "CVS";
    1278         f += CmtSystem::file_separator ();
    1279         f += "Repository";
    1280        
    1281         CmtSystem::get_cvsroot (s);
    1282         if (s[0] == ':')
    1283           {
    1284             int pos = s.find (1, ":");
    1285             s.erase (0, pos+1);
    1286             pos = s.find (0, ":");
    1287             s.erase (0, pos+1);
    1288           }
    1289         s += "/";
    1290         s += module;
    1291         s += "\n";
    1292        
    1293         if (m_simulation)
    1294           {
    1295             cout << "#CMT> Would fill in the CVS/Repository file with " << endl;
    1296             cout << s << endl;
    1297           }
    1298         else
    1299           {
    1300             if (m_verbose)
    1301               {
    1302                 cout << "#CMT> Fill in the CVS/Repository file with " << endl;
    1303                 cout << s << endl;
    1304               }
    1305             s.write (f);
    1306           }
    1307       }
    1308    
    1309     if (m_simulation)
    1310       {
    1311         cout << "#CMT> Would write the top CVS/Entries file with " << endl;
    1312         cout << text << endl;
    1313       }
    1314     else
    1315       {
    1316         // Now the CVS/Entries is ready to be created.
    1317         if (m_verbose)
    1318           {
    1319             cout << "#CMT> Fill in the top CVS/Entries file with " << endl;
    1320             cout << text << endl;
    1321           }
    1322         text.write (entries_file_name);
    1323       }
     1272    execute_and_retry (command, "Error getting package contents");
     1273
     1274    make_management_files (module, text);
    13241275
    13251276    return (true);
     
    13291280     Effective checkout of a package or a project
    13301281   */
    1331   bool really_checkout (const cmt_string& prefix,
    1332                         const cmt_string& package,
     1282  bool really_checkout (const cmt_string& offset,
     1283                        const cmt_string& product,
    13331284                        const cmt_string& version,
     1285                        const cmt_string& tag,
    13341286                        const cmt_string& module,
    13351287                        const cmt_string& basedir,
     
    13391291    cmt_string out;
    13401292   
    1341     cout << "# ================= working on " << structure_info << " " << package
     1293    cout << "# ================= working on " << structure_info << " " << product
    13421294         << " version " << version;
    13431295
    13441296    if (at_head) cout << " (At head) ";
    13451297
    1346     cmt_string full_prefix;
    1347 
    1348     full_prefix = m_offset;
    1349     full_prefix += prefix;
     1298    cmt_string full_offset;
     1299
     1300    full_offset = m_cvs_offset;
     1301    full_offset += offset;
    13501302
    13511303    cmt_string echo_ppath;
    13521304       
    1353     if (prefix != "")
     1305    if (offset != "")
    13541306      {
    13551307        echo_ppath = " path ";
    1356         echo_ppath += prefix;
    1357       }
    1358    
    1359     cout << echo_ppath << endl;
    1360 
    1361     CmtSystem::dirname (dir, dir);
    1362 
    1363     //if (Cmt::get_current_structuring_style () == with_version_directory)
    1364 
    1365     if (m_simulation)
    1366       {
    1367         cout << "#CMT> Would mkdir " << dir << endl;
    1368       }
    1369     else
    1370       {
    1371         if (m_verbose)
    1372           {
    1373             cout << "#CMT> About to mkdir " << dir << endl;
    1374           }
    1375        
    1376         if (!CmtSystem::mkdir (dir))
    1377           {
    1378             cout << "# Error creating the base directory :" << dir << endl;
    1379             cout << "#---------------------------------------------------------" << endl;
    1380             return (false);
    1381           }
    1382        
    1383         CmtSystem::cd (dir);
    1384        
    1385         /*
    1386           if (m_verbose)
    1387           {
    1388           cout << "#CMT> pwd.1=" << CmtSystem::pwd () << endl;
    1389           }
    1390         */
    1391       }
     1308        echo_ppath += offset;
     1309      }
     1310   
     1311    cout << echo_ppath << " in " << dir << endl;
     1312
     1313    if ((structure_info == "project") || (Cmt::get_current_structuring_style () == with_version_directory))
     1314      {
     1315        // Move back to the product name.
     1316        CmtSystem::dirname (dir, dir);
     1317      }
     1318
     1319    if (!mkdir (dir)) return (false);
    13921320       
    13931321    if (structure_info == "package")
    13941322      {
    1395         really_checkout_package_contents (prefix,
    1396                                           package,
     1323        really_checkout_package_contents (offset,
     1324                                          product,
    13971325                                          version,
    13981326                                          module,
     
    14031331    else if (structure_info == "project")
    14041332      {
    1405         really_checkout_project_contents (prefix,
    1406                                           package,
     1333        really_checkout_project_contents (offset,
     1334                                          product,
    14071335                                          version,
     1336                                          tag,
    14081337                                          module,
    14091338                                          basedir,
     
    14161345
    14171346  cmt_string find_matching_version (const cmt_string& expression)
    1418       {
    1419         cmt_string result;
    1420 
    1421           //
    1422           // Here expression takes the form
    1423           //   <some path>/<expression with wild-card>
    1424           //
    1425 
    1426         cmt_string dir;
    1427         CmtSystem::dirname (expression, dir);
    1428         dir += CmtSystem::file_separator ();
    1429 
    1430         cmt_string version;
    1431         CmtSystem::basename (expression, version);
    1432 
    1433         if (version.find ("*") == cmt_string::npos)
    1434           {
    1435               // there is no wildcarding here. A simple test is enough.
    1436             if (CmtSystem::test_directory (expression))
    1437               {
    1438                 if (m_cmtcvstest) cout << "## Found direct match with " << version << endl;
    1439                 result = version;
    1440               }
    1441             else
    1442               {
    1443                 if (m_cmtcvstest) cout << "## Explicit version " << version
    1444                                        << " has no direct match" << endl;
    1445               }
    1446           }
    1447         else
    1448           {
    1449             version.replace ("*", ".*");
    1450 
    1451             cmt_regexp exp (version);
    1452 
    1453             CmtSystem::cmt_string_vector list;
    1454 
    1455             if (m_cmtcvstest) cout << "## Trying scan_dir dir=" << dir
    1456                                    << " exp=" << version << endl;
    1457 
    1458             CmtSystem::scan_dir (dir, exp, list);
    1459 
    1460             if (list.size () > 0)
    1461               {
    1462                 result = list[0];
    1463 
    1464                 if (m_cmtcvstest) cout << "## At least one version is matching " << version
    1465                                        << "(" << list.size () << " matches) " << result << endl;
    1466 
    1467                 CmtSystem::basename (result, result);
    1468               }
    1469             else
    1470               {
    1471                 if (m_cmtcvstest) cout << "## There is no version matching " << version << endl;
    1472               }
    1473           }
    1474 
    1475         return (result);
    1476       }
    1477 
     1347  {
     1348    cmt_string result;
     1349
     1350    //
     1351    // Here expression takes the form
     1352    //   <some path>/<expression with wild-card>
     1353    //
     1354
     1355    cmt_string dir;
     1356    CmtSystem::dirname (expression, dir);
     1357    dir += CmtSystem::file_separator ();
     1358   
     1359    cmt_string version;
     1360    CmtSystem::basename (expression, version);
     1361
     1362    if (version.find ("*") == cmt_string::npos)
     1363      {
     1364        // there is no wildcarding here. A simple test is enough.
     1365        if (CmtSystem::test_directory (expression))
     1366          {
     1367            result = version;
     1368          }
     1369      }
     1370    else
     1371      {
     1372        version.replace ("*", ".*");
     1373       
     1374        cmt_regexp exp (version);
     1375       
     1376        CmtSystem::cmt_string_vector list;
     1377       
     1378        CmtSystem::scan_dir (dir, exp, list);
     1379       
     1380        if (list.size () > 0)
     1381          {
     1382            result = list[0];
     1383           
     1384            CmtSystem::basename (result, result);
     1385          }
     1386      }
     1387   
     1388    return (result);
     1389  }
     1390 
    14781391  /**
    14791392   *   We provide a path to a requirements file. From it we read the use
    14801393   *  statements, and we try to checkout the corresponding packages.
     1394   *
     1395   *   A boolean return tells if any recursion occurred.
    14811396   */
    1482   void checkout_from_requirements (const cmt_string& requirements_path)
     1397  bool checkout_from_requirements (const cmt_string& requirements_path)
    14831398  {
    14841399    static cmt_regexp expression ("^[ \t]*use[ \t]");
     
    14911406    p1.run (text, expression);
    14921407
     1408    bool result = (p1.result () != "");
    14931409    RecursivePass2 p2 (*this);
    14941410    p2.run (p1.result ());
     1411
     1412    return (result);
    14951413  }
    14961414
     
    15071425    text.read (file_name);
    15081426
     1427    CvsImplementation& me = *this;
     1428    CvsImplementation saved;
     1429    saved = me;
     1430    cmt_string here = CmtSystem::pwd ();
     1431
    15091432    RecursivePass3 p3;
    15101433    p3.run (text, expression);
     
    15121435    RecursivePass4 p4 (*this);
    15131436    p4.run (p3.result ());
     1437
     1438    Grep grep;
     1439
     1440    grep.run (text, "container");
     1441    cmt_string container = grep.result ();
     1442
     1443    if (container != "")
     1444      {
     1445        static cmt_regexp container_expression ("^[ \t]*container[ \t]");
     1446
     1447        add_cmtpath (here);
     1448
     1449        cout << "  # --> now getting project packages from the " << container << " " << here << endl;
     1450
     1451        CmtSystem::cd (here);
     1452
     1453        RecursivePass1 p1;
     1454        p1.run (text, container_expression);
     1455
     1456        RecursivePass2 p2 (*this);
     1457
     1458        m_home_dir = CmtSystem::pwd ();
     1459        p2.run (p1.result ());
     1460      }
     1461
     1462    CmtSystem::cd (here);
     1463    me = saved;
    15141464  }
    15151465
     
    15251475     - the CVS tag
    15261476   */
    1527   void do_checkout (const cmt_string& prefix,
    1528                     const cmt_string& package,
    1529                     const cmt_string& specified_version,
    1530                     const cmt_string& tag)
     1477  void do_checkout_phase2 (const cmt_string& offset,
     1478                           const cmt_string& product,
     1479                           const cmt_string& specified_version,
     1480                           const cmt_string& tag)
    15311481  {
    15321482    if (m_verbose)
    15331483      {
    1534         cout << "#CMT> checkout_package> prefix=" << prefix
    1535              << " " << structure_info << "=" << package
     1484        cout << "#CMT> do_checkout_phase2> offset=" << offset
     1485             << " " << structure_info << "=" << product
    15361486             << " specified_version=" << specified_version
     1487             << " tag=" << tag
     1488             << " pwd=" << CmtSystem::pwd ()
    15371489             << endl;
    15381490      }
     
    15401492    cmt_string version = specified_version;
    15411493    cmt_string empty;
    1542     cmt_string full_prefix;
    1543    
    1544     full_prefix = m_offset;
    1545     full_prefix += prefix;
     1494    cmt_string full_offset;
     1495
     1496    full_offset = m_cvs_offset;
     1497    full_offset += offset;
    15461498   
    15471499    cmt_string echo_ppath;
    15481500   
    1549     if (prefix != "")
     1501    if (offset != "")
    15501502      {
    15511503        echo_ppath = " path ";
    1552         echo_ppath += prefix;
     1504        echo_ppath += offset;
    15531505      }
    15541506   
    15551507    if (version == "")
    15561508      {
    1557         cout << "# ================= No version specified for " << structure_info << " " << package << endl;
     1509        cout << "# ================= No version specified for " << structure_info << " " << product << endl;
    15581510        return;
    15591511      }
     
    15611513    //
    15621514    //  First make an attempt to locate the specified version of
    1563     //  this package "as-it-is" in the work area.
     1515    //  this product "as-it-is" in the work area.
    15641516    //   Since 'version' may contain wild-card, it's likely that
    15651517    //  we should not simply use CmtSystem::test_directory but
     
    15691521    cmt_string dir;
    15701522   
    1571     dir = build_version_directory (prefix, package, version);
    1572    
    1573     if (m_cmtcvstest)
    1574       cout << "## (testing dir= " << dir << ")" << endl;
     1523    dir = build_version_directory (offset, product, version);
    15751524   
    15761525    bool recursive = m_recursive;
    15771526   
    1578     /*
    1579       if (m_cmtcvstest)
    1580       {
    1581       cmt_string v = find_matching_version (dir);
    1582      
    1583       cout << "---> v=" << v << endl;
    1584       }
    1585     */
    1586    
    15871527    cmt_string effective_version = find_matching_version (dir);
    15881528   
     
    15911531        version = effective_version;
    15921532       
    1593         dir = build_version_directory (prefix, package, version);
    1594        
    1595         cout << "# ================= " << structure_info << " " << package
     1533        dir = build_version_directory (offset, product, version);
     1534       
     1535        cout << "# ================= " << structure_info << " " << product
    15961536             << " version " << version << echo_ppath
    15971537             << " already installed in " << dir << endl;
     
    16031543        bool at_head = false;
    16041544        cmt_string module;
     1545        cmt_string cvs_tag = (tag != "") ? tag : version;
    16051546       
    16061547        //
     
    16121553        //
    16131554       
    1614         if (version.find ("*") != cmt_string::npos)
    1615           {
    1616             cout << "# ================= " << structure_info << " " << package
    1617                  << " version " << version << echo_ppath
     1555        if (cvs_tag.find ("*") != cmt_string::npos)
     1556          {
     1557            cout << "# ================= " << structure_info << " " << product
     1558                 << " version " << cvs_tag << echo_ppath
    16181559                 << " has wild cards and will not be considered." << endl;
    16191560            return;
    16201561          }
    16211562       
    1622         if (!get_version (full_prefix, package, version,
    1623                           module, version, at_head))
     1563        if (!get_version (full_offset, product, cvs_tag,
     1564                          module, cvs_tag, at_head))
    16241565          {
    16251566            return;
    16261567          }
    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;
    16311568       
    16321569        if (m_head)
     
    16421579       
    16431580        //
    1644         // Make a second try after having selected a version from all the
    1645         // available versions compatible with the specified version
     1581        // Make a second try after having selected a CVS tag from all the
     1582        // available tags compatible with the specified version
    16461583        //
    1647        
    1648         dir = build_version_directory (prefix, package, version);
    1649        
     1584
     1585        if (tag == "")
     1586          {
     1587            // If tag was not specified, then the version directory has to match the CVS tag
     1588            // Otherwise the original version specification is kept for the directory.
     1589
     1590            version = cvs_tag;
     1591            dir = build_version_directory (offset, product, version);
     1592          }
     1593
    16501594        if (CmtSystem::test_directory (dir))
    16511595          {
    1652             cout << "# ================= " << structure_info << " " << package
     1596            cout << "# ================= " << structure_info << " " << product
    16531597                 << " version " << version << echo_ppath
    16541598                 << " already installed." << endl;
     
    16621606            //
    16631607           
    1664             if (!really_checkout (prefix, package, version, module, dir, at_head))
     1608            if (!really_checkout (offset, product, version, cvs_tag, module, dir, at_head))
    16651609              {
    1666                 cout << "# bad return from really_checkout_package" << endl;
     1610                cout << "# bad return from really_checkout_product" << endl;
    16671611                return;
    16681612              }
     
    16701614      }
    16711615   
    1672     /*
    1673       if (m_verbose)
    1674       {
    1675       cout << "#CMT> pwd.4=" << CmtSystem::pwd () << " structure=" << structure_info << endl;
    1676       }
    1677     */
    1678    
    16791616    //
    1680     //  Now reach the newly checked out package.
     1617    //  Now reach the newly checked out product.
    16811618    //
    16821619   
     
    16901627          {
    16911628            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         */
     1629            return;
     1630          }
    17011631       
    17021632        // Check if it is a true CMT package.
     
    17131643            dir += "cmt";
    17141644            CmtSystem::cd ("cmt");
    1715            
    1716             /*
    1717               if (m_verbose)
    1718               {
    1719               cout << "#CMT> pwd.5=" << CmtSystem::pwd () << endl;
    1720               }
    1721             */
    17221645           
    17231646            if (Cmt::get_current_structuring_style () == without_version_directory)
     
    17391662                dir += "mgr";
    17401663                CmtSystem::cd ("mgr");
    1741                
    1742                 /*
    1743                   if (m_verbose)
    1744                   {
    1745                   cout << "#CMT> pwd.6=" << CmtSystem::pwd () << endl;
    1746                   }
    1747                 */
    17481664              }
    17491665            else
    17501666              {
    1751                 cout << "# " << package << " not a CMT package" << endl;
     1667                cout << "# " << product << " not a CMT package" << endl;
    17521668                return;
    17531669              }
    17541670          }
    17551671       
    1756         //cout << "#   (recursive is " << recursive << ")" << endl;
    1757        
    17581672        if (recursive)
    17591673          {
    1760             checkout_from_requirements ("requirements");
     1674            cmt_string here = CmtSystem::pwd ();
     1675
     1676            bool did_recurse = checkout_from_requirements ("requirements");
     1677
     1678            CmtSystem::cd (here);
     1679
     1680            if (did_recurse) execute ("cmt -quiet broadcast cmt -quiet config");
    17611681          }
    17621682      }
     
    17721692          {
    17731693            cout << "#CMT> Project directory not created " << dir << endl;
     1694            return;
    17741695          }
    17751696       
     
    17821703        if (!CmtSystem::test_file (file_name))
    17831704          {
    1784             cout << "# " << package << " not a CMT project" << endl;
     1705            cout << "# " << product << " not a CMT project" << endl;
    17851706            return;
    17861707          }
     
    17901711            checkout_from_project_file (file_name);
    17911712          }
     1713
     1714        cout << "# ================= Project " << product << " completed" << endl;
     1715
    17921716      }
    17931717  }
     
    18031727
    18041728   */
    1805   void do_checkout (const cmt_string& module, const cmt_string& version_tag)
    1806   {
    1807     //CMTPATH=${CMTPATH}:${m_home_dir}; export CMTPATH
     1729  void do_checkout_phase1 (const cmt_string& module,
     1730                           const cmt_string& version_dir,
     1731                           const cmt_string& version_tag)
     1732  {
     1733    add_cmtpath (m_home_dir);
    18081734
    18091735    History& h = History::instance ();
     
    18201746      }
    18211747
    1822     cmt_string prefix;
    1823     cmt_string package;
     1748    cmt_string offset;
     1749    cmt_string product;
    18241750    cmt_string version;
     1751    cmt_string tag;
    18251752   
    18261753    if (version_tag == "")
     
    18291756       
    18301757        cmt_string m;
    1831         m = m_offset;
     1758        m = m_cvs_offset;
    18321759        m += module;
    18331760       
    1834         show_cvs_infos (m);
     1761        get_cvs_infos_with_offset (m);
    18351762       
    18361763        if (error_info != "")
     
    18401767          }
    18411768
    1842         if (tags_top_info != "") version = tags_top_info;
    1843         else version = tags_info;
     1769        if (tags_top_info != "") tag = tags_top_info;
     1770        else tag = tags_info;
    18441771       
    1845           //if (CmtSystem::testenv ("CMTTESTAWK")) cout << "version=" << version << endl;
    1846 
    1847         cut.run (version);
     1772        cut.run (tag);
    18481773       
    1849         version = cut.result ();
    1850 
    1851           //if (CmtSystem::testenv ("CMTTESTAWK")) cout << "version=" << version << endl;
     1774        tag = cut.result ();
    18521775      }
    18531776    else
    18541777      {
    1855         version = version_tag;
    1856       }
    1857 
    1858     CmtSystem::dirname (module, prefix);
    1859     CmtSystem::basename (module, package);
     1778        tag = version_tag;
     1779      }
     1780
     1781    version = (version_dir == "") ? tag : version_dir;
     1782
     1783    CmtSystem::dirname (module, offset);
     1784    CmtSystem::basename (module, product);
    18601785   
    18611786    cmt_string top_dir;
     
    18651790    top_dir += m_checkout_dir;
    18661791    top_dir += CmtSystem::file_separator ();
    1867     top_dir += prefix;
     1792    top_dir += offset;
    18681793    top_dir += CmtSystem::file_separator ();
    1869     top_dir += package;
     1794    top_dir += product;
    18701795    top_dir += CmtSystem::file_separator ();
    18711796    top_dir += version;
     
    18761801      {
    18771802        cout << "#CMT> about to checkout " << structure_info
    1878              << " " << package << " version " << version << " into " << top_dir << endl;
    1879       }
    1880    
    1881     do_checkout (prefix, package, version, "");
    1882 
    1883     /*
    1884     if (m_verbose)
    1885       {
    1886         cout << "#CMT> after do_checkout pwd.7=" << CmtSystem::pwd () << " top_dir=" << top_dir << endl;
    1887       }
    1888     */
     1803             << " " << product << " version " << version << " into " << top_dir << endl;
     1804      }
     1805
     1806    static const cmt_string empty;
     1807    do_checkout_phase2 (offset, product, version, tag);
    18891808
    18901809    if (m_simulation) return;
    18911810
    18921811    if (!CmtSystem::cd (top_dir)) return;
    1893 
    1894     /*
    1895     if (m_verbose)
    1896       {
    1897         cout << "#CMT> pwd.8=" << CmtSystem::pwd () << endl;
    1898       }
    1899     */
    19001812
    19011813    if (structure_info == "project")
     
    19071819        file_name += "project.cmt";
    19081820       
    1909         if (CmtSystem::test_file (file_name))
    1910           {
    1911             cout << "#CMT> project " << package << " has been checked out" << endl;
    1912           }
    1913         else
    1914           {
    1915             cout << "# " << package << " was not properly checked out and is missing its cmt/project.cmt file" << endl;
     1821        if (!CmtSystem::test_file (file_name))
     1822          {
     1823            cout << "# " << product << " was not properly checked out and is missing its cmt/project.cmt file" << endl;
    19161824            return;
    19171825          }
     
    19301838            top_dir += "cmt";
    19311839            CmtSystem::cd ("cmt");
    1932            
    1933             /*
    1934               if (m_verbose)
    1935               {
    1936               cout << "#CMT> pwd.9=" << CmtSystem::pwd () << endl;
    1937               }
    1938             */
    19391840          }
    19401841        else
     
    19491850                top_dir += "mgr";
    19501851                CmtSystem::cd ("mgr");
    1951                
    1952                 /*
    1953                   if (m_verbose)
    1954                   {
    1955                   cout << "#CMT> pwd.10=" << CmtSystem::pwd () << endl;
    1956                   }
    1957                 */
    19581852              }
    19591853            else
    19601854              {
    1961                 cout << "# " << package << " was not properly checked out and is missing its cmt/requirements file" << endl;
     1855                cout << "# " << product << " was not properly checked out and is missing its cmt/requirements file" << endl;
    19621856                return;
    19631857              }
     
    19661860        if (m_verbose)
    19671861          {
    1968             cout << "#CMT> package " << package << " has been checked out" << endl;
    1969           }
    1970        
    1971         if (m_recursive)
    1972           {
    1973             if (m_verbose || m_simulation)
    1974               {
    1975                 cout << "#CMT> Executing [" << "cmt -quiet broadcast cmt -quiet config" << "]" << endl;
    1976               }
    1977            
    1978             if (!m_simulation)
    1979               {
    1980                 CmtSystem::execute ("cmt -quiet broadcast cmt -quiet config");
    1981               }
    1982           }
    1983         else
    1984           {
    1985             if (m_verbose || m_simulation)
    1986               {
    1987                 cout << "#CMT> Executing [" << "cmt -quiet config" << "]" << endl;
    1988               }
    1989        
    1990             if (!m_simulation)
    1991               {
    1992                 CmtSystem::execute ("cmt -quiet config");
    1993               }
     1862            cout << "#CMT> product " << product << " has been checked out" << endl;
     1863          }
     1864       
     1865        if (!m_recursive)
     1866          {
     1867            execute ("cmt -quiet config");
    19941868          }
    19951869      }
     
    20031877    cout << "   modifier :" << endl;
    20041878    cout << "   -l        Do not process used packages (default)." << endl;
    2005     cout << "   -R        Process used packages recursively." << endl;
     1879    cout << "   -R        Process used products recursively." << endl;
    20061880    cout << "   -r rev    Check out version tag. (is sticky)" << endl;
     1881    cout << "   -vd dir   Use this version directory instead of CVS tag." << endl;
    20071882    cout << "   -d dir    Check out into dir instead of module name." << endl;
    20081883    cout << "   -o offset Offset in the CVS repository" << endl;
     
    20361911      }
    20371912   
    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 ("//", "/");
     1913    m_cvs_offset = CmtSystem::getenv ("CMTCVSOFFSET");
     1914    if (m_cvs_offset != "")
     1915      {
     1916        m_cvs_offset += "/";
     1917        m_cvs_offset.replace_all ("//", "/");
    20521918      }
    20531919   
     
    20641930        else
    20651931          {
    2066             show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), option);
     1932            get_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), option);
    20671933           
    20681934            if (error_info != "")
     
    21081974    cmt_string out;
    21091975   
    2110     show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), module);
     1976    get_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), module);
    21111977   
    21121978    if (error_info != "")
     
    21281994    cmt_string out;
    21291995   
    2130     show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module);
     1996    get_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module);
    21311997   
    21321998    if (error_info != "")
     
    21482014    cmt_string out;
    21492015   
    2150     show_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module);
     2016    get_cvs_infos (CmtSystem::getenv ("CMTCVSOFFSET"), (module == "") ? "." : module);
    21512017   
    21522018    if (error_info != "")
     
    21792045      }
    21802046   
    2181     if (CmtSystem::getenv ("CMTCVSTEST") != "")
    2182       {
    2183         m_cmtcvstest = true;
    2184       }
    2185     else
    2186       {
    2187         m_cmtcvstest = false;
    2188       }
    2189    
    21902047    m_home_dir = CmtSystem::pwd ();
    21912048    m_checkout_dir = "";
    2192     m_offset = "";
    2193     m_branch_suffix = "";
    2194    
     2049    m_version_dir = "";
     2050    m_cvs_offset = "";
     2051
    21952052    cmt_string module;
    21962053   
     
    22012058   
    22022059    bool need_checkout_dir = false;
    2203     bool need_offset = false;
     2060    bool need_cvs_offset = false;
    22042061    bool need_requirements_file = false;
     2062    bool need_version_dir = false;
    22052063   
    22062064    m_simulation = false;
     
    22082066    m_verbose = false;
    22092067   
    2210     bool need_branch_suffix = false;
    2211    
    22122068    m_head = true;
    22132069   
    2214     m_offset = CmtSystem::getenv ("CMTCVSOFFSET");
    2215     if (m_offset != "")
    2216       {
    2217         m_offset += "/";
    2218         m_offset.replace_all ("//", "/");
     2070    m_cvs_offset = CmtSystem::getenv ("CMTCVSOFFSET");
     2071    if (m_cvs_offset != "")
     2072      {
     2073        m_cvs_offset += "/";
     2074        m_cvs_offset.replace_all ("//", "/");
    22192075      }
    22202076   
     
    22412097            m_checkout_dir = option;
    22422098          }
    2243         else if (need_offset)
    2244           {
    2245             need_offset = false;
    2246             m_offset = option;
    2247             m_offset += '/';
    2248             m_offset.replace_all ("//", "/");
    2249           }
    2250         else if (need_branch_suffix)
    2251           {
    2252             need_branch_suffix = false;
    2253             m_branch_suffix = "-";
    2254             m_branch_suffix += option;
     2099        else if (need_version_dir)
     2100          {
     2101            need_version_dir = false;
     2102            m_version_dir = option;
     2103          }
     2104        else if (need_cvs_offset)
     2105          {
     2106            need_cvs_offset = false;
     2107            m_cvs_offset = option;
     2108            m_cvs_offset += '/';
     2109            m_cvs_offset.replace_all ("//", "/");
    22552110          }
    22562111        else if (need_requirements_file)
     
    22812136            else if (option == "-o")
    22822137              {
    2283                 need_offset = true;
     2138                need_cvs_offset = true;
    22842139              }
    22852140            else if (option == "-n")
     
    22912146                m_verbose = true;
    22922147              }
    2293             else if (option == "-branch")
     2148            else if (option == "-vd")
    22942149              {
    2295                 need_branch_suffix = true;
     2150                need_version_dir = true;
    22962151              }
    22972152            else if (option == "-requirements")
     
    23112166            else
    23122167              {
    2313                 do_checkout (option, version_tag);
     2168                do_checkout_phase1 (option, m_version_dir, version_tag);
    23142169              }
    23152170          }
     
    23212176  bool m_recursive;
    23222177  bool m_head;
    2323   bool m_cmtcvstest;
    23242178  bool m_verbose;
    23252179  bool m_simulation;
     
    23272181  cmt_string m_home_dir;
    23282182  cmt_string m_checkout_dir;
    2329   cmt_string m_offset;
    2330   cmt_string m_branch_suffix;
     2183  cmt_string m_version_dir;
     2184  cmt_string m_cvs_offset;
    23312185
    23322186  cmt_string m_protocol_level;
     
    25992453  else
    26002454    {
    2601       m_cvs.do_checkout (path, package, version, "");
     2455      static const cmt_string empty;
     2456      m_cvs.do_checkout_phase2 (path, package, version, empty);
    26022457    }
    26032458}
     
    26782533    }
    26792534 
    2680   cout << "  #     " << project << " " << version << endl;
     2535  cout << "  #     " << project << " " << version << " " << tag << endl;
    26812536}
    26822537
     
    27602615  else
    27612616    {
    2762       m_cvs.do_checkout ("", project, version, tag);
     2617      static const cmt_string empty;
     2618      m_cvs.do_checkout_phase2 (empty, project, version, tag);
    27632619    }
    27642620}
  • CMT/HEAD/src/setup.tcsh

    r11 r45  
    55#-----------------------------------------------------------
    66
    7 complete cmt p/1/'(broadcast build check check_files checkout co cleanup config create expand filter help lock remove run setup show system unlock version cvstags cvsbranches cvssubpackages)'/ \
     7complete cmt p/1/'(broadcast build check check_files checkout co cleanup config create expand filter help lock remove run setup show system unlock version cvstags cvsbranches cvssubpackages cvssubprojects)'/ \
    88 n/build/'(CMT_pacman constituent_makefile constituents_makefile dependencies library_links make_setup msdev os9_makefile prototype readme tag_makefile temporary_name triggers win_makefile)'/ \
    99 n/show/'(action action_names action_value actions all_tags applied_patterns author branches clients cmtpath_patterns constituent constituent_names constituents cycles fragment fragments groups include_dirs language languages macro macro_names macro_value macros manager packages path pattern patterns projects pwd set set_names set_value sets strategies tags use_paths uses versions)'/ \
  • CMT/HEAD/src/setup.zsh

    r11 r45  
    1212   function cmt_default_path { d=`dirname ${CMTROOT}`; reply=(`dirname ${d}`) }; \
    1313   function cmt_patterns { reply=(`cmt -quiet show pattern_names`) }; \
    14    compctl -k '(broadcast,build,check,check_files,checkout,co,cleanup,config,create,create_project,expand,filter,help,lock,remove,run,setup,show,system,unlock,version,cvstags,cvsbranches,cvssubpackages)' -x \
     14   compctl -k '(broadcast,build,check,check_files,checkout,co,cleanup,config,create,create_project,expand,filter,help,lock,remove,run,setup,show,system,unlock,version,cvstags,cvsbranches,cvssubpackages,cvssubprojects)' -x \
    1515   'c[-1,broadcast]' -k '(-begin=,-select=,-exclude=,-local,-global,-depth=)' - \
    1616   's[build],c[-1,build]' -k '(CMT_pacman, constituent_makefile,constituents_makefile,dependencies,library_links,make_setup,msdev,os9_makefile,prototype,readme,tag_makefile,temporary_name,triggers,win_makefile)' - \
Note: See TracChangeset for help on using the changeset viewer.