CVSSourceCodeManager.st
author penk
Wed, 15 Dec 2004 11:32:43 +0100
changeset 1407 f8314a9474cf
parent 1406 725a5b2866f2
child 1408 762e5320c296
permissions -rw-r--r--
tempDir handling
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     1
"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     3
              All Rights Reserved
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     4
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     5
 This software is furnished under a license and may be used
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     6
 only in accordance with the terms of that license and with the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     8
 be provided or otherwise made available to, or used by, any
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
     9
 other person.  No title to or ownership of the software is
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    10
 hereby transferred.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    11
"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    12
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    13
"{ Package: 'stx:libbasic3' }"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    14
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    15
AbstractSourceCodeManager subclass:#CVSSourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    16
	instanceVariableNames:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    17
	classVariableNames:'Verbose CVSRoot CVSWorkDirectory RemoteCVS CVSBinDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    18
		CVSModuleRoots CMD_checkout CVSTempDir DisabledModules'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    19
	poolDictionaries:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    20
	category:'System-SourceCodeManagement'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    21
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    22
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    23
!CVSSourceCodeManager class methodsFor:'documentation'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    24
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    25
copyright
130
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    26
"
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    27
 COPYRIGHT (c) 1995 by Claus Gittinger
807
f84a9377278e Fix .stxCvsDummy / import stuff.
Stefan Vogel <sv@exept.de>
parents: 806
diff changeset
    28
              All Rights Reserved
130
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    29
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    30
 This software is furnished under a license and may be used
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    31
 only in accordance with the terms of that license and with the
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    33
 be provided or otherwise made available to, or used by, any
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    34
 other person.  No title to or ownership of the software is
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    35
 hereby transferred.
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    36
"
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    37
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    38
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    39
documentation
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    40
"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    41
    SourceCodeManager which accesses the sourcecode through cvs.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    42
    It requires the shell environment variable CVSROOT to be set
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    43
    to the top of the repository tree. (or alternatively, the CVSRoot
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    44
    variable being set by a private.rc file).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    45
    Under that top, for each module (especially the stx module itself), 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    46
    a subdirectory containing that modules directories must exist.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    47
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    48
    If not specified otherwise, the module defaults to 'stx'. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    49
    If a class has its home in another module, it has to be compiled
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    50
    with a corresponding entry in the package string (see below).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    51
    Within a module, classes are organized in classlibraries, and the corresponding
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    52
    source code is found in various subdirectories of CVSROOT. The directories
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    53
    name can also be provided by the package string - if not, it defaults to the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    54
    libraries name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    55
    The package string controls all this, and is REQUIRED in order for the sourceCodeManager
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    56
    to be able to retrieve a classes source.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    57
    The package strings format is:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    58
        '...any infotext....(sourceCodeInfo)'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    59
    the sourceCOdeInfo consists of multiple entries, separated by colons.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    60
    The following formats are allowed:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    61
        (libraryName)                   - module defaults to 'stx'; directory to the name of the library
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    62
        (foo/bar/x)                     - module defaults to 'stx'; dir is 'foo/bar/x'; library name defaults to x
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    63
        (module:directory:libname)      - specifies all components
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    64
    The first formats are intermediate, for backward compatibility. We urge everyone
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    65
    to use the last format (by changing the Make.proto files and add a -P flag to
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    66
    the stc compiler flags (see libbasic/Make.proto as an example).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    67
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    68
    Notice, that the sourceCodeManager is (currently) only consulted, if no
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    69
    source subdirectory exists, or no source file is found there. If it does exist,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    70
    that one is supposed to contain an up-to-date version of the classes source
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    71
    (this is temporary - in the future the probe order will be reversed, trying
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    72
     the source repository first).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    73
    The source directory is required for systems which do NO source code control.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    74
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    75
    Setup:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    76
        - make certain, that the commands 'cvs' and 'co' are available on your system.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    77
        - add setup for the CVSROOT environment variable to your .bashrc / .login / .profile
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    78
        - Make certain that either no local source directory exists, or it is empty or it contains
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    79
          only source code for files NOT found in the repository (this will not be required in future versions).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    80
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    81
    Caveat:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    82
        currently, the rcs container is accessed directly, since cvs mangles the files ident-string and
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    83
        thus does not correctly recreate the original file (all source is offset by some characters w.r.t. the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    84
        compiled file).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    85
        Therefore, sevrer-mode CVS is not supported.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    86
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    87
    [class variables:]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    88
        CVSTempDir      <String | nil>  where a directory tree is
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    89
                                        generated temporarily for checkin/checkout
1407
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
    90
                                        (default is nil -> systems tmp-dir)
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    91
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    92
        CVSRoot         <String>        the CVS root. Imported from the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    93
                                        CVSROOT shell variable.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    94
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    95
        RemoteCVS       <Boolean>       if true, remote CVS access is used
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    96
                                        (i.e. via a socket to a CVS server).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    97
                                        if false, disk access is used;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    98
                                        files in CVSRoot must be accessable.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
    99
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   100
        CVSWorkDirectory                not yet supported/implemented.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   101
                                        PLANNED: name of a directory hierarchy,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   102
                                        which is kept in sync with the current
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   103
                                        version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   104
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   105
        CVSBinDir                       where the CVS commands are found
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   106
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   107
        CVSModuleRoots  <Directory>     per-module roots.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   108
                                        If empty, or no entry is found for a
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   109
                                        module is found, CVSRoot is used.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   110
                                        Otherwise, specifies a per-module CVSRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   111
                                        (allows multiple CVS hierarchies)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   112
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   113
    [author:]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   114
        Claus Gittinger
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   115
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   116
    [see also:]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   117
        ( cvs manual page :man: cvs )
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   118
        ( Coding style used in Smalltalk/X classes :html: programming/codingStyle.html )
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   119
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   120
    [restrictions:]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   121
        commercial version only
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   122
"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   123
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   124
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   125
examples
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   126
"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   127
    Default setup:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   128
        This setup accesses all sources from a single repository: /files/CVS.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   129
        Actually, this is the setup as used within eXept for development.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   130
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   131
            CVSSourceCodeManager initializeForRepository:'/files/CVS'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   132
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   133
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   134
    Dual repository setup:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   135
        This accesses all ST/X standard classes' source from the /files/CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   136
        repository, while your private classes are created in and accessed from
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   137
        '/files/myCVS'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   138
        This setup is useful, if you need revision management on the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   139
        ST/X standard classes as well as for your own classes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   140
        In order to do this, you should (manually) check in all ST/X classes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   141
        into a private repository WHILE preserving the original revision numbers.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   142
        A shell-procedure similar to:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   143
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   144
            for i in lib*/*.st
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   145
            do
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   146
                id=`ident $i`
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   147
                set $id
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   148
                rev=$3
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   149
                ci -r$rev <CVSDIR>/$i $i
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   150
            done
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   151
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   152
        should acomplish this.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   153
        Now, that you have all ST/X files in your own repository (and with the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   154
        original revision numbers), access is possible by defining CVSROOT
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   155
        as above. However, in order to have your own files being stored in
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   156
        another repository, you have to give a per-module repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   157
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   158
        This defines the default repository (for your containers):
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   159
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   160
            CVSSourceCodeManager initializeForRepository:'/files/myCVS'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   161
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   162
        and this specifies a repository for all standard ST/X classes (in the stx module):
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   163
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   164
            CVSSourceCodeManager repositoryName:'/files/CVS' forModule:'stx'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   165
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   166
    Dual repository setup for eXept customers with a full licence
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   167
    (these can access our in-house master repository, for convenient software update
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   168
     and uploading):
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   169
        All class sourcees under the 'stx' module (i.e. packageID is 'stx:*') can be accessed
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   170
        from the eXept cvs server (i.e. CVSROOT for them is :pserver:userName@exept.de:/files/CVS/stc).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   171
        All local classes should be maintained in and accessed from a local cvs repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   172
        such as '/files/myCVS'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   173
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   174
        Then, tell the CVSSourceCodeManager about this;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   175
        first the default repository:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   176
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   177
            CVSSourceCodeManager initializeForRepository:'/files/myCVS'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   178
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   179
        and the repository for all standard ST/X classes (in the stx module):
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   180
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   181
            CVSSourceCodeManager repositoryName:':pserver:userName@exept.de:/files/CVS' forModule:'stx'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   182
"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   183
! !
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   184
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   185
!CVSSourceCodeManager class methodsFor:'initialization'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   186
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   187
forgetDisabledModules
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   188
    DisabledModules := nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   189
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   190
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   191
initCommands
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   192
    CMD_checkout := 'cvs -n checkout %1'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   193
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   194
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   195
initialize
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   196
    "check if $CVSROOT (the shell variable) or CVSRoot (the smalltalk global)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   197
     is set, check if cvs commands can be executed and install myself as the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   198
     SourceCodeManager if this works out ok"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   199
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   200
    | s f top ok triedPath cvsCmd cmdName |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   201
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   202
    DisabledModules := nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   203
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   204
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   205
    "/ if CVSROOT is non-empty and both cvs and co are available
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   206
    "/ as commands, assume this system uses a cvs source code management.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   207
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   208
    CVSRoot ifNil:[
1407
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   209
        CVSRoot := OperatingSystem getEnvironment:'CVSROOT'.
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   210
        CVSRoot ifNil:[
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   211
            "disabled since $CVSROOT is not set"
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   212
            ^ self
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   213
        ].
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   214
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   215
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   216
    OperatingSystem isMSDOSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   217
        cvsCmd := 'cvs.exe'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   218
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   219
        cvsCmd := 'cvs'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   220
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   221
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   222
    CVSBinDir size > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   223
        OperatingSystem isMSDOSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   224
            cmdName := CVSBinDir asFilename constructString:cvsCmd.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   225
            ( OperatingSystem canExecuteCommand:cmdName) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   226
                CVSBinDir := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   227
            ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   228
                CVSBinDir := CVSBinDir asFilename pathName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   229
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   230
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   231
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   232
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   233
    CVSBinDir size == 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   234
        CVSBinDir := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   235
        (ok := OperatingSystem canExecuteCommand:cvsCmd) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   236
            "/ mhmh - no cvs;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   237
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   238
            OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   239
                triedPath := #( '/usr/local/bin' ).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   240
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   241
                OperatingSystem isMSDOSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   242
                    triedPath := Array with:'c:\bin'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   243
                                        with:(Filename currentDirectory pathName)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   244
                                        with:(OperatingSystem stxBinDirPath ? 'c:\windows').
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   245
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   246
                    triedPath := #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   247
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   248
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   249
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   250
            triedPath do:[:eachTriedDir |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   251
                ok ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   252
                    (OperatingSystem canExecuteCommand:(eachTriedDir asFilename constructString:cvsCmd)) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   253
                        ok := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   254
                        CVSBinDir := eachTriedDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   255
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   256
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   257
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   258
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   259
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   260
        ok := OperatingSystem canExecuteCommand:(CVSBinDir asFilename constructString:cvsCmd).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   261
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   262
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   263
    ok ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   264
        'CVSSourceCodeManager [warning]: disabled since no >> cvs << command found' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   265
        ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   266
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   267
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   268
"/    (OperatingSystem canExecuteCommand:(CVSBinDir , 'co')) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   269
"/        'CVSSourceCodeManager [warning]: limited functionality - no >> co << command found' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   270
"/    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   271
"/    (OperatingSystem canExecuteCommand:(CVSBinDir , 'rlog')) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   272
"/        'CVSSourceCodeManager [warning]: limited functionality - no >> rlog << command found' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   273
"/    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   274
"/    (OperatingSystem canExecuteCommand:(CVSBinDir , 'patch')) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   275
"/        'CVSSourceCodeManager [warning]: limited functionality - no >> patch << command found' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   276
"/    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   277
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   278
    RemoteCVS := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   279
    UseWorkTree := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   280
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   281
    CacheDirectoryName ifNil:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   282
        self initCacheDirPath.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   283
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   284
    CachingSources ifNil:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   285
        CachingSources := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   286
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   287
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   288
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   289
    "/ check if there is an stx directory there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   290
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   291
    ((f := CVSRoot asFilename) isDirectory 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   292
    and:[(top := f construct:'stx') isDirectory
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   293
    and:[top isReadable]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   294
        RemoteCVS := false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   295
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   296
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   297
    Smalltalk at:#SourceCodeManager put:self.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   298
    DefaultManager := self.    
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   299
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   300
    ('CVSSourceCodeManager [info]: repository CVSROOT is ''' , CVSRoot , '''.') infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   301
    RemoteCVS ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   302
        'CVSSourceCodeManager [info]: assume remote CVS mode (no stx found in CVSROOT)' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   303
        ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   304
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   305
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   306
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   307
    "/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   308
    "/ if non-nil, a working tree is kept there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   309
    "/ and updated/commited files are not removed.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   310
    "/ If you use a regular (make-) tree, 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   311
    "/ set WorkTreeDirectoryName (or the environment variable) to that.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   312
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   313
    "/ this is not yet finished.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   314
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   315
    s := OperatingSystem getEnvironment:'STX_WORKTREE'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   316
    s notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   317
        WorkTreeDirectoryName := s.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   318
        UseWorkTree := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   319
    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   320
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   321
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   322
     AbstractSourceCodeManager initialize
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   323
     CVSSourceCodeManager initialize
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   324
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   325
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   326
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   327
     CVSRoot := '/files/CVS'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   328
     AbstractSourceCodeManager initialize.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   329
     CVSSourceCodeManager initialize.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   330
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   331
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   332
    "Created: / 4.11.1995 / 19:14:38 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   333
    "Modified: / 19.12.1995 / 14:25:46 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   334
    "Modified: / 5.12.2001 / 18:52:00 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   335
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   336
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   337
initializeForRepository:aDirectoryName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   338
    "set the global CVSROOT directory (i.e. the repositories name).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   339
     And reinitialize. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   340
     Can be used from the launcher to change/configure the repository."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   341
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   342
    self repositoryName:aDirectoryName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   343
    AbstractSourceCodeManager initialize.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   344
    CVSSourceCodeManager initialize.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   345
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   346
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   347
     CVSSourceCodeManager initializeForRepository:'/files/CVS'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   348
     CVSSourceCodeManager initializeForRepository:'ibm:/files/CVS'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   349
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   350
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   351
    "Created: / 13.8.1997 / 17:20:57 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   352
    "Modified: / 25.9.1997 / 12:28:05 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   353
    "Modified: / 2.11.1997 / 17:08:27 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   354
! !
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   355
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   356
!CVSSourceCodeManager class methodsFor:'accessing'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   357
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   358
cvsBinDirectory
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   359
    "return the name of the bin repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   360
     Thats the directory, where the cvs / cvs.exe command is found."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   361
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   362
    ^ CVSBinDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   363
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   364
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   365
cvsBinDirectory:aString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   366
    "set the name of the bin repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   367
     Thats the directory, where the cvs / cvs.exe command is found."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   368
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   369
    aString isEmpty ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   370
        CVSBinDir := aString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   371
    ] ifFalse:[        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   372
        CVSBinDir := aString asFilename pathName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   373
        (CVSBinDir endsWith:Filename separator) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   374
            CVSBinDir := CVSBinDir copyWithoutLast:1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   375
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   376
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   377
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   378
1407
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   379
cvsTmpDirectory
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   380
    "return the name of the tmp repository.
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   381
     Thats the directory, where temporary files are created for checkin/checkout.
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   382
     If nil, the systems default tempDirectory is used."
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   383
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   384
    ^ (CVSTempDir ? Filename tempDirectory pathName)
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   385
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   386
    "
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   387
     CVSTempDir := nil   
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   388
    "
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   389
!
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   390
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   391
cvsTmpDirectory:aPathNameString
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   392
    "set the name of the tmp repository.
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   393
     Thats the directory, where temporary files are created for checkin/checkout.
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   394
     If nil, the systems default tempDirectory is used."
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   395
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   396
    CVSTempDir := aPathNameString
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   397
!
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   398
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   399
repositoryName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   400
    "return the name of the global repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   401
     This is used, if no per-module repository is defined."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   402
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   403
    ^ CVSRoot
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   404
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   405
    "Created: 14.9.1996 / 13:22:05 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   406
    "Modified: 19.9.1997 / 06:12:02 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   407
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   408
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   409
repositoryName:aDirectoryName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   410
    "set the name of the repository;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   411
     thats the name of the global CVSROOT directory, which is used 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   412
     if no specific repository was defined for a module.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   413
     Can be used from an rc-script, to override the CVSROOT shell 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   414
     variable setting."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   415
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   416
    DisabledModules := nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   417
    CVSRoot := aDirectoryName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   418
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   419
    "Created: 14.9.1996 / 13:22:24 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   420
    "Modified: 19.9.1997 / 06:10:31 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   421
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   422
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   423
repositoryName:aRepositoryName forModule:aModuleName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   424
    "set the CVSROOT directory which provides the sources for all 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   425
     classes in a particular module.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   426
     This can be used from an rc-script, to specify a repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   427
     for a particular module.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   428
     If left unspecified, the global (i.e. fallBack) repository is used."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   429
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   430
    DisabledModules := nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   431
    CVSModuleRoots isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   432
        CVSModuleRoots := Dictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   433
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   434
    CVSModuleRoots at:aModuleName put:aRepositoryName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   435
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   436
    "Modified: 19.9.1997 / 06:09:40 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   437
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   438
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   439
repositoryNameForModule:aModuleName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   440
    "return the CVSROOT directory which provides the sources for all 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   441
     classes in a particular module.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   442
     Nil is returned for unspecified moduleRoots; in this case, 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   443
     the global (i.e. fallBack) repository will be used for source access."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   444
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   445
    CVSModuleRoots isNil ifTrue:[^nil].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   446
    ^ CVSModuleRoots at:aModuleName ifAbsent:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   447
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   448
    "Modified: 19.9.1997 / 06:09:40 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   449
    "Created: 19.9.1997 / 06:13:06 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   450
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   451
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   452
repositoryNamesPerModule
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   453
    "return the dictionary, which associates CVSRoots to module names.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   454
     If no entry is contained in this dictionary for some module,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   455
     the default cvsRoot (CVSRoot) will be used."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   456
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   457
    ^ CVSModuleRoots ? (Dictionary new)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   458
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   459
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   460
repositoryNamesPerModule:aDictionary
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   461
    "set the dictionary, which associates CVSRoots to module names.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   462
     If no entry is contained in this dictionary for some module,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   463
     the default cvsRoot (CVSRoot) will be used."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   464
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   465
    CVSModuleRoots := aDictionary
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   466
! !
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   467
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   468
!CVSSourceCodeManager class methodsFor:'private'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   469
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   470
checkOut:relativeFilename module:moduleDir in:tempdir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   471
    "checkout realtiveFilename in tempdir"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   472
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   473
    |cmd|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   474
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   475
    cmd := 'checkout -l ' , relativeFilename.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   476
    ^ self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   477
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   478
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   479
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   480
        log:false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   481
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   482
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   483
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   484
      self checkOut:'stx/libbasic/Integer.st' asFilename in:'/tmp' asFilename
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   485
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   486
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   487
    "Created: / 18.1.2000 / 20:30:01 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   488
    "Modified: / 18.1.2000 / 20:35:06 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   489
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   490
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   491
checkinTroubleDialog:title message:message log:log abortable:abortable option:optionTitle
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   492
    "trouble checking in - open a dialog"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   493
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   494
    ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   495
        checkinTroubleDialog:title 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   496
        message:message 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   497
        log:log 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   498
        abortable:abortable 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   499
        option:optionTitle 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   500
        option2:nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   501
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   502
    "Created: 10.12.1995 / 17:34:33 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   503
    "Modified: 12.9.1996 / 02:39:06 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   504
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   505
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   506
checkinTroubleDialog:title message:message log:log abortable:abortable option:optionTitle option2:optionTitle2
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   507
    ^self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   508
        checkinTroubleDialog:title 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   509
        message:message 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   510
        log:log 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   511
        abortable:abortable 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   512
        option:optionTitle 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   513
        option2:optionTitle2 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   514
        option3:nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   515
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   516
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   517
checkinTroubleDialog:title message:message log:log abortable:abortable option:optionTitle option2:optionTitle2 option3:optionTitle3
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   518
    "trouble checking in - open a dialog"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   519
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   520
    |l box list listView optionPressed option2Pressed option3Pressed|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   521
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   522
    l := log collect:[:line | line withTabsExpanded].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   523
    list := SelectionInList with:l.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   524
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   525
    box := Dialog new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   526
    box label:(title).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   527
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   528
    (box addTextLabel:message) borderWidth:0.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   529
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   530
    listView := SelectionInListView on:list.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   531
    listView disable.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   532
    listView height:200.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   533
    box addComponent:(HVScrollableView forView:listView miniScrollerH:true) tabable:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   534
    box addVerticalSpace.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   535
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   536
    abortable ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   537
        box addAbortButton
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   538
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   539
    optionTitle notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   540
        box addOkButton:(Button label:optionTitle action:[optionPressed := true. box hide]).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   541
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   542
    optionTitle2 notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   543
        box addOkButton:(Button label:optionTitle2 action:[option2Pressed := true. box hide]).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   544
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   545
    optionTitle3 notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   546
        box addOkButton:(Button label:optionTitle3 action:[option3Pressed := true. box hide]).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   547
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   548
    box addOkButton.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   549
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   550
    box extent:(box preferredExtent).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   551
    box minExtent:box extent.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   552
    box maxExtent:box extent.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   553
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   554
    box open.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   555
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   556
    box destroy.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   557
    optionPressed == true ifTrue:[^ #option].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   558
    option2Pressed == true ifTrue:[^ #option2].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   559
    option3Pressed == true ifTrue:[^ #option3].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   560
    ^ box accepted
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   561
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   562
    "Created: 9.9.1996 / 19:12:45 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   563
    "Modified: 12.9.1996 / 02:39:10 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   564
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   565
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   566
createEntryFor:pathInRepository module:aModule in:aDirectory revision:rev date:date special:special overwrite:overwrite
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   567
    "create an CVS/Repository and CVS/Entries entry for filename. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   568
     If the path does not exist, it will be created
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   569
     If overwrite is true, an existing Entry will be overwritten.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   570
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   571
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   572
    |filename cvsRoot cvsDir name entries firstPart s path|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   573
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   574
    filename := pathInRepository asFilename.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   575
    cvsDir := (aDirectory asFilename construct:'CVS') recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   576
    entries := cvsDir construct:'Entries'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   577
    name := filename baseName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   578
    firstPart := '/', name, '/'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   579
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   580
    s := entries readStreamOrNil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   581
    s isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   582
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   583
        "/ no Repository yet, create one
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   584
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   585
        |index root|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   586
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   587
        cvsRoot := self getCVSROOTForModule:aModule.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   588
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   589
        "/ match for first '/', to get the path portion without :pserver:host:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   590
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   591
        index := cvsRoot indexOf:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   592
        index > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   593
            root := cvsRoot copyFrom:(index).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   594
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   595
            root := cvsRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   596
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   597
        "/ create Repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   598
        "/ (notice, contents must be a Unix filename ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   599
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   600
        s := (cvsDir construct:'Repository') writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   601
        path := Filename components:filename directory name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   602
        path := path asStringWith:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   603
        s nextPutLine:(root, '/', path).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   604
        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   605
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   606
        "/ make new Entries file.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   607
        s := entries writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   608
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   609
        |newName newStream line|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   610
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   611
        newName := Filename newTemporaryIn:cvsDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   612
        newStream := newName writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   613
        [(line := s nextLine) notNil] whileTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   614
            (line findString:firstPart) ~= 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   615
                "/ we have found an entry for ourself.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   616
                "/ If we do not want to overwrite it, clean up everything and return.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   617
                overwrite ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   618
                    newName remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   619
                    newStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   620
                    s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   621
                    ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   622
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   623
                newStream nextPutLine:line
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   624
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   625
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   626
        newName renameTo:entries.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   627
        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   628
        s := newStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   629
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   630
    s nextPutLine:firstPart, rev, '/', date, '/', special, '/'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   631
    s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   632
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   633
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   634
        self createEntryFor:'foo/xxx/yyy' in:'foo/xxx' revision:'1.22' date:'dummy' special:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   635
        self createEntryFor:'foo/xxx/yyy' in:'foo/xxx' revision:'3.44' date:'new dummy' special:'special'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   636
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   637
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   638
    "Created: / 19.9.1997 / 06:21:02 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   639
    "Modified: / 7.1.1998 / 14:15:35 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   640
    "Modified: / 20.8.1998 / 00:12:11 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   641
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   642
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   643
createLocalDirectory:packageDir inModule:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   644
    "create a local working directory for module/package.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   645
     To speed up things, we checkout the file '.cvsignore', to create
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   646
     the whole tree. If the file is not present, we will create it as empty file.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   647
     Return the name of a temporary directory containing the package"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   648
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   649
    ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   650
        createLocalDirectory:packageDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   651
        inModule:moduleDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   652
        with:'.cvsignore'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   653
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   654
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   655
     self createLocalDirectory:'libbasic' inModule:'stx'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   656
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   657
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   658
    "Created: / 23.7.1999 / 19:14:28 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   659
    "Modified: / 26.7.1999 / 17:43:35 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   660
    "Modified: / 18.1.2000 / 20:56:19 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   661
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   662
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   663
createLocalDirectory:packageDir inModule:moduleDir with:fileToCheckout
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   664
    "create a local working directory for module/package, and checkout the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   665
     given file there.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   666
     Return the name of a temporary directory containing the package, or nil"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   667
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   668
    |path absolutePath tempdir workingDir unixPath|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   669
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   670
    path := (moduleDir asFilename construct:packageDir) construct:fileToCheckout.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   671
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   672
    tempdir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   673
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   674
        ('CVSSourceCodeManager [error]: no tempDir - cannot checkout') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   675
        ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   676
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   677
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   678
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   679
        OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   680
            unixPath := path name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   681
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   682
            OperatingSystem isVMSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   683
                self error:'VMS case not yet implemented'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   684
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   685
            unixPath := path name copy replaceAll:$\ with:$/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   686
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   687
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   688
        (self checkOut:unixPath module:moduleDir in:tempdir) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   689
            "dummy file does not exist, so create it"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   690
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   691
            absolutePath := tempdir construct:path.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   692
            absolutePath directory recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   693
            "now create the file"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   694
            (absolutePath writeStream close) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   695
                ('CVSSourceCodeManager [error]: cannot create dummy') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   696
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   697
                ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   698
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   699
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   700
            "now create the dummy file in the repository"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   701
            (self import:moduleDir in:tempdir) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   702
                ('CVSSourceCodeManager [error]: cannot import dummy') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   703
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   704
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   705
            "remove the path, so that checkout works"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   706
            (tempdir construct:moduleDir) recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   707
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   708
            "checkout the dummy, the intermediate directories will be created"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   709
            (self checkOut:unixPath module:moduleDir in:tempdir) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   710
                ('CVSSourceCodeManager [warning]: import failed (to create working dir)') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   711
"/false ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   712
"/                "/ manually create it
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   713
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   714
"/                (tempdir construct:unixPath) directory recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   715
"/                workingDir := tempdir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   716
"/                unixPath asFilename directory components do:[:each |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   717
"/                    self executeCVSCommand:('add ' , each) module:moduleDir inDirectory:workingDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   718
"/                    workingDir := workingDir construct:each.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   719
"/                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   720
"/                (absolutePath writeStream close) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   721
"/                    ('CVSSourceCodeManager [error]: cannot create dummy') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   722
"/                    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   723
"/                    ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   724
"/                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   725
"/                self executeCVSCommand:('add ' , fileToCheckout) module:moduleDir inDirectory:workingDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   726
"/                self executeCVSCommand:('commit ' , fileToCheckout) module:moduleDir inDirectory:workingDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   727
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   728
"/                ^ tempdir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   729
"/].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   730
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   731
                ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   732
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   733
        ].
1406
725a5b2866f2 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1405
diff changeset
   734
    ] ifCurtailed:[
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   735
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   736
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   737
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   738
    ^ tempdir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   739
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   740
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   741
     self createLocalDirectory:'libbasic' inModule:'stx'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   742
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   743
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   744
    "Modified: / 26.7.1999 / 17:43:35 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   745
    "Created: / 18.1.2000 / 20:55:52 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   746
    "Modified: / 18.1.2000 / 20:56:45 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   747
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   748
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   749
createTempDirectory:packageDir forModule:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   750
    "create a temp directory for checking out"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   751
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   752
    |tempdir dir|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   753
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   754
    "/ if CVSTempDir isNil, use current.
1407
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
   755
    tempdir := Filename newTemporaryIn:(self cvsTmpDirectory).
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   756
    tempdir exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   757
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   758
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   759
    OperatingSystem errorSignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   760
        'SourceCodemanager [error]: cannot create temporary directory' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   761
        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   762
    ] do:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   763
        tempdir makeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   764
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   765
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   766
    moduleDir notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   767
        dir := tempdir construct:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   768
        dir makeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   769
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   770
        packageDir notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   771
            dir := dir construct:packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   772
            dir recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   773
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   774
        dir exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   775
            tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   776
            'SourceCodemanager [error]: cannot create temporary directory' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   777
            ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   778
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   779
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   780
    ^ tempdir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   781
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   782
    "self createTempDirectory:'fooPackage' forModule:'fooModule'"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   783
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   784
    "Created: 9.12.1995 / 19:14:35 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   785
    "Modified: 19.12.1995 / 16:13:02 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   786
    "Modified: 18.8.1997 / 19:06:52 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   787
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   788
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   789
cvsTimeString:absoluteTime
1388
6fae02877da5 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 1387
diff changeset
   790
    "convert a Timestamp to a string suitable for the CVS/Entries file:
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   791
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   792
                         123456789012345678901234
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   793
                         Tue Dec 19 20:56:26 1995
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   794
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   795
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   796
    |date time stream|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   797
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   798
    date := absoluteTime asDate.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   799
    time := absoluteTime asTime.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   800
    stream := WriteStream on:(String new:24).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   801
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   802
    (#('Mon' 'Tue' 'Wed' 'Thu' 'Fri' 'Sat' 'Sun') at:(date dayInWeek)) printOn:stream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   803
    stream space.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   804
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   805
    (#('Jan' 'Feb' 'Mar' 'Apr' 'May' 'Jun' 'Jul' 'Aug' 'Sep' 'Oct' 'Nov' 'Dec') 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   806
        at:(date month)) printOn:stream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   807
    stream space.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   808
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   809
    date day printOn:stream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   810
    stream space.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   811
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   812
    time print24HourFormatOn: stream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   813
    stream space.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   814
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   815
    date year printOn:stream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   816
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   817
    ^ stream contents
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   818
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   819
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   820
    "
1388
6fae02877da5 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 1387
diff changeset
   821
     CVSSourceCodeManager cvsTimeString:(Timestamp now)
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   822
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   823
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   824
    "Modified: 20.12.1995 / 11:03:32 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   825
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   826
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   827
executeCVSCommand:cvsCommand module:moduleName inDirectory:dir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   828
    "execute command and prepend cvs command name and global options.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   829
     if dir ~= nil, execute command in that directory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   830
     This also leads to a log-entry to be added to cvs's logfile."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   831
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   832
    ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   833
        executeCVSCommand:cvsCommand 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   834
        module:moduleName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   835
        inDirectory:dir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   836
        log:true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   837
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   838
    "Modified: / 20.5.1998 / 16:07:28 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   839
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   840
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   841
executeCVSCommand:cvsCommand module:moduleName inDirectory:dir log:doLog
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   842
    "execute command and prepend cvs command name and global options.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   843
     if dir ~= nil, execute command in that directory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   844
     The doLog argument, if false supresses a logEntry to be added 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   845
     in the cvs log file (used when reading / extracting history)"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   846
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   847
    ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   848
        executeCVSCommand:cvsCommand module:moduleName inDirectory:dir log:doLog 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   849
        pipe:false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   850
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   851
1390
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   852
executeCVSCommand:cvsCommand module:moduleName inDirectory:dirArg log:doLog errorTo:errorStream
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   853
    "execute command and prepend cvs command name and global options.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   854
     execute command in the dirArg directory.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   855
     The doLog argument, if false supresses a logEntry to be added 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   856
     in the cvs log file (used when reading / extracting history)"
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   857
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   858
    |command cvsRoot rslt ok pathOfDir p dir|
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   859
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   860
    dir := dirArg asFilename.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   861
    pathOfDir := dir pathName.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   862
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   863
    cvsRoot := self getCVSROOTForModule:moduleName.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   864
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   865
    command := CVSBinDir.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   866
    command size > 0 ifTrue:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   867
        (command endsWith:Filename separator) ifFalse:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   868
            command := command , (Filename separator)
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   869
        ]
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   870
    ].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   871
    command := command , 'cvs'.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   872
    (command includes:Character space) ifTrue:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   873
        command := '"' , command , '"'        
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   874
    ].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   875
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   876
    doLog ifFalse:[
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
   877
"/ cvs  1.11.14 fails with -l option
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
   878
"/        command := command , ' -l'.
1390
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   879
    ].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   880
    command := command , ' -d "', cvsRoot, '" ', cvsCommand.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   881
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   882
    Verbose == true ifTrue:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   883
        ('CVSSourceCodeManager [info]: executing: ' , command , ' [in ' , pathOfDir , ']') infoPrintCR.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   884
    ].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   885
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   886
    Processor isDispatching ifFalse:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   887
        rslt := ok := OperatingSystem executeCommand:command 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   888
                                inputFrom:nil 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   889
                                outputTo:nil 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   890
                                errorTo:errorStream 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   891
                                auxFrom:nil
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   892
                                inDirectory:pathOfDir
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   893
                                lineWise:false
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   894
                                onError:[:status| false].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   895
    ] ifTrue:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   896
        p := [
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   897
            rslt := ok := OperatingSystem executeCommand:command
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   898
                                inputFrom:nil 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   899
                                outputTo:nil 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   900
                                errorTo:errorStream 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   901
                                auxFrom:nil
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   902
                                inDirectory:pathOfDir
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   903
                                lineWise:false
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   904
                                onError:[:status| false].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   905
        ] fork.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   906
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   907
        (p waitUntilTerminatedWithTimeout:300) ifTrue:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   908
            ('CVSSourceCodeManager [info]: command timeout: ' , command) errorPrintCR.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   909
            ^ false
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   910
        ]. 
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   911
    ].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   912
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   913
    ok ifFalse:[
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   914
        ('CVSSourceCodeManager [info]: command failed: ' , command) errorPrintCR.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   915
    ].
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   916
    ^ rslt
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   917
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   918
    "Modified: / 23.4.1996 / 15:24:00 / stefan"
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   919
    "Created: / 20.5.1998 / 16:06:34 / cg"
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   920
    "Modified: / 19.5.1999 / 10:43:57 / cg"
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   921
!
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
   922
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   923
executeCVSCommand:cvsCommand module:moduleName inDirectory:dirArg log:doLog pipe:doPipe
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   924
    "execute command and prepend cvs command name and global options.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   925
     execute command in the dirArg directory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   926
     The doLog argument, if false supresses a logEntry to be added 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   927
     in the cvs log file (used when reading / extracting history)"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   928
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   929
    |command cvsRoot rslt ok pathOfDir p dir|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   930
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   931
    dir := dirArg asFilename.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   932
    pathOfDir := dir pathName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   933
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   934
    cvsRoot := self getCVSROOTForModule:moduleName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   935
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   936
    command := CVSBinDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   937
    command size > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   938
        (command endsWith:Filename separator) ifFalse:[
1387
a3611183c69d separatorString / separator
Claus Gittinger <cg@exept.de>
parents: 1373
diff changeset
   939
            command := command , (Filename separator)
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   940
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   941
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   942
    command := command , 'cvs'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   943
    (command includes:Character space) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   944
        command := '"' , command , '"'        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   945
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   946
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   947
    doLog ifFalse:[
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
   948
"/ cvs  1.11.14 fails with -l option
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
   949
"/        command := command , ' -l'.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   950
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   951
    command := command , ' -d "', cvsRoot, '" ', cvsCommand.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   952
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   953
    Verbose == true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   954
        ('CVSSourceCodeManager [info]: executing: ' , command , ' [in ' , pathOfDir , ']') infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   955
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   956
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   957
    doPipe ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   958
        rslt := PipeStream readingFrom:command inDirectory:pathOfDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   959
        ok := rslt notNil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   960
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   961
        Processor isDispatching ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   962
            rslt := ok := OperatingSystem executeCommand:command inDirectory:pathOfDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   963
        ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   964
            p := [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   965
                rslt := ok := OperatingSystem executeCommand:command inDirectory:pathOfDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   966
            ] fork.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   967
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   968
            (p waitUntilTerminatedWithTimeout:300) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   969
                ('CVSSourceCodeManager [info]: command timeout: ' , command) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   970
                ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   971
            ]. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   972
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   973
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   974
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   975
    ok ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   976
        ('CVSSourceCodeManager [info]: command failed: ' , command) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   977
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   978
    ^ rslt
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   979
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   980
    "Modified: / 23.4.1996 / 15:24:00 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   981
    "Created: / 20.5.1998 / 16:06:34 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   982
    "Modified: / 19.5.1999 / 10:43:57 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   983
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   984
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   985
getCVSROOTForModule:aModuleName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   986
    "internal: used when accessing a source repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   987
     Return the CVSROOT which provides the sources for a particular module.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   988
     If no specific root was defined for that module, return the value of
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   989
     the global (fallBack) CVSRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   990
     Nil is returned if no repository is available." 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   991
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   992
    |root|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   993
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   994
    CVSModuleRoots isNil ifTrue:[^ CVSRoot].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   995
    aModuleName isNil ifTrue:[^ CVSRoot].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   996
    root := CVSModuleRoots at:aModuleName ifAbsent:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   997
    ^ root ? CVSRoot
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   998
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
   999
    "Created: / 19.9.1997 / 06:18:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1000
    "Modified: / 20.5.1998 / 16:30:12 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1001
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1002
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1003
getCVSROOTsPerModule
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1004
    "return a dictionary, which associates CVSRoots to modules" 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1005
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1006
    ^ CVSModuleRoots ? #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1007
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1008
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1009
import:moduleDir in:tempdir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1010
    "import the existing tree in tempdir as repository"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1011
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1012
    |cmd|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1013
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1014
    cmd := 'import -m "checkin from stx browser" . initialV initialR'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1015
    ^ self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1016
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1017
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1018
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1019
        log:false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1020
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1021
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1022
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1023
      |f d|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1024
      f := 'stefan/dummy/fasel'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1025
      d := '/tmp/tt' asFilename construct:f.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1026
      d directory recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1027
      d writeStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1028
      self import:'stefan' in:'/tmp/tt/stefan' asFilename
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1029
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1030
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1031
    "Created: / 23.7.1999 / 19:19:34 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1032
    "Modified: / 26.7.1999 / 17:46:29 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1033
    "Modified: / 18.1.2000 / 20:21:32 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1034
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1035
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1036
releaseAndRemove:tempdir module:moduleDir outputTo:outputFilename
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1037
    "cleanup; release tree towards cvs and remove the temporary tree"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1038
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1039
    |cmd redirect|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1040
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1041
    outputFilename isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1042
        OperatingSystem isMSDOSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1043
            redirect := 'NUL'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1044
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1045
            redirect := '/dev/null'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1046
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1047
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1048
        redirect := outputFilename name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1049
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1050
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1051
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1052
    "/ release it towards cvs
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1053
    "/
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
  1054
    cmd := 'release > ' , redirect.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1055
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1056
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1057
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1058
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1059
        log:false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1060
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1061
"/        'CVSMGR: failed to release: ' errorPrint. cmd errorPrintNL.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1062
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1063
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1064
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1065
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1066
    "Modified: / 23.4.1996 / 14:29:49 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1067
    "Created: / 19.9.1997 / 06:28:02 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1068
    "Modified: / 20.5.1998 / 16:44:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1069
    "Modified: / 3.9.1999 / 14:51:29 / ps"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1070
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1071
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1072
repositoryTopDirectory
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1073
    "return the top of the repository. This handles remote CVS connections
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1074
     as well"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1075
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1076
    CVSRoot isNil ifTrue:[^ nil].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1077
    ^ self repositoryTopDirectory:CVSRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1078
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1079
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1080
     CVSSourceCodeManager repositoryTopDirectory
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1081
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1082
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1083
    "Created: / 25.11.1995 / 18:39:19 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1084
    "Modified: / 16.1.1998 / 17:33:31 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1085
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1086
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1087
repositoryTopDirectory:aString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1088
    "return the top of the repository (without remote prefix)"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1089
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1090
    |idx|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1091
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1092
    idx := aString indexOf:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1093
    idx <= 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1094
        ^ aString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1095
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1096
    ^ aString copyFrom:idx.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1097
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1098
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1099
     CVSSourceCodeManager repositoryTopDirectory:':pserver:stefan@ibm.exept.de:/archiv/cvs'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1100
     CVSSourceCodeManager repositoryTopDirectory:'exept:/files/CVS'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1101
     CVSSourceCodeManager repositoryTopDirectory:'/archiv/cvs'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1102
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1103
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1104
    "Modified: / 16.1.1998 / 17:32:03 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1105
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1106
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1107
revisionStringFromLog:log entry:entry forClass:aClass
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1108
    "given a log entry, extract a revision string"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1109
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1110
    |oldRev idx special|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1111
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1112
    oldRev := aClass revisionString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1113
    special := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1114
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1115
    oldRev notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1116
        idx := oldRev lastIndexOf:$[.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1117
        idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1118
            idx := oldRev indexOf:$[ startingAt:idx+1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1119
            idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1120
                special := ' ' , (oldRev copyFrom:idx).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1121
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1122
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1123
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1124
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1125
    ^ '$Header: ' , (log at:#container) ,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1126
      ' ' , (entry at:#revision) ,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1127
      ' ' , (entry at:#date) , 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1128
      ' ' , (entry at:#author) , 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1129
      ' ' , (entry at:#state) ,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1130
      ' $' ,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1131
      special
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1132
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1133
    "Created: 16.9.1996 / 20:24:14 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1134
    "Modified: 3.3.1997 / 22:31:51 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1135
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1136
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1137
updatedRevisionStringOf:aClass forRevision:newRevision with:originalVersionString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1138
    "update a revision string"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1139
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1140
    |idx leftPart rightPart vsnString newVsn|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1141
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1142
    "/ search for ,v
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1143
    idx := originalVersionString indexOfSubCollection:'.st,v'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1144
    idx == 0 ifTrue:[^ nil].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1145
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1146
    leftPart := originalVersionString copyTo:(idx - 1 + 5).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1147
    rightPart := (originalVersionString copyFrom:(idx + 5)) withoutSpaces.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1148
    idx := rightPart indexOfSeparator.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1149
    idx == 0 ifTrue:[^ nil].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1150
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1151
    vsnString := rightPart copyTo:idx - 1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1152
    rightPart := rightPart copyFrom:idx + 1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1153
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1154
    newRevision isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1155
        (vsnString endsWith:'m') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1156
             "/ alread a modified class
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1157
"/            ('already modified: ' , vsnString) printNL.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1158
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1159
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1160
        newVsn := vsnString , 'm'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1161
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1162
        newVsn := newRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1163
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1164
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1165
    ^ leftPart , ' ' , newVsn , ' ' , rightPart
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1166
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1167
    "Created: 7.12.1995 / 20:23:38 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1168
    "Modified: 16.9.1996 / 20:24:28 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1169
! !
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1170
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1171
!CVSSourceCodeManager class methodsFor:'source code access'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1172
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1173
checkin:containerFilename text:someText directory:packageDir module:moduleDir logMessage:logMessage force:force
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1174
    "enter some (source) code (which is someText)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1175
     into the source repository. If the force argument is true, no merge is done;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1176
     instead, the code is checked in as given (Dangerous).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1177
     Return true if ok, false if not."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1178
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1179
    |tempdir cmd checkoutName logMsg revision logTmp 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1180
     cmdOut whatHappened s  idx changeLog changesAsLogged l 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1181
     newRevision  msg answer didMerge
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1182
     mySource mergedSource modulePath time 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1183
     editor checkInRepaired didAccept emphasizedText repairedText out 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1184
     emSep comment|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1185
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1186
    revision := self newestRevisionInFile:containerFilename directory:packageDir module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1187
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1188
    logMsg := logMessage.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1189
    (logMsg isNil or:[logMsg isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1190
        logMsg := 'checkin from browser'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1191
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1192
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1193
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1194
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1195
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1196
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1197
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1198
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1199
    "/ in CVS, we have to checkout the file first, in order
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1200
    "/ to get up-to-date CVS entries, and also to be able to merge in
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1201
    "/ other users changes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1202
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1203
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1204
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1205
    "/ first, create a temporary work tree
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1206
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1207
    tempdir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1208
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1209
        ('CVSSourceCodeManager [error]: no tempDir - cannot checkin ' , containerFilename) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1210
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1211
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1212
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1213
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1214
    "/ next, create CVS/Entries and CVS/Repository with version information of current version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1215
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1216
    modulePath :=  moduleDir , '/' , packageDir. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1217
    checkoutName :=  modulePath , '/' , containerFilename.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1218
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1219
    revision isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1220
        "/ a new file ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1221
        ^ self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1222
            createContainerForText:someText inModule:moduleDir package:packageDir container:containerFilename
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1223
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1224
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1225
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1226
    "/ correct our current time, so that converting it will give us UTC
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1227
    "/
1388
6fae02877da5 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 1387
diff changeset
  1228
    time := Timestamp now subtractSeconds:1.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1229
    time := time addSeconds:(time utcOffset).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1230
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1231
    self createEntryFor:checkoutName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1232
         module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1233
         in:(tempdir construct:modulePath) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1234
         revision:revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1235
         date:(self cvsTimeString:time)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1236
         special:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1237
         overwrite:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1238
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1239
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1240
    "/ copy-over our current version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1241
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1242
    Stream errorSignal handle:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1243
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1244
        'CVSSourceCodeManager [error]: cannot copy-over filedOut class source' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1245
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1246
    ] do:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1247
        s := (tempdir construct:checkoutName) writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1248
        s nextPutAll:someText.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1249
        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1250
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1251
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1252
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1253
    "/ synchronize i.e. merge in any changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1254
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1255
    self activityNotification:'merging ' , containerFilename , ' with repository version ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1256
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1257
    cmd := 'update ', containerFilename, ' >', '"' , cmdOut name , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1258
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1259
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1260
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1261
        inDirectory:((tempdir construct:moduleDir) constructString:packageDir)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1262
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1263
        force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1264
            'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1265
            tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1266
            cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1267
            'CVSSourceCodeManager [error]: cannot merge current source with repository version' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1268
            ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1269
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1270
    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1271
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1272
        "/ check what happened - the contents of the cmdOut file may be:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1273
        "/   empty   -> nothing changed
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1274
        "/   M xxx   -> merged-in changes from other users
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1275
        "/   C xxx   -> a conflict occured and the differences have been merged into the source
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1276
        "/              needs special action
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1277
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1278
        (cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1279
            whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1280
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1281
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1282
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1283
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1284
    (whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1285
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1286
        "/ no change
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1287
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1288
"/        Transcript showCR:'no change in ' , containerFilename , ' (repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1289
        force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1290
            self information:'nothing changed in ' , containerFilename , ' (repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1291
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1292
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1293
        ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1294
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1295
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1296
    Verbose == true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1297
        ('CVSMGR: result is: ' , whatHappened) infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1298
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1299
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1300
    force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1301
        revision isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1302
            changeLog := self revisionLogOfContainer:containerFilename directory:packageDir module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1303
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1304
            changeLog := self revisionLogOfContainer:containerFilename module:moduleDir package:packageDir fromRevision:(self revisionAfter:revision) toRevision:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1305
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1306
        changeLog notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1307
            s := WriteStream on:String new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1308
            self writeRevisionLogMessagesFrom:changeLog withHeader:false to:s.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1309
            changesAsLogged := s contents.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1310
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1311
            "/ mhmh - that should not happen
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1312
            changesAsLogged := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1313
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1314
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1315
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1316
    didMerge := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1317
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1318
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1319
    "/ cvs above rel10 returns a multiline info ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1320
    "/ we have to extract the one line which states what happened.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1321
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1322
    whatHappened := whatHappened asCollectionOfLines asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1323
    whatHappened := whatHappened select:[:line |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1324
                        (line startsWith:'RCS file') not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1325
                        and:[(line startsWith:'retrieving') not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1326
                        and:[(line startsWith:'Merging') not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1327
                        and:[line size > 0]]]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1328
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1329
    whatHappened := whatHappened asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1330
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1331
    (force or:[whatHappened startsWith:'M ']) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1332
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1333
        "/ merged in changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1334
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1335
        (force 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1336
        or:[changeLog isNil 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1337
        or:[(changeLog at:#revisions) isEmpty]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1338
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1339
            "/ pretty good - nothing has changed in the meanwhile
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1340
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1341
            Transcript showCR:'checking in ' , containerFilename , ' ...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1342
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1343
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1344
            "/ someone else has changed things in the meanwhile, but there is no conflict
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1345
            "/ and version have been merged.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1346
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1347
            didMerge := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1348
            changesAsLogged := changesAsLogged asCollectionOfLines.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1349
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1350
            s := WriteStream on:String new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1351
            s nextPutAll:someText.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1352
            mySource := s contents asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1353
            mergedSource := (tempdir construct:checkoutName) readStream contents asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1354
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1355
            mySource = mergedSource ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1356
                msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as listed below.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1357
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1358
I have merged your version with the newest repository version, 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1359
and found no differences between the result and your current version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1360
(i.e. your version seemed up-to-date).'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1361
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1362
                self checkinTroubleDialog:'Merging versions'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1363
                               message:msg 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1364
                               log:changesAsLogged
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1365
                               abortable:false 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1366
                               option:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1367
                didMerge := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1368
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1369
                msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as listed below.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1370
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1371
If you continue, your new changes (based upon rev. ' , revision printString , ') will be MERGED
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1372
into the newest revision. This will combine the other version with your changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1373
into a new common revision which may be different from both. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1374
Although this is a nice feature, it may fail to create the expected result in certain situations. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1375
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1376
You should carefully check the result - by comparing the current version with the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1377
most recent version in the repository. If that does not contain an acceptable version,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1378
change methods as required and check in again. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1379
Be aware, that after that, the actual repository version is different from your current classes,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1380
and you should update your class from the repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1381
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1382
Continue ?'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1383
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1384
                answer := self checkinTroubleDialog:'Merging versions'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1385
                               message:msg 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1386
                               log:changesAsLogged
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1387
                               abortable:true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1388
                               option:'Stop - see first'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1389
                answer ~~ true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1390
                    answer == #option ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1391
                        DiffTextView 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1392
                            openOn:mySource
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1393
                            label:'current version'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1394
                            and:mergedSource
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1395
                            label:'merged version'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1396
                            
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1397
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1398
                    Transcript showCR:'checkin aborted - (no merge; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1399
                    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1400
                    ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1401
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1402
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1403
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1404
"/                changesAsLogged := (changesAsLogged asStringCollection collect:[:line | line withTabsExpanded]) asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1405
"/                msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as follows:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1406
"/' , changesAsLogged , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1407
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1408
"/If you continue, your new changes (based upon rev. ' , revision , ') will be MERGED
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1409
"/into the newest revision. This will combine the other version with your changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1410
"/into a new common revision which is different from both. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1411
"/Although convenient, it may fail to create the expected result in certain situations. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1412
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1413
"/You should carefully check the result - by comparing the current version with the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1414
"/most recent version in the repository. If that does not contain an acceptable version,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1415
"/change methods as required and check in again. Be aware, that the actual repository version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1416
"/is different from your current classes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1417
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1418
"/Continue ?'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1419
"/                (self confirm:msg) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1420
"/                    Transcript showCR:'checkin aborted - (no merge; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1421
"/                    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1422
"/                    ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1423
"/                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1424
            Transcript showCR:'checking in ' , containerFilename , ' (merged other changes) ...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1425
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1426
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1427
        (whatHappened startsWith:'C ') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1428
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1429
            "/ conflict; someone else checked in something in the meanwhile,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1430
            "/ and there is a conflict between this version and the checked in version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1431
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1432
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1433
            changesAsLogged := changesAsLogged asCollectionOfLines.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1434
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1435
            msg := 'The source of ' , containerFilename , ' has been changed in the meanwhile as listed below.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1436
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1437
Your new changes (based upon rev. ' , revision printString , ') CONFLICT with those changes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1438
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1439
You should fix things by comparing your class with the most recent repository version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1440
and change your methods avoiding conflicts. The checkin again.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1441
'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1442
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1443
            answer := self checkinTroubleDialog:'Version conflict'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1444
                 message:msg 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1445
                 log:changesAsLogged
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1446
                 abortable:false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1447
                 option:'show conflicts'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1448
                 option2:'resolve conflicts'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1449
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1450
            answer == #option ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1451
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1452
                "/ show conflicts in a 3-way DiffTextView ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1453
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1454
                Diff3TextView
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1455
                    openOnMergedText:(tempdir construct:checkoutName) readStream contents 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1456
                    label:'your version (checkin attempt)' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1457
                    label:'original (base version)' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1458
                    label:'newest repository version'. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1459
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1460
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1461
            checkInRepaired := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1462
            answer == #option2 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1463
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1464
                "/ allow checkin of repair version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1465
                "/ this is error prone ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1466
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1467
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1468
                "/ show merged version in an editor ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1469
                "/ ... accept will check it in.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1470
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1471
                emphasizedText := (tempdir construct:checkoutName) readStream contents.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1472
                emSep := (Array with:(#color->Color black)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1473
                             with:(#backgroundColor->Color green)).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1474
                emphasizedText := Diff3TextView 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1475
                            emphasizeMergedDiff3Text:emphasizedText 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1476
                            emphasize1:(Array with:(#color->Color white)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1477
                                              with:(#backgroundColor->Color blue))
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1478
                            emphasize2:(Array with:(#color->Color white)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1479
                                              with:(#backgroundColor->Color red))
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1480
                            emphasizeSep:emSep.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1481
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1482
                comment := 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1483
'"/ ***************************************************************
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1484
"/ This text contains your current versions code (blue)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1485
"/ merged with the conflicting code as found in the repository (red) which resulted
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1486
"/ from some other checkin.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1487
"/ Each such conflict is surrounded by green text (like this paragraph).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1488
"/ 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1489
"/ Please have a look at ALL the conflicts and fix things as appropriate.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1490
"/ Delete the green lines as a confirmation - I will not checkin the changed text,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1491
"/ unless no more green parts are present. This includes this comment at the top.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1492
"/ ***************************************************************
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1493
'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1494
                comment := (Text string:comment emphasis:emSep) asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1495
                emphasizedText := comment , emphasizedText.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1496
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1497
                didAccept := false. checkInRepaired := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1498
                [didAccept not and:[checkInRepaired]] whileTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1499
                    editor := RCSConflictEditTextView 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1500
                                setupWith:emphasizedText
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1501
                                title:'Resolve conflicts in ' , containerFilename , ', then accept & close to checkin'.    
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1502
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1503
                    editor acceptAction:[:dummy |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1504
                        repairedText := editor list.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1505
                        didAccept := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1506
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1507
                    didAccept := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1508
                    editor topView openModal.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1509
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1510
                    didAccept ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1511
                        (Dialog confirm:'You did not accept the new text. Edit again ?')
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1512
                        ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1513
                            checkInRepaired := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1514
                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1515
                    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1516
                        "/ check if all green-stuff (separators) have been removed
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1517
                        (repairedText findFirst:[:line | line notNil and:[line notEmpty and:[(line emphasisAt:1) = emSep]]]) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1518
                            self warn:'You have to look at ALL conflicts, and remove ALL green lines as a confirmation !!'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1519
                            didAccept := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1520
                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1521
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1522
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1523
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1524
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1525
                checkInRepaired ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1526
                    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1527
                        out := (tempdir construct:checkoutName) writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1528
                        out nextPutAll:(repairedText asString string).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1529
                        didAccept := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1530
                        out close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1531
                    ] on:FileStream openErrorSignal do:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1532
                        self warn:'could not write file ' , (tempdir constructString:checkoutName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1533
                        checkInRepaired := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1534
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1535
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1536
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1537
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1538
            checkInRepaired ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1539
                Transcript showCR:'checking in ' , containerFilename , ' (manually repaired version) ...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1540
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1541
                'CVSSourceCodeManager [warning]: cannot (for now) checkin; conflicts found' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1542
                Transcript showCR:'checkin of ' , containerFilename , ' aborted (conflicting changes; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1543
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1544
                ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1545
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1546
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1547
            (whatHappened startsWith:'U ') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1548
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1549
                "/ nothing changed here, but the repository already contains
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1550
                "/ a newer version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1551
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1552
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1553
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1554
                self information:'nothing changed in your ''' , containerFilename , ''';
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1555
but repository already contains a newer version (repository unchanged).'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1556
                ^ true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1557
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1558
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1559
                "/ unexpected
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1560
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1561
                self warn:'unexpected message from CVS:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1562
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1563
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1564
No checkin performed.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1565
                Transcript showCR:'*** cannot checkin ' , containerFilename , ' (unexpected CVS response; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1566
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1567
                ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1568
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1569
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1570
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1571
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1572
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1573
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1574
    "/ now check it in again
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1575
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1576
    self activityNotification:'saving ' , containerFilename , ' in repository ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1577
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1578
    logMsg := logMsg replChar:$"  withString:'\"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1579
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1580
    OperatingSystem isUNIXlike ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1581
        "/ save the log message into another tempFile ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1582
        logTmp := Filename newTemporaryIn:tempdir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1583
        s := logTmp writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1584
        s nextPutAll:logMsg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1585
        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1586
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1587
        cmd := 'commit -F "', logTmp baseName, '" ', checkoutName, ' >', '"' , cmdOut name , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1588
    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1589
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1590
        "/ CVS up to V1.9.14 prints the 'new revision' to stderr,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1591
        "/ CVS V1.9.16 to stdout.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1592
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1593
        cmd := 'commit -m "', logMsg, '" ', checkoutName, ' >', '"' , cmdOut name , '"' , ' 2>&1'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1594
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1595
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1596
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1597
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1598
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1599
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1600
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1601
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1602
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1603
        (cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1604
            whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1605
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1606
            whatHappened := '<< no message >>'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1607
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1608
        self warn:'The following problem was reported by cvs:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1609
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1610
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1611
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1612
The class has NOT been checked into the repository.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1613
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1614
       ('CVSSourceCodeManager [error]: cvs: ' , whatHappened) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1615
       'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1616
        logTmp notNil ifTrue:[logTmp remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1617
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1618
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1619
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1620
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1621
    logTmp notNil ifTrue:[logTmp remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1622
    (cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1623
        whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1624
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1625
        whatHappened := nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1626
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1627
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1628
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1629
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1630
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1631
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1632
    "/ fetch the new revision nr as found in the commit commands output
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1633
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1634
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1635
    (whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1636
        'CVSSourceCodeManager [error]: unexpected empty checkin command output' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1637
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1638
        whatHappened := whatHappened asCollectionOfLines asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1639
        idx := whatHappened indexOfLineStartingWith:'new revision:'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1640
        idx == 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1641
            'CVSSourceCodeManager [error]: unexpected checkin command output (no new-revision info)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1642
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1643
            l := whatHappened at:idx.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1644
            newRevision := (l copyFrom:14 to:(l indexOf:$; startingAt:14)-1) withoutSpaces.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1645
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1646
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1647
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1648
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1649
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1650
checkinClass:cls fileName:classFileName directory:packageDir module:moduleDir source:sourceFileName logMessage:logMessage force:forceArg
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1651
    "enter a classes source code (which has been already filed out into sourceFileName)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1652
     into the source repository. If the force argument is true, no merge is done;
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1653
     instead, the code is checked in as given (Dangerous).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1654
     Return true if ok, false if not."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1655
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1656
    |tempdir cmd checkoutName logMsg revision logTmp 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1657
     cmdOut whatHappened s entry idx changeLog changesAsLogged l 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1658
     newRevision newString binRevision className msg answer didMerge
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1659
     mySource mergedSource modulePath time 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1660
     editor checkInRepaired checkInNew didAccept emphasizedText repairedText out 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1661
     emSep comment force|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1662
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1663
    force := forceArg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1664
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1665
    className := cls name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1666
    cls isPrivate ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1667
        self error:'refuse to check in private classes.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1668
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1669
    revision := cls revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1670
    (revision notNil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1671
    and:[revision endsWith:$m]) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1672
    ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1673
        "/ this class has already been checked in with a merge,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1674
        "/ but not reloaded from the repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1675
        "/ must use the original revision string.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1676
        revision := revision copyWithoutLast:1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1677
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1678
    (binRevision := cls binaryRevision) notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1679
        revision ~= binRevision ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1680
            ('CVSSourceCodeManager [info]: class ' , className , ' is based upon ' , binRevision , ' but has revision ' , (revision ? '?')) infoPrintCR
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1681
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1682
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1683
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1684
    revision isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1685
        revision := self newestRevisionOf:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1686
        revision isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1687
            force ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1688
                revision := self newestRevisionInFile:classFileName directory:packageDir module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1689
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1690
                revision := '1.0'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1691
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1692
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1693
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1694
1373
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1695
    logMessage isNil ifTrue:[
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1696
        logMsg := ''.
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1697
    ] ifFalse:[
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1698
        logMsg := logMessage asSingleByteStringIfPossible.
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1699
        logMsg bitsPerCharacter ~~ 8 ifTrue:[
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1700
            'CVSSourceCodeManager [error]: cvs cannot handle unicode in logMessage' errorPrintCR.
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1701
            ^ false.
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1702
        ].    
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1703
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1704
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1705
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1706
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1707
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1708
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1709
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1710
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1711
    "/ in CVS, we have to checkout the file first, in order
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1712
    "/ to get up-to-date CVS entries, and also to be able to merge in
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1713
    "/ other users changes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1714
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1715
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1716
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1717
    "/ first, create a temporary work tree
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1718
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1719
    tempdir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1720
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1721
        ('CVSSourceCodeManager [error]: no tempDir - cannot checkin ' , className) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1722
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1723
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1724
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1725
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1726
    "/ next, create CVS/Entries and CVS/Repository with version information of current version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1727
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1728
    modulePath :=  moduleDir , '/' , packageDir. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1729
    checkoutName :=  modulePath , '/' , classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1730
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1731
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1732
    "/ correct our current time, so that converting it will give us UTC
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1733
    "/
1388
6fae02877da5 Use Timestamp/#asTimestamp instead of AbsoluteTime/#asAbsoluteTime
Stefan Vogel <sv@exept.de>
parents: 1387
diff changeset
  1734
    time := Timestamp now subtractSeconds:1.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1735
    time := time addSeconds:(time utcOffset).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1736
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1737
    self createEntryFor:checkoutName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1738
         module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1739
         in:(tempdir construct:modulePath) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1740
         revision:revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1741
         date:(self cvsTimeString:time)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1742
         special:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1743
         overwrite:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1744
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1745
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1746
    "/ copy-over our current version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1747
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1748
    Error handle:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1749
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1750
        'CVSSourceCodeManager [error]: cannot copy-over filedOut class source' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1751
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1752
    ] do:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1753
        sourceFileName asFilename copyTo:(tempdir construct:checkoutName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1754
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1755
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1756
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1757
    "/ synchronize i.e. merge in any changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1758
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1759
    self activityNotification:'merging ' , cls name , ' with repository version ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1760
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1761
    cmd := 'update ', classFileName, ' >', '"' , cmdOut name , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1762
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1763
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1764
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1765
        inDirectory:((tempdir construct:moduleDir) constructString:packageDir)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1766
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1767
        force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1768
            "/ someone fiddled around with repository ?
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1769
            (cls binaryRevision notNil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1770
            and:[(self checkForExistingContainerInModule:moduleDir package:packageDir container:classFileName) not ])
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1771
            ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1772
                (Dialog confirm:('Someone seems to have removed the source container for ' , cls name , '\\Force new checkin ?') withCRs)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1773
                ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1774
                    cls setBinaryRevision:nil.
1373
65473183582d Check for unicode in cvs log message (cvs cannot handle this)
Stefan Vogel <sv@exept.de>
parents: 1365
diff changeset
  1775
                    ^ self checkinClass:cls fileName:classFileName directory:packageDir module:moduleDir source:sourceFileName logMessage:logMsg force:force.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1776
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1777
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1778
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1779
        force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1780
            'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1781
            tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1782
            cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1783
            'CVSSourceCodeManager [error]: cannot merge current source with repository version' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1784
            ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1785
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1786
    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1787
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1788
        "/ check what happened - the contents of the cmdOut file may be:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1789
        "/   empty   -> nothing changed
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1790
        "/   M xxx   -> merged-in changes from other users
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1791
        "/   C xxx   -> a conflict occured and the differences have been merged into the source
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1792
        "/              needs special action
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1793
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1794
        (cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1795
            whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1796
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1797
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1798
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1799
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1800
    (whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1801
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1802
        "/ no change
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1803
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1804
"/        Transcript showCR:'no change in ' , className , ' (repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1805
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1806
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1807
        force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1808
"/            (ChangeSet current includesChangeForClass:cls) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1809
"/                (self confirm:('Nothing changed in %1 (repository unchanged).\\Remove entries from changeSet ?' bindWith:className) withCRs) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1810
"/                    ChangeSet current condenseChangesForClass:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1811
"/                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1812
"/            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1813
                self information:('Nothing changed in %1 (repository unchanged)' bindWith:className).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1814
"/            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1815
            self postCheckInClass:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1816
        ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1817
            changeLog := self revisionLogOfContainer:classFileName directory:packageDir module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1818
            (changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1819
                'CVSSourceCodeManager [error]: failed to update revisionString (no log)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1820
                cls updateVersionMethodFor:'$' , 'Header' , '$'.  "/ concatenated to avoid RCS expansion
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1821
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1822
                entry := (changeLog at:#revisions) first.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1823
                newString := self revisionStringFromLog:changeLog entry:entry forClass:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1824
                cls updateVersionMethodFor:newString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1825
                cls revision ~= newRevision ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1826
                    'CVSSourceCodeManager [error]: failed to update revisionString' errorPrintCR
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1827
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1828
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1829
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1830
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1831
        ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1832
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1833
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1834
    Verbose == true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1835
        ('CVSMGR: result is: ' , whatHappened) infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1836
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1837
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1838
    force ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1839
        revision isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1840
            changeLog := self revisionLogOf:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1841
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1842
            changeLog := self revisionLogOf:cls fromRevision:(self revisionAfter:revision) toRevision:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1843
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1844
        changeLog notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1845
            s := WriteStream on:String new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1846
            self writeRevisionLogMessagesFrom:changeLog withHeader:false to:s.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1847
            changesAsLogged := s contents.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1848
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1849
            "/ mhmh - that should not happen
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1850
            changesAsLogged := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1851
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1852
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1853
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1854
    didMerge := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1855
    checkInRepaired := checkInNew := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1856
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1857
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1858
    "/ cvs above rel10 returns a multiline info ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1859
    "/ we have to extract the one line which states what happened.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1860
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1861
    whatHappened := whatHappened asCollectionOfLines asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1862
    whatHappened := whatHappened select:[:line |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1863
                        (line startsWith:'RCS file') not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1864
                        and:[(line startsWith:'retrieving') not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1865
                        and:[(line startsWith:'Merging') not
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1866
                        and:[line size > 0]]]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1867
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1868
    whatHappened := whatHappened asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1869
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1870
    (force or:[whatHappened startsWith:'M ']) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1871
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1872
        "/ merged in changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1873
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1874
        (force 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1875
        or:[changeLog isNil 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1876
        or:[(changeLog at:#revisions) isEmpty]]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1877
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1878
            "/ pretty good - nothing has changed in the meanwhile
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1879
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1880
            Transcript showCR:'checking in ' , className , ' ...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1881
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1882
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1883
            "/ someone else has changed things in the meanwhile, but there is no conflict
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1884
            "/ and version have been merged.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1885
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1886
            didMerge := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1887
            changesAsLogged := changesAsLogged asCollectionOfLines.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1888
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1889
            s := WriteStream on:String new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1890
            cls fileOutOn:s withTimeStamp:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1891
            mySource := s contents asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1892
            mergedSource := (tempdir construct:checkoutName) readStream contents asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1893
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1894
            mySource = mergedSource ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1895
                msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1896
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1897
I have merged your version with the newest repository version, 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1898
and found no differences between the result and your current version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1899
(i.e. your version seemed up-to-date).'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1900
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1901
                self checkinTroubleDialog:'Merging versions'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1902
                               message:msg 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1903
                               log:changesAsLogged
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1904
                               abortable:false 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1905
                               option:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1906
                didMerge := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1907
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1908
                msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1909
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1910
If you continue, your new changes (based upon rev. ' , revision printString , ') will be MERGED
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1911
into the newest revision. This will combine the other version with your changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1912
into a new common revision which may be different from both. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1913
Although this is a nice feature, it may fail to create the expected result in certain situations. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1914
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1915
You should carefully check the result - by comparing the current version with the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1916
most recent version in the repository. If that does not contain an acceptable version,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1917
change methods as required and check in again. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1918
Be aware, that after that, the actual repository version is different from your current classes,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1919
and you should update your class from the repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1920
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1921
Continue ?'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1922
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1923
                answer := self checkinTroubleDialog:'Merging versions'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1924
                               message:msg 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1925
                               log:changesAsLogged
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1926
                               abortable:true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1927
                               option:'Stop - see first'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1928
                               option2:'Do NOT Merge - Force my Code'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1929
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1930
                answer == #option2 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1931
                    (Dialog confirm:'Are you certain that you want to suppress a merge and force your code to be checked in ?')
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1932
                    ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1933
                        s := (tempdir construct:checkoutName) writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1934
                        cls fileOutOn:s withTimeStamp:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1935
                        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1936
                        answer := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1937
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1938
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1939
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1940
                answer ~~ true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1941
                    answer == #option ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1942
                        DiffTextView 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1943
                            openOn:mySource
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1944
                            label:'current version'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1945
                            and:mergedSource
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1946
                            label:'merged version'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1947
                            
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1948
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1949
                    Transcript showCR:'checkin aborted - (no merge; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1950
                    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1951
                    ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1952
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1953
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1954
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1955
"/                changesAsLogged := (changesAsLogged asStringCollection collect:[:line | line withTabsExpanded]) asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1956
"/                msg := 'The source of ' , className , ' has been changed in the meanwhile as follows:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1957
"/' , changesAsLogged , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1958
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1959
"/If you continue, your new changes (based upon rev. ' , revision , ') will be MERGED
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1960
"/into the newest revision. This will combine the other version with your changes
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1961
"/into a new common revision which is different from both. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1962
"/Although convenient, it may fail to create the expected result in certain situations. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1963
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1964
"/You should carefully check the result - by comparing the current version with the
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1965
"/most recent version in the repository. If that does not contain an acceptable version,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1966
"/change methods as required and check in again. Be aware, that the actual repository version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1967
"/is different from your current classes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1968
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1969
"/Continue ?'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1970
"/                (self confirm:msg) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1971
"/                    Transcript showCR:'checkin aborted - (no merge; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1972
"/                    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1973
"/                    ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1974
"/                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1975
            Transcript showCR:'checking in ' , className , ' (merged other changes) ...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1976
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1977
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1978
        (whatHappened startsWith:'C ') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1979
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1980
            "/ conflict; someone else checked in something in the meanwhile,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1981
            "/ and there is a conflict between this version and the checked in version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1982
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1983
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1984
            changesAsLogged := changesAsLogged asCollectionOfLines.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1985
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1986
            msg := 'The source of ' , className , ' has been changed in the meanwhile as listed below.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1987
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1988
Your new changes (based upon rev. ' , revision printString , ') CONFLICT with those changes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1989
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1990
You should fix things by comparing your class with the most recent repository version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1991
and change your methods avoiding conflicts. The checkin again.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1992
'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1993
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1994
            answer := self checkinTroubleDialog:'Version conflict'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1995
                 message:msg 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1996
                 log:changesAsLogged
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1997
                 abortable:false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1998
                 option:'Show conflicts'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  1999
                 option2:'Resolve conflicts'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2000
                 option3:'Do NOT Merge - Force my Code'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2001
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2002
            answer == #option ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2003
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2004
                "/ show conflicts in a 3-way DiffTextView ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2005
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2006
                Diff3TextView
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2007
                    openOnMergedText:(tempdir construct:checkoutName) readStream contents 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2008
                    label:'your version (checkin attempt)' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2009
                    label:'original (base version)' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2010
                    label:'newest repository version'. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2011
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2012
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2013
            answer == #option2 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2014
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2015
                "/ allow checkin of repair version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2016
                "/ this is error prone ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2017
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2018
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2019
                "/ show merged version in an editor ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2020
                "/ ... accept will check it in.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2021
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2022
                emphasizedText := (tempdir construct:checkoutName) readStream contents.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2023
                emSep := (Array with:(#color->Color black)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2024
                             with:(#backgroundColor->Color green)).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2025
                emphasizedText := Diff3TextView 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2026
                            emphasizeMergedDiff3Text:emphasizedText 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2027
                            emphasize1:(Array with:(#color->Color white)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2028
                                              with:(#backgroundColor->Color blue))
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2029
                            emphasize2:(Array with:(#color->Color white)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2030
                                              with:(#backgroundColor->Color red))
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2031
                            emphasizeSep:emSep.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2032
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2033
                comment := 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2034
'"/ ***************************************************************
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2035
"/ This text contains your current versions code (blue)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2036
"/ merged with the conflicting code as found in the repository (red) which resulted
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2037
"/ from some other checkin.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2038
"/ Each such conflict is surrounded by green text (like this paragraph).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2039
"/ 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2040
"/ Please have a look at ALL the conflicts and fix things as appropriate.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2041
"/ Delete the green lines as a confirmation - I will not checkin the changed text,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2042
"/ unless no more green parts are present. This includes this comment at the top.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2043
"/ ***************************************************************
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2044
'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2045
                comment := (Text string:comment emphasis:emSep) asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2046
                emphasizedText := comment , emphasizedText.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2047
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2048
                didAccept := false. checkInRepaired := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2049
                [didAccept not and:[checkInRepaired]] whileTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2050
                    editor := RCSConflictEditTextView 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2051
                                setupWith:emphasizedText
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2052
                                title:'Resolve conflicts in ' , className , ', then accept & close to checkin'.    
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2053
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2054
                    editor acceptAction:[:dummy |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2055
                        repairedText := editor list.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2056
                        didAccept := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2057
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2058
                    didAccept := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2059
                    editor topView openModal.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2060
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2061
                    didAccept ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2062
                        (Dialog confirm:'You did not accept the new text. Edit again ?')
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2063
                        ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2064
                            checkInRepaired := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2065
                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2066
                    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2067
                        "/ check if all green-stuff (separators) have been removed
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2068
                        (repairedText findFirst:[:line | line notNil and:[line notEmpty and:[(line emphasisAt:1) = emSep]]]) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2069
                            self warn:'You have to look at ALL conflicts, and remove ALL green lines as a confirmation !!'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2070
                            didAccept := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2071
                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2072
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2073
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2074
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2075
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2076
                checkInRepaired ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2077
                    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2078
                        out := (tempdir construct:checkoutName) writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2079
                        out nextPutAll:(repairedText asString string).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2080
                        didAccept := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2081
                        out close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2082
                    ] on:FileStream openErrorSignal do:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2083
                        self warn:'could not write file ' , (tempdir constructString:checkoutName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2084
                        checkInRepaired := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2085
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2086
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2087
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2088
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2089
            answer == #option3 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2090
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2091
                "/ force checkin of new version
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2092
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2093
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2094
                "/ show merged version in an editor ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2095
                "/ ... accept will check it in.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2096
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2097
                [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2098
                    out := (tempdir construct:checkoutName) writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2099
                    out nextPutAll:(mySource asString string).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2100
                    didAccept := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2101
                    out close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2102
                    checkInNew := checkInRepaired := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2103
                ] on:FileStream openErrorSignal do:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2104
                    self warn:'could not write file ' , (tempdir constructString:checkoutName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2105
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2106
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2107
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2108
            checkInRepaired ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2109
                checkInNew ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2110
                    Transcript showCR:'checking in ' , className , ' (force new version)...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2111
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2112
                    Transcript showCR:'checking in ' , className , ' (manually repaired version)...'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2113
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2114
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2115
                'CVSSourceCodeManager [warning]: cannot (for now) checkin; conflicts found' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2116
                Transcript showCR:'checkin of ' , className , ' aborted (conflicting changes; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2117
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2118
                ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2119
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2120
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2121
            ((whatHappened startsWith:'U ') 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2122
            or:[ (whatHappened startsWith:'P ') ]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2123
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2124
                "/ nothing changed here, but the repository already contains
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2125
                "/ a newer version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2126
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2127
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2128
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2129
                self information:'nothing changed in your ''' , className , ''';
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2130
but repository already contains a newer version (repository unchanged).'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2131
                ^ true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2132
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2133
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2134
                "/ unexpected
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2135
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2136
                self warn:'unexpected message from CVS:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2137
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2138
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2139
No checkin performed.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2140
                Transcript showCR:'*** cannot checkin ' , className , ' (unexpected CVS response; repository unchanged)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2141
                tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2142
                ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2143
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2144
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2145
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2146
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2147
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2148
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2149
    "/ now check it in again
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2150
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2151
    self activityNotification:'saving ' , cls name , ' in repository ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2152
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2153
    logMsg := logMsg replChar:$"  withString:'\"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2154
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2155
    OperatingSystem isUNIXlike ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2156
        "/ save the log message into another tempFile ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2157
        logTmp := Filename newTemporaryIn:tempdir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2158
        s := logTmp writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2159
        s nextPutAll:logMsg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2160
        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2161
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2162
        cmd := 'commit -F "', logTmp baseName, '" ', checkoutName, ' >', '"' , cmdOut name , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2163
    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2164
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2165
        "/ CVS up to V1.9.14 prints the 'new revision' to stderr,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2166
        "/ CVS V1.9.16 to stdout.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2167
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2168
        cmd := 'commit -m "', logMsg, '" ', checkoutName, ' >', '"', cmdOut name, '"' , ' 2>&1'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2169
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2170
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2171
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2172
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2173
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2174
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2175
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2176
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2177
        (cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2178
            whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2179
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2180
            whatHappened := '<< no message >>'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2181
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2182
        self warn:'The following problem was reported by cvs:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2183
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2184
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2185
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2186
The class has NOT been checked into the repository.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2187
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2188
       'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2189
        logTmp notNil ifTrue:[logTmp remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2190
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2191
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2192
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2193
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2194
    logTmp notNil ifTrue:[logTmp remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2195
    (cmdOut exists and:[cmdOut fileSize > 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2196
        whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2197
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2198
        whatHappened := nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2199
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2200
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2201
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2202
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2203
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2204
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2205
    "/ fetch the new revision nr as found in the commit commands output
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2206
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2207
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2208
    (whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2209
        'CVSSourceCodeManager [error]: unexpected empty checkin command output' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2210
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2211
        whatHappened := whatHappened asCollectionOfLines asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2212
        idx := whatHappened indexOfLineStartingWith:'new revision:'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2213
        idx == 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2214
            'CVSSourceCodeManager [error]: unexpected checkin command output (no new-revision info)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2215
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2216
            l := whatHappened at:idx.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2217
            newRevision := (l copyFrom:14 to:(l indexOf:$; startingAt:14)-1) withoutSpaces.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2218
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2219
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2220
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2221
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2222
    "/ if there was no merge (i.e. the current version has been checked in unchanged):
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2223
    "/   patch the classes revisionInfo (but keep binaryRevision unchanged) to the new revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2224
    "/   this makes everyone here believe, that the incore version of the class is based upon
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2225
    "/   the newly checked in version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2226
    "/   (however, the binaryRevision must remain as it is - we will need it to fetch the sourceCode
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2227
    "/    correctly for all unchanged methodss)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2228
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2229
    "/ if there was a merge (i.e. the repository now contains a merge of the current and some
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2230
    "/ other version):
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2231
    "/    patch the classes revisionInfo (again, keep the binaryRevision) to the old revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2232
    "/    and add a 'm' (for merged).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2233
    "/    If we later checkin again, the new checkin will be again based on the current revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2234
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2235
    newRevision notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2236
        didMerge ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2237
            self activityNotification:'fetch new revision number of ', cls name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2238
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2239
            changeLog := self revisionLogOf:cls fromRevision:newRevision toRevision:newRevision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2240
            (changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2241
                force ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2242
                    changeLog := self revisionLogOfContainer:classFileName directory:packageDir module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2243
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2244
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2245
            (changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2246
                'CVSSourceCodeManager [error]: failed to update revisionString (no log)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2247
                cls updateVersionMethodFor:'$' , 'Header' , '$'.  "/ concatenated to avoid RCS expansion
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2248
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2249
                entry := (changeLog at:#revisions) first.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2250
                newString := self revisionStringFromLog:changeLog entry:entry forClass:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2251
                cls updateVersionMethodFor:newString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2252
                cls revision ~= newRevision ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2253
                    'CVSSourceCodeManager [error]: failed to update revisionString' errorPrintCR
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2254
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2255
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2256
        ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2257
            newString := self updatedRevisionStringOf:cls forRevision:nil with:cls revisionString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2258
            cls updateVersionMethodFor:newString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2259
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2260
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2261
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2262
    Class addChangeRecordForClassCheckIn:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2263
    self postCheckInClass:cls.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2264
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2265
    (checkInRepaired and:[checkInNew not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2266
        self information:'Now the repository contains a merge between your and the other changes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2267
However, the class in your image does NOT contain the other changes.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2268
This will lead to more conflict-resolving whenever you check this class in again later,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2269
unless you load the newest (merged) version of the class from the repository.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2270
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2271
I recommend doing this as soon as possible via your browsers checkout function.'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2272
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2273
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2274
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2275
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2276
     SourceCodeManager checkinClass:Array logMessage:'testing only'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2277
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2278
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2279
    "Created: / 11.9.1996 / 16:16:11 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2280
    "Modified: / 26.2.1998 / 17:34:16 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2281
    "Modified: / 5.11.2001 / 14:35:38 / cg"
130
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
  2282
!
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
  2283
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2284
checkoutModule:aModule package:aPackage andDo:aBlock
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2285
    "check out everything from a package into a temporary directory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2286
     Then evaluate aBlock, passing the name of that temp-directory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2287
     Afterwards, the tempDir is removed.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2288
     Return true, if OK, false if any error occurred."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2289
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2290
    |cvsRoot packageDir tempdir cmdOut cmd dirName|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2291
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2292
    cvsRoot := self getCVSROOTForModule:aModule.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2293
    cvsRoot isNil ifTrue:[^ false ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2294
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2295
    aPackage notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2296
        dirName := aModule , '/' , aPackage.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2297
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2298
        dirName := aModule.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2299
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2300
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2301
    self activityNotification:'checking out everything in ' , dirName , ' ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2302
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2303
    tempdir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2304
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2305
        ('CVSSourceCodeManager [error]: no tempDir - cannot checkout') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2306
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2307
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2308
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
  2309
    cmd := 'checkout ', dirName.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2310
    OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2311
        "/ can redirect output
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2312
        cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2313
        cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2314
            cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2315
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2316
        cmd := cmd , ' > ', '"'  , cmdOut name, '"' .
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2317
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2318
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2319
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2320
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2321
        module:aModule
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2322
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2323
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2324
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2325
        cmdOut notNil ifTrue:[cmdOut remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2326
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2327
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2328
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2329
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2330
    cmdOut notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2331
"/        listOfFiles := cmdOut contents.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2332
        cmdOut remove
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2333
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2334
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2335
    packageDir := (tempdir construct:dirName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2336
    (packageDir isDirectory) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2337
        'CVSSourceCodeManager [error]: checkout failed (no dir)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2338
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2339
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2340
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2341
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2342
    "/ now, invoke the block ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2343
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2344
        aBlock value:packageDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2345
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2346
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2347
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2348
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2349
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2350
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2351
    "Modified: / 28.4.1999 / 12:21:10 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2352
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2353
1405
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2354
streamForClass:cls fileName:fileName revision:revision directory:packageDir module:moduleDir cache:cacheItArg
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2355
    "extract a source file and return an open readStream on it,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2356
     or nil if the extract failed. If revision is nil or (#newest), take
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2357
     the latest; otherwise, a specific revisions source is extracted.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2358
     The cls argument is currently ignored, but may be used in future versions,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2359
     to validate the correct container against the class.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2360
     To check out a file (i.e. not a classes file), leave it nil."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2361
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2362
    |dir cachedSourceFilename cachedFile cmd fullName revisionArg stream
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2363
     checkoutName checkoutNameLocal fullTempName fullCachedName tempdir cmdOut
1405
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2364
     classFileName cvsRoot tempFile revMsg cacheIt|
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2365
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2366
    cacheIt := cacheItArg.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2367
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2368
    (DisabledModules notNil and:[DisabledModules includes:moduleDir]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2369
        Transcript showCR:'cvs access for module ' , moduleDir , ' has been disabled (due to previous failure)'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2370
        Transcript showCR:'reenable using the launchers source&debugger dialog'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2371
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2372
        ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2373
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2374
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2375
    cvsRoot := self getCVSROOTForModule:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2376
    cvsRoot isNil ifTrue:[^ nil].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2377
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2378
    "/ if not already existing, create a cache directory
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2379
    "/ where we deposit sources.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2380
    "/ this is used as a cache for further requests, since
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2381
    "/ accessing the repository may be slow.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2382
    "/ (if cvs uses a remote connection via ppp, for example)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2383
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2384
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2385
    revision ~~ #newest ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2386
        (dir := self sourceCacheDirectory) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2387
            'CVSSourceCodeManager [warning]: no source cache directory' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2388
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2389
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2390
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2391
    classFileName := fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2392
    (classFileName endsWith:',v') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2393
        classFileName := classFileName copyWithoutLast:2.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2394
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2395
    (classFileName endsWith:'.st') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2396
        cls notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2397
            classFileName := classFileName copyWithoutLast:3.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2398
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2399
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2400
    fullName := moduleDir , '/' , packageDir , '/' , classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2401
    cls notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2402
        fullName := fullName , '.st'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2403
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2404
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2405
    (revision isNil or:[revision == #newest]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2406
        cachedSourceFilename := classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2407
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2408
        cachedSourceFilename := classFileName , '_' , revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2409
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2410
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2411
    dir notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2412
        cachedFile := dir construct:cachedSourceFilename.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2413
        cachedFile exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2414
"/            cachedFile fileSize < 10 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2415
"/                ('CVSSourceCodeManager [warning]: existing: ', cachedFile name , ' seems corrupted.') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2416
"/                cachedFile remove
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2417
"/            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2418
"/            ('CVSSourceCodeManager [info]: found existing: ', cachedFile name) infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2419
                ^ cachedFile readStream
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2420
"/            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2421
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2422
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2423
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2424
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2425
    "/ first, create a temporary work tree
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2426
    "/ Do not make module and package directories, their existence cause cvs checkout to fail in server mode
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2427
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2428
    tempdir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2429
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2430
        ('CVSSourceCodeManager [error]: no tempDir - cannot checkout ' , classFileName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2431
        ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2432
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2433
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2434
"/    tempdir := Filename newTemporaryIn:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2435
"/    tempdir exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2436
"/        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2437
"/    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2438
"/    tempdir makeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2439
"/    dir := tempdir construct:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2440
"/    dir makeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2441
"/    dir := dir construct:packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2442
"/    dir recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2443
"/    dir exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2444
"/        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2445
"/        'CVSMGR: cannot create temporary directory' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2446
"/        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2447
"/    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2448
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2449
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2450
    "/ check it out there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2451
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2452
    checkoutName :=  fullName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2453
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2454
    checkoutNameLocal := (moduleDir asFilename construct:packageDir) constructString:(fullName asFilename baseName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2455
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2456
    (revision isNil or:[revision == #newest]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2457
        cachedSourceFilename := classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2458
        revisionArg := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2459
        revMsg := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2460
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2461
        cachedSourceFilename := classFileName , '_' , revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2462
        revisionArg := ' -r ' , revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2463
        revMsg := ' (' , revision , ')'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2464
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2465
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2466
    self activityNotification:'checking out source ' , checkoutName , revMsg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2467
    OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2468
        "/ can redirect output
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2469
        cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2470
        cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2471
            cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2472
        ].
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
  2473
        cmd := 'checkout' , revisionArg , ' ', checkoutName , ' > ' , '"' , cmdOut name, '"' .
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2474
    ] ifFalse:[
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
  2475
        cmd := 'checkout' , revisionArg , ' ', checkoutName.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2476
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2477
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2478
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2479
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2480
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2481
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2482
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2483
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2484
        cmdOut notNil ifTrue:[cmdOut remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2485
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2486
        ('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2487
        "/ see if there is CVS access at all ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2488
        (self checkForExistingModule:moduleDir) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2489
            "/ disable
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2490
            DisabledModules isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2491
                DisabledModules := Set new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2492
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2493
            DisabledModules add:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2494
            ('CVSSourceCodeManager [warning]: disabled repository access for module ' , moduleDir) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2495
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2496
        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2497
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2498
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2499
    cmdOut notNil ifTrue:[cmdOut remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2500
    fullTempName := tempdir construct:checkoutNameLocal.
1405
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2501
    CacheDirectoryName isNil ifTrue:[
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2502
        cacheIt := false
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2503
    ] ifFalse:[
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2504
        fullCachedName := CacheDirectoryName asFilename constructString:cachedSourceFilename.
cd6a25ddc6fe *** empty log message ***
penk
parents: 1393
diff changeset
  2505
    ].
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2506
    fullTempName exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2507
        ('CVSSourceCodeManager [error]: failed to checkout ', fullTempName pathName, ' (file does not exist after cvs co)') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2508
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2509
        ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2510
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2511
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2512
    (cacheIt 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2513
    and:[cachedFile notNil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2514
    and:[fullTempName exists]])
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2515
    ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2516
        (OperatingSystem errorSignal catch:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2517
            fullTempName moveTo:fullCachedName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2518
        ]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2519
            ('CVSSourceCodeManager [error]: failed to rename ', fullTempName pathName, ' to ', cachedSourceFilename) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2520
            tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2521
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2522
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2523
        fullCachedName asFilename exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2524
            stream := fullCachedName asFilename readStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2525
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2526
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2527
        OperatingSystem isUNIXlike ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2528
            "/ cannot remove files which are still open ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2529
            "/ sigh - need a delete-on-close flag in FileStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2530
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2531
            tempFile := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2532
            fullTempName copyTo:tempFile.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2533
            stream := tempFile readStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2534
            stream notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2535
                stream removeOnClose:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2536
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2537
        ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2538
            stream := fullTempName readStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2539
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2540
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2541
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2542
    self releaseAndRemove:tempdir module:moduleDir outputTo:nil. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2543
    ^ stream
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2544
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2545
    "Created: / 4.11.1995 / 19:46:20 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2546
    "Modified: / 20.8.1997 / 16:37:11 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2547
    "Modified: / 23.8.2001 / 12:28:59 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2548
! !
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2549
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2550
!CVSSourceCodeManager class methodsFor:'source code administration'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2551
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2552
checkForExistingContainerInModule:moduleDir package:packageDir container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2553
    "check for a container to exist"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2554
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2555
    |fullName ret cvsRoot cmd tempDir|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2556
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2557
    cvsRoot := self getCVSROOTForModule:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2558
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2559
    fullName := moduleDir , '/' , packageDir , '/' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2560
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2561
    RemoteCVS ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2562
        cvsRoot asFilename exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2563
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2564
            "/ with local CVS - simply check if that file exists
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2565
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2566
            (fullName endsWith:',v') ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2567
                fullName := fullName , ',v'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2568
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2569
            ^ (cvsRoot , '/' , fullName) asFilename exists.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2570
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2571
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2572
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2573
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2574
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2575
    "With remote CVS, do a no-op rtag command, which doesn't
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2576
     need a working directory, but reports missing files"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2577
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2578
    (fullName endsWith:',v') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2579
        fullName := fullName copyWithoutLast:2.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2580
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2581
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2582
    cmd := '-n rtag -l -F dummy '.
1390
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2583
    [  
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2584
        |errorStream|
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2585
        errorStream := '' writeStream.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2586
        
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2587
        ret := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2588
                    executeCVSCommand:cmd , fullName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2589
                    module:moduleDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2590
                    "/ cg; cannot do it in current dir, in case it contains a CVS subDirectory,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2591
                    "/ with a different CVSRoot in its CVS/Root file ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2592
                    "/ cvs would complain then.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2593
                    inDirectory:(tempDir pathName) 
1390
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2594
                    log:false
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2595
                    errorTo:errorStream.
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2596
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2597
        "cannot check for exit status starting at cvs 1.11.5, because an exit status 0
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2598
         is returned even if the file does not exist"
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2599
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2600
        "But: if there is any output, the command failed and the container does not exist"
5ca713ed160e Fix for cvs 1.11.6 and following
Stefan Vogel <sv@exept.de>
parents: 1388
diff changeset
  2601
        ret := errorStream size == 0.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2602
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2603
        tempDir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2604
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2605
    ^ ret
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2606
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2607
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2608
     CVSSourceCodeManager 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2609
        checkForExistingContainerInModule:'stx' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2610
        package:'libbasic' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2611
        container:'Integer.st'     
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2612
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2613
     CVSSourceCodeManager 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2614
        checkForExistingContainerInModule:'stx' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2615
        package:'libtool' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2616
        container:'AboutBox.st'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2617
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2618
     CVSSourceCodeManager 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2619
        checkForExistingContainerInModule:'stx' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2620
        package:'libtool' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2621
        container:'AboutBox.st,v'     
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2622
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2623
     CVSSourceCodeManager 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2624
        checkForExistingContainerInModule:'stx' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2625
        package:'libtool' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2626
        container:'FooBar.st'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2627
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2628
     CVSSourceCodeManager 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2629
        checkForExistingContainerInModule:'DPU' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2630
        package:'test' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2631
        container:'marks'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2632
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2633
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2634
    "Created: / 9.12.1995 / 19:13:37 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2635
    "Modified: / 1.3.1999 / 19:32:55 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2636
    "Modified: / 23.7.1999 / 17:36:58 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2637
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2638
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2639
checkForExistingModule:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2640
    "check for a module to exist"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2641
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2642
    |ret cvsRoot cmd tempDir|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2643
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2644
    self activityNotification:'checking for existing module ' , moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2645
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2646
    cvsRoot := self getCVSROOTForModule:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2647
    cvsRoot isNil ifTrue:[^ false].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2648
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2649
    RemoteCVS ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2650
        cvsRoot asFilename exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2651
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2652
            "/ with local CVS - simply check if that directory exists
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2653
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2654
            ^ (cvsRoot , '/' , moduleDir) asFilename isDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2655
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2656
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2657
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2658
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2659
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2660
    "With remote CVS, do a no-op rtag command, which doesn't
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2661
     need a working directory, but reports missing files"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2662
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2663
    cmd := '-n rtag -l dummy '.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2664
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2665
        ret := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2666
                    executeCVSCommand:cmd , moduleDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2667
                    module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2668
                    "/ cg; cannot do it in current dir, in case it contains a CVS subDirectory,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2669
                    "/ with a different CVSRoot in its CVS/Root file ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2670
                    "/ cvs would complain then.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2671
                    inDirectory:(tempDir pathName) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2672
                    log:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2673
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2674
        tempDir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2675
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2676
    ^ ret
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2677
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2678
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2679
     CVSSourceCodeManager checkForExistingModule:'stx'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2680
     CVSSourceCodeManager checkForExistingModule:'DPU'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2681
     CVSSourceCodeManager checkForExistingModule:'cg'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2682
     CVSSourceCodeManager checkForExistingModule:'aeg' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2683
     CVSSourceCodeManager checkForExistingModule:'foo'   
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2684
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2685
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2686
    "Created: / 9.12.1995 / 19:13:37 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2687
    "Modified: / 1.3.1999 / 19:32:59 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2688
    "Modified: / 23.7.1999 / 17:38:59 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2689
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2690
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2691
checkForExistingModule:moduleDir package:packageDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2692
    "check for a package to exist"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2693
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2694
    |ret cvsRoot cmd tempDir fullName |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2695
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2696
    self activityNotification:'checking for existing package ' , packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2697
1365
ad41e246bd9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
  2698
    cvsRoot := self getCVSROOTForModule:moduleDir.
ad41e246bd9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
  2699
    cvsRoot isNil ifTrue:[^ false].
ad41e246bd9d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1362
diff changeset
  2700
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2701
    fullName := moduleDir , '/' , packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2702
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2703
    RemoteCVS ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2704
        cvsRoot asFilename exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2705
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2706
            "/ with local CVS - simply check if that directory exists
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2707
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2708
            ^ (cvsRoot , '/' , fullName) asFilename isDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2709
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2710
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2711
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2712
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2713
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2714
    "With remote CVS, do a no-op rtag command, which doesn't
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2715
     need a working directory, but reports missing files"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2716
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2717
    cmd := '-n rtag -l -F dummy '.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2718
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2719
        ret := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2720
                    executeCVSCommand:cmd, fullName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2721
                    module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2722
                    "/ cg; cannot do it in current dir, in case it contains a CVS subDirectory,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2723
                    "/ with a different CVSRoot in its CVS/Root file ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2724
                    "/ cvs would complain then.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2725
                    inDirectory:(tempDir pathName) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2726
                    log:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2727
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2728
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2729
        tempDir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2730
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2731
    ^ ret
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2732
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2733
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2734
     CVSSourceCodeManager checkForExistingModule:'stx' package:'libbasic' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2735
     CVSSourceCodeManager checkForExistingModule:'aeg' package:'libProgram'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2736
     CVSSourceCodeManager checkForExistingModule:'foo' package:'libbasic' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2737
     CVSSourceCodeManager checkForExistingModule:'foo' package:'bar'   
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2738
     CVSSourceCodeManager checkForExistingModule:'cg' package:'private'   
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2739
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2740
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2741
    "Created: / 9.12.1995 / 19:13:37 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2742
    "Modified: / 1.3.1999 / 19:33:04 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2743
    "Modified: / 23.7.1999 / 17:39:21 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2744
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2745
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2746
createContainerFor:aClass inModule:moduleDir package:packageDir container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2747
    "create a container - this does an initial checkin
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2748
     (i.e. cvs add & cvs commit)"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2749
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2750
    |fullName tempdir checkoutName cmdOut cmd tempFile idx aStream whatHappened l newRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2751
     changeLog entry newString startIdx endIdx checkInDir logTmp s|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2752
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2753
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2754
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2755
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2756
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2757
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2758
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2759
    fullName := moduleDir , '/' , packageDir , '/' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2760
    checkoutName :=  moduleDir , '/' , packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2761
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2762
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2763
    "/ first, check out everything there - this creates the CVS helpfiles
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2764
    "/ required later.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2765
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2766
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2767
    self activityNotification:'checking for directory ' , checkoutName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2768
    tempdir := self createLocalDirectory:packageDir inModule:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2769
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2770
        ('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2771
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2772
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2773
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2774
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2775
    "/ create the source there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2776
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2777
    tempFile := (tempdir construct:checkoutName) construct:fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2778
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2779
        aStream := tempFile writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2780
    ] on:FileStream openErrorSignal do:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2781
        ('CVSSourceCodeManager [error]: temporary fileout failed -> ', tempFile name) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2782
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2783
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2784
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2785
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2786
    Class fileOutErrorSignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2787
        'CVSSourceCodeManager [error]: fileout failed' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2788
        aStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2789
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2790
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2791
    ] do:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2792
        aClass fileOutOn:aStream withTimeStamp:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2793
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2794
    aStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2795
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2796
    tempFile exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2797
        'CVSSourceCodeManager [error]: temporary fileout failed' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2798
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2799
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2800
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2801
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2802
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2803
    "/ and add it to the repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2804
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2805
    self activityNotification:'adding ' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2806
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2807
    OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2808
        checkInDir := tempdir constructString:checkoutName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2809
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2810
        OperatingSystem isMSDOSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2811
            checkInDir := tempdir constructString:(checkoutName copyReplaceAll:$/ with:$\).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2812
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2813
            self error:'VMS case not yet implemented'. "/ add code for VMS ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2814
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2815
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2816
    cmd := 'add ' , fileName , ' > ', '"' , cmdOut name, '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2817
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2818
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2819
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2820
        inDirectory:checkInDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2821
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2822
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2823
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2824
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2825
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2826
        ('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2827
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2828
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2829
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2830
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2831
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2832
    "/ commit
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2833
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2834
    self activityNotification:'committing ' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2835
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2836
    OperatingSystem isUNIXlike ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2837
        "/ save the log message into another tempFile ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2838
        logTmp := Filename newTemporaryIn:checkInDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2839
        s := logTmp writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2840
        s nextPutAll:'initial checkin'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2841
        s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2842
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2843
        cmd := 'commit -F "', logTmp baseName, '" ', fileName, ' > ', '"', cmdOut name, '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2844
    ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2845
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2846
        "/ CVS up to V1.9.14 prints the 'new revision' to stderr,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2847
        "/ CVS V1.9.16 to stdout.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2848
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2849
        cmd := 'commit -m "initial checkin" ' , fileName , ' > ', '"' , cmdOut name, '"', ' 2>&1'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2850
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2851
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2852
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2853
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2854
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2855
        inDirectory:checkInDir "tempdir name"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2856
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2857
        Verbose == true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2858
            'CVSMGR: failed to execute: ' infoPrint. cmd infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2859
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2860
        cmdOut fileSize > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2861
            whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2862
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2863
            whatHappened := '<< no message >>'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2864
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2865
        self warn:'The following problem was reported by cvs:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2866
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2867
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2868
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2869
The class has NOT been checked into the repository.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2870
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2871
       'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2872
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2873
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2874
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2875
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2876
    whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2877
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2878
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2879
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2880
    "/ release it towards cvs
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2881
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2882
    self releaseAndRemove:tempdir module:moduleDir outputTo:nil. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2883
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2884
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2885
    "/ good - its in the CVS repository; now, we need the updated RCS header
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2886
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2887
    (whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2888
        'CVSSourceCodeManager [warning]: unexpected empty commit command output' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2889
        "/ TODO: scan the file for $Header ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2890
        "/ and extract the revision manually
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2891
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2892
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2893
        whatHappened := whatHappened asCollectionOfLines asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2894
        idx := whatHappened indexOfLineStartingWith:'initial revision:'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2895
        idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2896
            startIdx := 18
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2897
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2898
            idx := whatHappened indexOfLineStartingWith:'new revision:'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2899
            idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2900
                'CVSSourceCodeManager [warning]: container existed before' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2901
                startIdx := 14.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2902
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2903
                'CVSSourceCodeManager [warning]: unexpected commit command output (no new-revision info)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2904
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2905
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2906
        idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2907
            l := whatHappened at:idx.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2908
            endIdx := (l indexOf:$; startingAt:startIdx) - 1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2909
            endIdx < 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2910
                endIdx := l size
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2911
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2912
            newRevision := (l copyFrom:startIdx to:endIdx) withoutSpaces.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2913
            (Number fromString:newRevision onError:nil) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2914
                newRevision := '1.1'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2915
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2916
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2917
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2918
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2919
    Transcript showCR:'created new sourceContainer for ' , aClass name , '.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2920
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2921
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2922
    "/ patch the classes revisionInfo (but keep binaryRevision unchanged)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2923
    "/ this makes everyone here believe, that the incore version of the class is based upon
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2924
    "/ the newly checked in version.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2925
    "/ (however, the binaryRevision must remain as it is - we will need it to fetch the sourceCode
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2926
    "/  correctly for all unchanged methodss)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2927
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2928
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2929
    newRevision notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2930
        changeLog := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2931
                        revisionLogOf:aClass 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2932
                        fromRevision:newRevision 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2933
                        toRevision:newRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2934
                        fileName:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2935
                        directory:packageDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2936
                        module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2937
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2938
        (changeLog isNil or:[(changeLog at:#revisions) size ~~ 1]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2939
            'CVSSourceCodeManager [error]: failed to update revisionString (no log)' errorPrintCR
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2940
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2941
            entry := (changeLog at:#revisions) first.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2942
            newString := self revisionStringFromLog:changeLog entry:entry forClass:aClass.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2943
            aClass updateVersionMethodFor:newString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2944
            ('CVSSourceCodeManager [info]: updated revisionString to:',newString) infoPrintCR
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2945
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2946
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2947
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2948
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2949
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2950
    Class addChangeRecordForClassCheckIn:aClass.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2951
    self postCheckInClass:aClass.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2952
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2953
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2954
    "Created: / 9.12.1995 / 19:13:37 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2955
    "Modified: / 23.7.1999 / 19:47:59 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2956
    "Modified: / 5.11.2001 / 14:22:56 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2957
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2958
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2959
createContainerForText:someText inModule:moduleDir package:packageDir container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2960
    "create a container - this does an initial checkin
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2961
     (i.e. cvs add & cvs commit)"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2962
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2963
    |fullName tempdir checkoutName cmdOut cmd tempFile idx aStream whatHappened l newRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2964
     startIdx endIdx checkInDir logTmp s|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2965
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2966
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2967
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2968
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2969
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2970
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2971
    fullName := moduleDir , '/' , packageDir , '/' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2972
    checkoutName :=  moduleDir , '/' , packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2973
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2974
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2975
    "/ first, check out everything there - this creates the CVS helpfiles
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2976
    "/ required later.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2977
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2978
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2979
    self activityNotification:'checking for directory ' , checkoutName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2980
    tempdir := self createLocalDirectory:packageDir inModule:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2981
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2982
        ('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2983
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2984
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2985
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2986
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2987
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2988
        "/ create the source there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2989
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2990
        tempFile := (tempdir construct:checkoutName) construct:fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2991
        [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2992
            aStream := tempFile writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2993
        ] on:FileStream openErrorSignal do:[:ex|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2994
            ('CVSSourceCodeManager [error]: temporary fileout failed -> ', tempFile name) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2995
            ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2996
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2997
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2998
        aStream nextPutAll:someText.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  2999
        aStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3000
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3001
        tempFile exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3002
            'CVSSourceCodeManager [error]: temporary fileout failed' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3003
            ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3004
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3005
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3006
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3007
        "/ and add it to the repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3008
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3009
        self activityNotification:'adding ' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3010
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3011
        OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3012
            checkInDir := tempdir constructString:checkoutName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3013
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3014
            OperatingSystem isMSDOSlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3015
                checkInDir := tempdir constructString:(checkoutName copyReplaceAll:$/ with:$\).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3016
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3017
                self error:'VMS case not yet implemented'. "/ add code for VMS ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3018
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3019
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3020
        cmd := 'add ' , fileName , ' > ', '"' , cmdOut name, '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3021
        (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3022
            executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3023
            module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3024
            inDirectory:checkInDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3025
        ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3026
            'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3027
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3028
            cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3029
            ('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3030
            ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3031
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3032
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3033
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3034
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3035
        "/ commit
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3036
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3037
        self activityNotification:'committing ' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3038
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3039
        OperatingSystem isUNIXlike ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3040
            "/ save the log message into another tempFile ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3041
            logTmp := Filename newTemporaryIn:checkInDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3042
            s := logTmp writeStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3043
            s nextPutAll:'initial checkin'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3044
            s close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3045
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3046
            cmd := 'commit -F "', logTmp baseName, '" ', fileName, ' >', '"', cmdOut name, '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3047
        ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3048
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3049
            "/ CVS up to V1.9.14 prints the 'new revision' to stderr,
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3050
            "/ CVS V1.9.16 to stdout.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3051
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3052
            cmd := 'commit -m "initial checkin" ' , fileName , ' > ', '"' , cmdOut name, '"', ' 2>&1'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3053
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3054
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3055
        (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3056
            executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3057
            module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3058
            inDirectory:checkInDir "tempdir name"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3059
        ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3060
            Verbose == true ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3061
                'CVSMGR: failed to execute: ' infoPrint. cmd infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3062
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3063
            cmdOut fileSize > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3064
                whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3065
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3066
                whatHappened := '<< no message >>'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3067
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3068
            self warn:'The following problem was reported by cvs:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3069
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3070
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3071
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3072
The class has NOT been checked into the repository.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3073
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3074
           'CVSSourceCodeManager [error]: cannot checkin modified class source' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3075
            cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3076
            ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3077
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3078
        whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3079
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3080
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3081
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3082
        "/ release it towards cvs
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3083
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3084
        self releaseAndRemove:tempdir module:moduleDir outputTo:nil. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3085
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3086
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3087
        "/ good - its in the CVS repository; now, we need the updated RCS header
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3088
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3089
        (whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3090
            'CVSSourceCodeManager [warning]: unexpected empty commit command output' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3091
            "/ TODO: scan the file for $Header ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3092
            "/ and extract the revision manually
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3093
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3094
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3095
            whatHappened := whatHappened asCollectionOfLines asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3096
            idx := whatHappened indexOfLineStartingWith:'initial revision:'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3097
            idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3098
                startIdx := 18
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3099
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3100
                idx := whatHappened indexOfLineStartingWith:'new revision:'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3101
                idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3102
                    'CVSSourceCodeManager [warning]: container existed before' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3103
                    startIdx := 14.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3104
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3105
                    'CVSSourceCodeManager [warning]: unexpected commit command output (no new-revision info)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3106
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3107
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3108
            idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3109
                l := whatHappened at:idx.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3110
                endIdx := (l indexOf:$; startingAt:startIdx) - 1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3111
                endIdx < 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3112
                    endIdx := l size
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3113
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3114
                newRevision := (l copyFrom:startIdx to:endIdx) withoutSpaces.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3115
                (Number fromString:newRevision onError:nil) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3116
                    newRevision := '1.1'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3117
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3118
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3119
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3120
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3121
        Transcript showCR:'created new sourceContainer for ' , fileName , '.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3122
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3123
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3124
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3125
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3126
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3127
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3128
createModule:moduleName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3129
    "create a module directory"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3130
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3131
    |tempdir moduleDir cmdOut cmd|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3132
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3133
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3134
    "/ first, create a temporary work tree
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3135
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3136
    tempdir := self createTempDirectory:nil forModule:moduleName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3137
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3138
        ('CVSSourceCodeManager [error]: no tempDir - cannot create moduleDirectory') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3139
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3140
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3141
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3142
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3143
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3144
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3145
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3146
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3147
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3148
    "/ create the module directory 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3149
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3150
    moduleDir := tempdir construct:moduleName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3151
    moduleDir exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3152
        'CVSSourceCodeManager [error]: failed to create: ' errorPrint.  moduleDir name errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3153
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3154
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3155
    ].     
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3156
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3157
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3158
    "/ then import it into CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3159
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3160
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3161
    cmd := 'import -m "created from browser" ' , moduleName , ' initialV initialR > ' , cmdOut name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3162
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3163
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3164
        module:moduleName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3165
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3166
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3167
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3168
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3169
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3170
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3171
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3172
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3173
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3174
    'CVSSourceCodeManager [info]: created new module: ' infoPrint. moduleName infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3175
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3176
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3177
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3178
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3179
    "Created: / 9.12.1995 / 19:53:51 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3180
    "Modified: / 7.1.1998 / 14:18:57 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3181
    "Modified: / 6.6.1998 / 16:15:34 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3182
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3183
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3184
createModule:moduleDirName package:packageDirName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3185
    "create a package directory"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3186
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3187
    |tempdir cmdOut cmd packageDir moduleDir relativePath idx parentPackage|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3188
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3189
    "/ any parent package required ?
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3190
    idx := packageDirName lastIndexOf:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3191
    idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3192
        parentPackage := packageDirName copyTo:idx-1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3193
        (self checkForExistingModule:moduleDirName package:parentPackage) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3194
            (self createModule:moduleDirName package:parentPackage) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3195
                ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3196
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3197
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3198
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3199
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3200
    (moduleDirName asFilename components includes:'core') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3201
        ('CVSSourceCodeManager [error]: cvs does not allow for a module to be named ''core'' - cannot create moduleDirectory') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3202
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3203
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3204
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3205
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3206
    "/ first, create a temporary work tree
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3207
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3208
    tempdir := self createTempDirectory:packageDirName forModule:moduleDirName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3209
    tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3210
        ('CVSSourceCodeManager [error]: no tempDir - cannot create moduleDirectory') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3211
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3212
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3213
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3214
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3215
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3216
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3217
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3218
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3219
    moduleDir := tempdir construct:moduleDirName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3220
    moduleDir isDirectory ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3221
        'CVSSourceCodeManager [error]: command failed: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3222
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3223
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3224
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3225
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3226
        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3227
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3228
    "/ create the package directory there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3229
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3230
    packageDir := moduleDir construct:packageDirName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3231
    OperatingSystem errorSignal catch:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3232
        packageDir recursiveMakeDirectory.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3233
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3234
    packageDir isDirectory ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3235
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3236
        ('CVSSourceCodeManager [error]: cannot create new directory: ' , packageDir pathName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3237
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3238
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3239
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3240
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3241
    "/ then import it into CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3242
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3243
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3244
    relativePath := moduleDirName asFilename constructString:packageDirName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3245
    cmd := 'import -m "created from browser" . initialV initialR > ' , cmdOut name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3246
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3247
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3248
        module:moduleDirName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3249
        inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3250
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3251
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3252
        'CVSSourceCodeManager [error]: output from cvs:' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3253
        (cmdOut contentsOfEntireFile) errorPrint.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3254
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3255
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3256
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3257
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3258
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3259
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3260
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3261
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3262
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3263
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3264
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3265
      self createModule:'stefan' package:'dummy1'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3266
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3267
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3268
    "Created: / 9.12.1995 / 20:09:33 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3269
    "Modified: / 23.7.1999 / 18:40:49 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3270
    "Modified: / 18.1.2000 / 20:14:01 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3271
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3272
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3273
getExistingContainersInModule:aModule package:aPackage
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3274
    "return a list of existing containers.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3275
     This does not work with remote-CVS"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3276
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3277
    |cvsRoot containers moduleDir packageDir tempdir cmdOut cmd dirName|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3278
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3279
    cvsRoot := self getCVSROOTForModule:aModule.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3280
    cvsRoot isNil ifTrue:[^ #() ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3281
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3282
    dirName := aModule , '/' , aPackage.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3283
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3284
    self activityNotification:'getting list of containers in ' , dirName , ' ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3285
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3286
    (RemoteCVS 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3287
    or:[cvsRoot asFilename exists not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3288
        "/ remote CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3289
        "/ filter the output of the history command
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3290
        "/ (sigh - there ought to be some cvs-command for that)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3291
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3292
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3293
        tempdir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3294
        tempdir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3295
            ('CVSSourceCodeManager [error]: no tempDir - cannot checkout') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3296
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3297
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3298
1393
28d04a5111c6 cvs V1.11.14 does not support the 'cvs -l' option any longer and breaks
Stefan Vogel <sv@exept.de>
parents: 1390
diff changeset
  3299
        cmd := 'checkout ', dirName.
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3300
        OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3301
            "/ can redirect output
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3302
            cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3303
            cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3304
                cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3305
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3306
            cmd := cmd , ' > ' , cmdOut name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3307
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3308
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3309
        (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3310
            executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3311
            module:aModule
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3312
            inDirectory:tempdir name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3313
        ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3314
            'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3315
            cmdOut notNil ifTrue:[cmdOut remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3316
            tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3317
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3318
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3319
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3320
        cmdOut notNil ifTrue:[cmdOut remove].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3321
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3322
        packageDir := (tempdir construct:dirName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3323
        (packageDir isDirectory) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3324
            'CVSSourceCodeManager [error]: checkout failed (no dir)' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3325
            tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3326
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3327
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3328
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3329
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3330
        "/ enumerate the checkedOut directory, looking for plain files
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3331
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3332
        containers := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3333
        packageDir directoryContents do:[:aFilenameString |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3334
            |fn|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3335
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3336
            (packageDir construct:aFilenameString) isDirectory ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3337
                containers add:aFilenameString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3338
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3339
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3340
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3341
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3342
        (cvsRoot := cvsRoot asFilename) exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3343
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3344
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3345
        ((moduleDir := cvsRoot construct:aModule) exists
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3346
        and:[moduleDir isDirectory]) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3347
            self warn:'No such module'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3348
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3349
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3350
        ((packageDir := moduleDir construct:aPackage) exists
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3351
        and:[packageDir isDirectory]) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3352
            self warn:'No such package'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3353
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3354
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3355
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3356
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3357
        "/ enumerate the package directory, looking for container files
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3358
        "/ strip off the ,v ending.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3359
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3360
        containers := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3361
        packageDir directoryContents do:[:aFilenameString |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3362
            |fn|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3363
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3364
            (aFilenameString endsWith:',v') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3365
                containers add:(aFilenameString copyWithoutLast:2)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3366
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3367
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3368
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3369
    ^ containers sort
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3370
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3371
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3372
     CVSSourceCodeManager getExistingContainersInModule:'stx' package:'libhtml'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3373
     CVSSourceCodeManager getExistingContainersInModule:'cg'  package:'java'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3374
     CVSSourceCodeManager getExistingContainersInModule:'sel' package:'bmti'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3375
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3376
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3377
    "Created: / 20.5.1998 / 19:48:59 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3378
    "Modified: / 20.5.1998 / 22:08:29 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3379
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3380
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3381
getExistingModules
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3382
    "return a list of existing modules.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3383
     This does not work with remote-CVS"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3384
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3385
    |cvsRoot modules inStream list|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3386
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3387
    cvsRoot := self getCVSROOTForModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3388
    cvsRoot isNil ifTrue:[^ #() ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3389
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3390
    self activityNotification:'getting list of modules...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3391
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3392
    (RemoteCVS 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3393
    or:[cvsRoot asFilename exists not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3394
        "/ remote CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3395
        "/ filter the output of the history command
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3396
        "/ (sigh - there ought to be some cvs-command for that)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3397
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3398
        inStream := PipeStream readingFrom:'cvs -d ' , cvsRoot , ' history -x A'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3399
        inStream isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3400
            self warn:'This operation is not possible with this remoteCVS server'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3401
            ^ #().
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3402
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3403
        list := inStream contents asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3404
        inStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3405
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3406
        modules := Set new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3407
        list do:[:line |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3408
            |idx items entry|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3409
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3410
            items := line asCollectionOfWords.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3411
            "/ #( 'A' '10/29' '17:47' '+0000' 'cg' '1.1' '.cvsignore' 'stx' '==' '~/work/stx' )
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3412
            "/ fetch the word before '=='
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3413
        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3414
            idx := items indexOf:'=='.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3415
            idx > 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3416
                entry := items at:idx-1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3417
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3418
                "/ extract the first directory component ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3419
                idx := entry indexOf:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3420
                idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3421
                    entry := entry copyTo:idx-1
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3422
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3423
                modules add:entry.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3424
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3425
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3426
        modules := modules asArray
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3427
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3428
        "/ local CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3429
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3430
        "/ enumerate the root directory, looking for subdirs
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3431
        "/ which contain a CVS subdir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3432
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3433
        (cvsRoot := cvsRoot asFilename) exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3434
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3435
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3436
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3437
        modules := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3438
        cvsRoot directoryContents do:[:aFilenameString |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3439
            |fn|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3440
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3441
            (aFilenameString endsWith:',v') ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3442
                (#('CVS' 'CVSROOT' 'Attic') includes:aFilenameString) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3443
                    (fn := (cvsRoot construct:aFilenameString)) isDirectory ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3444
                        modules add:aFilenameString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3445
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3446
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3447
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3448
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3449
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3450
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3451
    ^ modules sort
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3452
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3453
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3454
     CVSSourceCodeManager getExistingModules
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3455
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3456
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3457
    "Created: / 20.5.1998 / 19:28:43 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3458
    "Modified: / 20.5.1998 / 22:07:07 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3459
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3460
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3461
getExistingPackagesInModule:aModule
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3462
    "return a list of existing packages.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3463
     This does not work with remote-CVS"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3464
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3465
    |cvsRoot packages moduleDir inStream list|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3466
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3467
    cvsRoot := self getCVSROOTForModule:aModule.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3468
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3469
    self activityNotification:'getting list of packages in ' , aModule , ' ...'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3470
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3471
    (RemoteCVS 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3472
    or:[cvsRoot asFilename exists not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3473
        "/ remote CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3474
        "/ filter the output of the history command
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3475
        "/ (sigh - there ought to be some cvs-command for that)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3476
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3477
        inStream := PipeStream readingFrom:'cvs -d ' , cvsRoot , ' history -x A'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3478
        inStream isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3479
            self warn:'This operation is not possible with this remoteCVS server'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3480
            ^ #().
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3481
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3482
        list := inStream contents asStringCollection.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3483
        inStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3484
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3485
        packages := Set new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3486
        list do:[:line |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3487
            |items idx entry|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3488
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3489
            items := line asCollectionOfWords.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3490
            "/ #( 'A' '10/29' '17:47' '+0000' 'cg' '1.1' '.cvsignore' 'stx' '==' '~/work/stx' )
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3491
            "/ fetch the word before '=='
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3492
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3493
            idx := items indexOf:'=='.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3494
            idx > 1 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3495
                entry := items at:idx-1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3496
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3497
                "/ extract the first directory component ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3498
                (entry startsWith:aModule) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3499
                    idx := entry indexOf:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3500
                    idx ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3501
                        (entry copyTo:idx-1) = aModule ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3502
                            packages add:(entry copyFrom:idx+1).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3503
                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3504
                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3505
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3506
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3507
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3508
        packages := packages asArray
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3509
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3510
        "/ local CVS
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3511
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3512
        "/ enumerate the module directory, looking for subdirs
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3513
        "/ which contain a CVS subdir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3514
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3515
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3516
        (cvsRoot := cvsRoot asFilename) exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3517
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3518
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3519
        (moduleDir := cvsRoot construct:aModule) isDirectory ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3520
            self warn:'No such module'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3521
            ^ #()
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3522
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3523
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3524
        packages := OrderedCollection new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3525
        moduleDir directoryContents do:[:aFilenameString |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3526
            |fn|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3527
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3528
            (aFilenameString endsWith:',v') ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3529
                (#('CVS' 'CVSROOT' 'Attic') includes:aFilenameString) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3530
                    (fn := (moduleDir construct:aFilenameString)) isDirectory ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3531
                        packages add:aFilenameString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3532
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3533
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3534
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3535
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3536
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3537
    ^ packages sort
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3538
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3539
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3540
     CVSSourceCodeManager getExistingPackagesInModule:'stx'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3541
     CVSSourceCodeManager getExistingPackagesInModule:'cg'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3542
     CVSSourceCodeManager getExistingPackagesInModule:'sel'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3543
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3544
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3545
    "Created: / 20.5.1998 / 19:28:43 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3546
    "Modified: / 20.5.1998 / 22:07:13 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3547
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3548
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3549
initialRevisionStringFor:aClass inModule:moduleDir package:packageDir container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3550
    "return a string usable as initial revision string"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3551
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3552
    |cvsRoot|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3553
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3554
    cvsRoot := self getCVSROOTForModule:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3555
    cvsRoot := self repositoryTopDirectory:cvsRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3556
    ^ self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3557
        initialRCSRevisionStringFor:aClass 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3558
        in:(cvsRoot , '/' , moduleDir , '/' , packageDir)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3559
        container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3560
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3561
    "Modified: / 19.9.1997 / 06:34:10 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3562
    "Modified: / 16.1.1998 / 17:34:13 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3563
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3564
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3565
newestRevisionInFile:classFileName directory:packageDir module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3566
    "return the newest revision found in a container.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3567
     Return nil on failure.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3568
     Uses 'cvs status', which is much faster than 'cvs log'"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3569
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3570
    |info|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3571
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3572
    info := self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3573
            statusOf:nil 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3574
            fileName:classFileName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3575
            directory:packageDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3576
            module:moduleDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3577
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3578
    info isNil ifTrue:[^ nil].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3579
    ^ info at:#newestRevision ifAbsent:nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3580
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3581
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3582
     SourceCodeManager newestRevisionInFile:'Array.st' directory:'libbasic' module:'stx'       
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3583
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3584
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3585
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3586
readRevisionLogEntryFromStream:inStream
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3587
    "read and parse a single revision info-entry from the cvs log output.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3588
     Return nil on end.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3589
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3590
     The returned information is a structure (IdentityDictionary)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3591
     filled with:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3592
              #revision              -> the revision string
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3593
              #author                -> who checked that revision into the repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3594
              #date                  -> when was it checked in
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3595
              #state                 -> the RCS state
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3596
              #numberOfChangedLines  -> the number of changed line w.r.t the previous
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3597
              #logMessage            -> the checkIn log message
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3598
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3599
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3600
    |revLine1 revLine2 record s line atEnd|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3601
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3602
    atEnd := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3603
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3604
    revLine1 := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3605
    [revLine1 notNil and:[(revLine1 startsWith:'revision ') not]]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3606
        whileTrue:[inStream atEnd ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3607
                    revLine1 := nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3608
                   ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3609
                    revLine1 := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3610
                  ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3611
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3612
    revLine2 := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3613
    (revLine1 notNil and:[revLine2 notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3614
        record := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3615
        record at:#revision put:(revLine1 asCollectionOfWords at:2).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3616
        "/ decompose date/author/state etc.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3617
        (revLine2 asCollectionOfSubstringsSeparatedBy:$;) do:[:info |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3618
            |subEntry|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3619
            subEntry := info withoutSeparators.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3620
            #('date:'   #date
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3621
              'author:' #author 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3622
              'state:'  #state 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3623
              'lines:'  #numberOfChangedLines
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3624
             ) pairWiseDo:[:word :key |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3625
                s := subEntry restAfter:word withoutSeparators:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3626
                s notNil ifTrue:[record at:key put:s.].                        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3627
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3628
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3629
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3630
        "first revision does not hav a 'lines:' entry"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3631
        (record includesKey:#numberOfChangedLines) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3632
            record at:#numberOfChangedLines put:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3633
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3634
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3635
        s := nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3636
        line := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3637
        [atEnd or:[line isNil or:[line startsWith:'--------']]] whileFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3638
            (line startsWith:'==========') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3639
                atEnd := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3640
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3641
                (line withoutSpaces = '.') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3642
                    line := '*** empty log message ***'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3643
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3644
                s isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3645
                    s := line
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3646
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3647
                    s := s , Character cr asString , line.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3648
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3649
                line := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3650
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3651
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3652
        record at:#logMessage put:s.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3653
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3654
    ^record.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3655
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3656
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3657
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3658
removeContainerFor:aClass inModule:moduleDir package:packageDir container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3659
    "remove a container"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3660
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3661
    (self removeContainerInModule:moduleDir package:packageDir container:fileName) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3662
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3663
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3664
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3665
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3666
    "/ patch the classes revisionInfo (but keep binaryRevision unchanged)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3667
    "/ this makes everyone here believe, that the incore version of the class is based upon
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3668
    "/ some container-less class.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3669
    "/ (however, the binaryRevision must remain as it is - we will need it to fetch the sourceCode
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3670
    "/  correctly for all unchanged methodss)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3671
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3672
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3673
    aClass updateVersionMethodFor:'no longer in repository'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3674
    Class addChangeRecordForClassContainerRemove:aClass.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3675
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3676
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3677
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3678
removeContainerInModule:moduleDir package:packageDir container:fileName
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3679
    "remove a container"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3680
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3681
    |fullName tempdir checkoutName cmdOut cmd tempFile whatHappened|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3682
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3683
    fullName := moduleDir , '/' , packageDir , '/' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3684
    checkoutName :=  moduleDir , '/' , packageDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3685
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3686
    (tempdir := self createLocalDirectory:packageDir inModule:moduleDir with:fileName) isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3687
        'CVSSourceCodeManager [error]: failed to checkout: ' errorPrint. checkoutName errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3688
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3689
        ('CVSSourceCodeManager [error]: cannot checkout ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3690
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3691
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3692
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3693
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3694
    "/ and remove it to the repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3695
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3696
    self activityNotification:'removing ' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3697
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3698
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3699
    "/ check presence of source there
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3700
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3701
    tempFile := (tempdir construct:checkoutName) construct:fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3702
    tempFile exists ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3703
        'CVSSourceCodeManager [error]: temporary fileout failed' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3704
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3705
        ^ false
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3706
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3707
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3708
    tempFile exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3709
        tempFile remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3710
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3711
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3712
    cmdOut := Filename newTemporary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3713
    cmdOut exists ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3714
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3715
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3716
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3717
    cmd := 'remove ' , fileName , ' > ' , cmdOut name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3718
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3719
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3720
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3721
        inDirectory:(tempdir constructString:checkoutName)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3722
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3723
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3724
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3725
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3726
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3727
        ('CVSSourceCodeManager [error]: cannot remove ' , checkoutName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3728
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3729
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3730
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3731
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3732
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3733
    "/ commit
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3734
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3735
    self activityNotification:'committing removal of ' , fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3736
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3737
    cmd := 'commit -m "removed container" -l ' , fileName , ' 2> ' , cmdOut name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3738
    (self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3739
        executeCVSCommand:cmd 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3740
        module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3741
        inDirectory:(tempdir constructString:checkoutName)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3742
    ) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3743
        'CVSSourceCodeManager [error]: failed to execute: ' errorPrint. cmd errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3744
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3745
        cmdOut fileSize > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3746
            whatHappened := cmdOut contentsOfEntireFile asString.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3747
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3748
            whatHappened := '<< no message >>'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3749
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3750
        self warn:'The following problem was reported by cvs:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3751
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3752
' , whatHappened , '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3753
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3754
The container has NOT been removed into the repository.'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3755
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3756
       'CVSSourceCodeManager [error]: cannot remove container' errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3757
        cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3758
        tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3759
        ^ false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3760
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3761
    cmdOut remove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3762
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3763
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3764
    "/ release the temporary tree towards cvs
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3765
    "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3766
    self releaseAndRemove:tempdir module:moduleDir outputTo:nil. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3767
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3768
    tempdir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3769
    ^ true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3770
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3771
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3772
     CVSSourceCodeManager removeContainerInModule:'stx' package:'private' container:'WorldPO.st'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3773
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3774
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3775
    "Modified: / 26.2.1998 / 17:33:57 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3776
    "Modified: / 18.1.2000 / 21:02:30 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3777
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3778
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3779
reportHistoryLogSince:timeGoal filterSTSources:filter filterUser:userFilter filterRepository:filterRep filterModules:filterModules inTo:aBlock
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3780
    "process a full historyLog, evaluate aBlock for each entry, passing 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3781
     the logs info in a dictionary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3782
     This walks over all possible repositories.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3783
     filterRep may be a collection of repository names 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3784
     (i.e. 'stc', 'exept', 'phx' etc.) to only report changes made to one
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3785
     of those repositories.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3786
     filterUser, if non-nil, will filter only changes made by that user."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3787
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3788
    |inStream line words recordType fileName user date time rev pkgDir module idx
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3789
     clsName cls clsRev roots info tempDir endReached|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3790
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3791
    CVSRoot isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3792
        'CVSSourceCodeManager [info]: CVSROOT not set' infoPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3793
        ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3794
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3795
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3796
    CVSModuleRoots notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3797
        roots := Set withAll:(CVSModuleRoots values)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3798
    ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3799
        roots := Set new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3800
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3801
    roots add:CVSRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3802
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3803
    "/ must do it in a tempDir, to avoid cvs validating the -D arg
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3804
    "/ against any info found in CVS/Root
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3805
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3806
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3807
    tempDir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3808
        ('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3809
        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3810
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3811
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3812
    roots do:[:aCVSRoot |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3813
        |root host cmd|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3814
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3815
        cmd := 'cvs -d ' , aCVSRoot.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3816
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3817
        "/ workaround a CVS bug ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3818
        "/ cvs crashes with:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3819
        "/   cvs -d exept:/files/CVS history -x WARM -a -D "yesterday"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3820
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3821
        "/ but works ok, when doing:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3822
        "/   rsh exept cvs -d /files/CVS history -x WARM -a -D "yesterday"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3823
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3824
        (aCVSRoot startsWith:':') ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3825
            OperatingSystem isUNIXlike ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3826
                host := aCVSRoot copyTo:(aCVSRoot indexOf:$:)-1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3827
                (host size > 0 and:[(host includes:Character space) not]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3828
                    root := aCVSRoot copyFrom:(aCVSRoot indexOf:$:)+1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3829
                    cmd := 'rsh ' , host , ' cvs -d ' , root    
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3830
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3831
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3832
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3833
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3834
        cmd := cmd , ' history -x WARM -a'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3835
        (timeGoal notNil and:[timeGoal notEmpty]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3836
            cmd := cmd , ' -D "' , timeGoal , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3837
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3838
        filterRep notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3839
            filterRep do:[:aRepository |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3840
                cmd := cmd , ' -p "' , aRepository , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3841
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3842
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3843
        userFilter notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3844
            userFilter isString ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3845
                cmd := cmd , ' -u "' , userFilter , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3846
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3847
                userFilter do:[:user |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3848
                    cmd := cmd , ' -u "' , user , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3849
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3850
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3851
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3852
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3853
"/ either I dont understand CVS, or it does not work correctly...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3854
"/ in any case, the -m option does NOT filter modules. (sigh)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3855
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3856
"/        filterModules notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3857
"/            filterModules do:[:aModule |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3858
"/                cmd := cmd , ' -m "' , aModule , '"'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3859
"/            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3860
"/        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3861
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3862
        Transcript showCR:cmd.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3863
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3864
        inStream := PipeStream readingFrom:cmd inDirectory:tempDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3865
        inStream isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3866
            ('CVSSourceCodeManager [error]: cannot open pipe to ''cvs history''') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3867
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3868
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3869
            inStream class streamErrorSignal handle:[:ex |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3870
                ('CVSSourceCodeManager [error]: pipe read error (''cvs history'')') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3871
                ex return.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3872
            ] do:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3873
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3874
                "/ read the commands pipe output and reformat the lines
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3875
                "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3876
                endReached := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3877
                [endReached] whileFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3878
                    inStream readWait.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3879
                    line := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3880
                    (endReached := line isNil) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3881
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3882
                        "/ cvs history line is of the following format:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3883
                        "/ [Ma] date time +xxx user rev name module/package ....
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3884
                        words := line asCollectionOfWords.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3885
                        words size >= 8 ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3886
                            "/ something like 'No records selected' ...
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3887
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3888
                        ] ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3889
                            recordType := words at:1.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3890
                            fileName := words at:7.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3891
                            user := words at:5.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3892
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3893
                            (filter not 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3894
                            or:[fileName endsWith:'.st']) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3895
                                (userFilter isNil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3896
                                or:[userFilter = user]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3897
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3898
                                    date := words at:2.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3899
                                    time := words at:3.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3900
                                    rev := words at:6.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3901
                                    pkgDir := words at:8.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3902
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3903
                                    module := pkgDir copy.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3904
                                    (module startsWith:'./') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3905
                                        module := module copyFrom:3.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3906
                                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3907
                                    idx := module indexOf:$/.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3908
                                    idx ~~ 0 ifTrue:[    
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3909
                                        module at:idx put:$:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3910
                                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3911
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3912
                                    (filterModules isNil 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3913
                                    or:[filterModules includes:module]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3914
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3915
                                        recordType = 'M' ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3916
                                            recordType := ' '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3917
                                        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3918
                                            recordType = 'A' ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3919
                                                recordType := '+'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3920
                                            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3921
                                                (recordType = 'R' or:[recordType = 'W']) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3922
                                                    recordType := '-'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3923
                                                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3924
                                            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3925
                                        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3926
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3927
                                        info := Dictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3928
                                        info at:#cvsRecordType       put:recordType.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3929
                                        info at:#date                put:date.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3930
                                        info at:#time                put:time.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3931
                                        info at:#user                put:user.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3932
                                        info at:#fileName            put:fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3933
                                        info at:#revision            put:rev.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3934
                                        info at:#directory           put:pkgDir.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3935
                                        info at:#className           put:(Smalltalk classNameForFile:fileName).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3936
                                    
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3937
                                        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3938
                                        "/ for your convenience:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3939
                                        "/  check what the actual version is in the image
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3940
                                        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3941
                                        clsName := Smalltalk classNameForFile:fileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3942
                                        clsName notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3943
                                            cls := Smalltalk classNamed:clsName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3944
                                            (cls notNil and:[(clsRev := cls revision) notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3945
                                                info at:#classesRevision     put:clsRev.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3946
                                            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3947
                                        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3948
                                        aBlock value:info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3949
                                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3950
                                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3951
                            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3952
                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3953
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3954
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3955
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3956
            inStream close.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3957
        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3958
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3959
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3960
    tempDir recursiveRemove.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3961
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3962
    "Created: / 17.1.2001 / 13:11:20 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3963
    "Modified: / 17.1.2001 / 13:41:22 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3964
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3965
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3966
reportHistoryLogSince:timeGoal filterSTSources:filter filterUser:userFilter filterRepository:filterRep inTo:aBlock
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3967
    "process a full historyLog, evaluate aBlock for each entry, passing 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3968
     the logs info in a dictionary.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3969
     This walks over all possible repositories.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3970
     filterRep may be a collection of repository names 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3971
     (i.e. 'stc', 'exept', 'phx' etc.) to only report changes made to one
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3972
     of those repositories.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3973
     filterUser, if non-nil, will filter only changes made by that user."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3974
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3975
    ^self
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3976
        reportHistoryLogSince:timeGoal 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3977
        filterSTSources:filter 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3978
        filterUser:userFilter 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3979
        filterRepository:filterRep 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3980
        filterModules:nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3981
        inTo:aBlock
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3982
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3983
    "Modified: / 17.1.2001 / 13:12:15 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3984
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3985
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3986
revisionInfoFromString:aString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3987
    "{ Pragma: +optSpace }"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3988
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3989
    "return a dictionary filled with revision info.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3990
     This extracts the relevant info from aString."
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3991
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3992
    ^ self revisionInfoFromRCSString:aString
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3993
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3994
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3995
     self revisionInfoFromString:(Array version)   
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3996
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3997
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3998
    "Modified: 29.1.1997 / 19:00:35 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  3999
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4000
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4001
revisionLogOf:clsOrNil fromRevision:rev1 toRevision:rev2 fileName:classFileName directory:packageDir module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4002
    "return info about the repository container and
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4003
     (part of) the revisionlog as a collection of revision entries.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4004
     Return nil on failure.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4005
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4006
     The returned information is a structure (IdentityDictionary)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4007
     filled with:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4008
            #container          -> the RCS/CVS container file name 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4009
            #cvsRoot            -> the CVS root (repository) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4010
            #filename           -> the actual source file name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4011
            #newestRevision     -> the revisionString of the newest revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4012
            #numberOfRevisions  -> the number of revisions in the container (nil for all)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4013
            #revisions          -> collection of per-revision info (see below)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4014
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4015
            rev1 / rev2 specify from which revisions a logEntry is wanted:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4016
             -If rev1 is nil, the first revision is the initial revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4017
              otherwise, the log starts with that revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4018
             -If rev2 is nil, the last revision is the newest revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4019
              otherwise, the log ends with that revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4020
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4021
             -If both are nil, all logEntries are extracted.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4022
             -If both are 0 (not nil), no logEntries are extracted (i.e. only the header).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4023
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4024
            per revision info consists of one record per revision:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4025
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4026
              #revision              -> the revision string
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4027
              #author                -> who checked that revision into the repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4028
              #date                  -> when was it checked in
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4029
              #state                 -> the RCS state
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4030
              #numberOfChangedLines  -> the number of changed line w.r.t the previous
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4031
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4032
            revisions are ordered newest first 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4033
            (i.e. the last entry is for the initial revision; the first for the most recent one)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4034
        "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4035
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4036
    |tempDir fullName modulePath inStream inHeaderInfo atEnd line revArg idx
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4037
     info record revisionRecords s headerOnly msg |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4038
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4039
    modulePath :=  moduleDir , '/' , packageDir. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4040
    fullName :=  modulePath , '/' , classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4041
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4042
    tempDir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4043
        ('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4044
        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4045
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4046
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4047
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4048
        self createEntryFor:fullName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4049
             module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4050
             in:(tempDir construct:modulePath) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4051
             revision:'1.1' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4052
             date:'dummy' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4053
             special:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4054
             overwrite:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4055
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4056
        revArg := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4057
        headerOnly := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4058
        (rev1 notNil or:[rev2 notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4059
            (rev1 == 0 and:[rev2 == 0]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4060
                revArg := '-h'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4061
                headerOnly := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4062
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4063
                revArg := '-r'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4064
                rev1 notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4065
                    revArg := revArg , rev1
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4066
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4067
                revArg := revArg , ':'.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4068
                rev2 notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4069
                    revArg := revArg , rev2
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4070
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4071
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4072
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4073
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4074
        headerOnly ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4075
            msg := 'fetching revision info '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4076
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4077
            msg := 'reading revision log '
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4078
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4079
        clsOrNil isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4080
            msg := msg , 'in ' , fullName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4081
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4082
            msg := msg , 'of ', clsOrNil name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4083
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4084
        self activityNotification:msg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4085
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4086
        inStream := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4087
                        executeCVSCommand:('log ' , revArg , ' ' , fullName) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4088
                        module:moduleDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4089
                        inDirectory:tempDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4090
                        log:true 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4091
                        pipe:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4092
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4093
        inStream isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4094
            ('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4095
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4096
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4097
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4098
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4099
        "/ read the commands pipe output and extract the container info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4100
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4101
        info := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4102
        inHeaderInfo := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4103
        [inHeaderInfo and:[inStream atEnd not]] whileTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4104
            line:= inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4105
            line notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4106
                |gotIt|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4107
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4108
                gotIt := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4109
                #('RCS file:'        #container
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4110
                  'Working file:'    #filename
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4111
                  'head:'            #newestRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4112
                  'total revisions:' #numberOfRevisions
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4113
                 ) pairWiseDo:[:word :key |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4114
                    gotIt ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4115
                        s := line restAfter:word withoutSeparators:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4116
                        s notNil ifTrue:[info at:key put:s. gotIt := true].                        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4117
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4118
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4119
                gotIt ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4120
                    (line startsWith:'description:') ifTrue:[inHeaderInfo := false].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4121
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4122
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4123
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4124
        inStream nextLine. "/ skip separating line after description.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4125
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4126
        info isEmpty ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4127
            ('CVSSourceCodeManager [warning]: no log for ', fullName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4128
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4129
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4130
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4131
        "/ strip selected revisions from the total-revisions entry
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4132
        s := info at:#numberOfRevisions.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4133
        (idx := s indexOf:$;) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4134
            info at:#numberOfRevisions put:(Integer readFrom:(s copyTo:idx - 1))
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4135
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4136
            info at:#numberOfRevisions put:(Integer readFrom:s onError:[1])
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4137
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4138
        headerOnly ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4139
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4140
            "/ continue to read the commands pipe output 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4141
            "/ and extract revision info records
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4142
            "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4143
            revisionRecords := OrderedCollection new:(info at:#numberOfRevisions).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4144
            info at:#revisions put:revisionRecords.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4145
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4146
            atEnd := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4147
            [atEnd or:[inStream atEnd]] whileFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4148
                record := self readRevisionLogEntryFromStream:inStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4149
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4150
"/                revLine1 := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4151
"/                [revLine1 notNil and:[(revLine1 startsWith:'revision ') not]]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4152
"/                    whileTrue:[inStream atEnd ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4153
"/                                revLine1 := nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4154
"/                               ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4155
"/                                revLine1 := inStream nextLine.]].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4156
"/                revLine2 := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4157
"/                (revLine1 notNil and:[revLine2 notNil]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4158
"/                    record := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4159
"/                    record at:#revision put:(revLine1 asCollectionOfWords at:2).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4160
"/                    "/ decompose date/author/state etc.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4161
"/                    (revLine2 asCollectionOfSubstringsSeparatedBy:$;) do:[:info |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4162
"/                        |subEntry|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4163
"/                        subEntry := info withoutSeparators.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4164
"/                        #('date:'   #date
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4165
"/                          'author:' #author 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4166
"/                          'state:'  #state 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4167
"/                          'lines:'  #numberOfChangedLines
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4168
"/                         ) pairWiseDo:[:word :key |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4169
"/                            s := subEntry restAfter:word withoutSeparators:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4170
"/                            s notNil ifTrue:[record at:key put:s.].                        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4171
"/                        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4172
"/                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4173
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4174
"/                    "first revision does not hav a 'lines:' entry"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4175
"/                    (record includesKey:#numberOfChangedLines) ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4176
"/                        record at:#numberOfChangedLines put:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4177
"/                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4178
"/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4179
"/                    s := nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4180
"/                    line := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4181
"/                    [atEnd or:[line isNil or:[line startsWith:'--------']]] whileFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4182
"/                        (line startsWith:'==========') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4183
"/                            atEnd := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4184
"/                        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4185
"/                            (line withoutSpaces = '.') ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4186
"/                                line := '*** empty log message ***'
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4187
"/                            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4188
"/                            s isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4189
"/                                s := line
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4190
"/                            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4191
"/                                s := s , Character cr asString , line.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4192
"/                            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4193
"/                            line := inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4194
"/                        ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4195
"/                    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4196
"/                    record at:#logMessage put:s.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4197
"/                    revisionRecords add:record.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4198
"/                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4199
                record isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4200
                    atEnd := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4201
                ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4202
                    revisionRecords add:record.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4203
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4204
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4205
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4206
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4207
        inStream notNil ifTrue:[inStream close].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4208
        tempDir recursiveRemove
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4209
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4210
    ^ info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4211
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4212
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4213
     SourceCodeManager revisionLogOf:Array 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4214
     SourceCodeManager revisionLogOf:Array fromRevision:'1.40' toRevision:'1.43' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4215
     SourceCodeManager revisionLogOf:Array fromRevision:'1.40' toRevision:nil  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4216
     SourceCodeManager revisionLogOf:Array fromRevision:nil toRevision:'1.3'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4217
     SourceCodeManager revisionLogOf:Array fromRevision:nil toRevision:nil  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4218
     SourceCodeManager revisionLogOf:Array fromRevision:0 toRevision:0  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4219
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4220
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4221
    "Created: / 16.11.1995 / 13:25:30 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4222
    "Modified: / 29.1.1997 / 16:51:30 / stefan"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4223
    "Modified: / 27.8.1998 / 12:40:59 / cg"
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4224
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4225
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4226
revisionLogOf:clsOrNil numberOfRevisions:numRevisions fileName:classFileName directory:packageDir module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4227
    "return info about the repository container and
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4228
     (part of) the revisionlog (numRevisions newest revisions)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4229
     as a collection of revision entries.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4230
     Return nil on failure.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4231
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4232
     The returned information is a structure (IdentityDictionary)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4233
     filled with:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4234
            #container          -> the RCS container file name 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4235
            #filename           -> the actual source file name
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4236
            #newestRevision     -> the revisionString of the newest revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4237
            #numberOfRevisions  -> the number of revisions in the container (nil for all)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4238
            #revisions          -> collection of per-revision info (see below)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4239
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4240
            rev1 / rev2 specify from which revisions a logEntry is wanted:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4241
             -If rev1 is nil, the first revision is the initial revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4242
              otherwise, the log starts with that revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4243
             -If rev2 is nil, the last revision is the newest revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4244
              otherwise, the log ends with that revision.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4245
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4246
             -If both are nil, all logEntries are extracted.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4247
             -If both are 0 (not nil), no logEntries are extracted (i.e. only the header).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4248
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4249
            per revision info consists of one record per revision:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4250
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4251
              #revision              -> the revision string
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4252
              #author                -> who checked that revision into the repository
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4253
              #date                  -> when was it checked in
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4254
              #state                 -> the RCS state
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4255
              #numberOfChangedLines  -> the number of changed line w.r.t the previous
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4256
              #logMessage            -> the checkIn log message
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4257
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4258
            revisions are ordered newest first 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4259
            (i.e. the last entry is for the initial revision; the first for the most recent one)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4260
        "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4261
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4262
    |tempDir fullName modulePath inStream inHeaderInfo atEnd line revArg idx
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4263
     info record revisionRecords s msg|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4264
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4265
    modulePath :=  moduleDir , '/' , packageDir. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4266
    fullName :=  modulePath , '/' , classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4267
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4268
    tempDir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4269
        ('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4270
        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4271
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4272
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4273
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4274
        self createEntryFor:fullName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4275
             module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4276
             in:(tempDir construct:modulePath) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4277
             revision:'1.1' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4278
             date:'dummy' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4279
             special:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4280
             overwrite:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4281
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4282
        revArg := ''.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4283
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4284
        msg := 'reading revision log '.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4285
        clsOrNil isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4286
            msg := msg , 'in ' , fullName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4287
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4288
            msg := msg , 'of ', clsOrNil name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4289
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4290
        self activityNotification:msg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4291
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4292
        inStream := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4293
                        executeCVSCommand:('log ' , revArg , ' ' , fullName) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4294
                        module:moduleDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4295
                        inDirectory:tempDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4296
                        log:true 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4297
                        pipe:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4298
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4299
        inStream isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4300
            ('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4301
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4302
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4303
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4304
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4305
        "/ read the commands pipe output and extract the container info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4306
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4307
        info := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4308
        inHeaderInfo := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4309
        [inHeaderInfo and:[inStream atEnd not]] whileTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4310
            line:= inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4311
            line notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4312
                |gotIt|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4313
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4314
                gotIt := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4315
                #('RCS file:'        #container
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4316
                  'Working file:'    #filename
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4317
                  'head:'            #newestRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4318
                  'total revisions:' #numberOfRevisions
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4319
                 ) pairWiseDo:[:word :key |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4320
                    gotIt ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4321
                        s := line restAfter:word withoutSeparators:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4322
                        s notNil ifTrue:[info at:key put:s. gotIt := true].                        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4323
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4324
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4325
                gotIt ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4326
                    (line startsWith:'description:') ifTrue:[inHeaderInfo := false].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4327
                ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4328
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4329
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4330
        inStream nextLine. "/ skip separating line after description.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4331
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4332
        info isEmpty ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4333
            ('CVSSourceCodeManager [warning]: no log for ', fullName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4334
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4335
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4336
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4337
        "/ strip selected revisions from the total-revisions entry
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4338
        s := info at:#numberOfRevisions.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4339
        (idx := s indexOf:$;) ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4340
            info at:#numberOfRevisions put:(Integer readFrom:(s copyTo:idx - 1))
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4341
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4342
            info at:#numberOfRevisions put:(Integer readFrom:s onError:[1])
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4343
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4344
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4345
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4346
        "/ continue to read the commands pipe output 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4347
        "/ and extract revision-info records
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4348
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4349
        revisionRecords := OrderedCollection new:(info at:#numberOfRevisions).
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4350
        info at:#revisions put:revisionRecords.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4351
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4352
        atEnd := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4353
        [atEnd or:[inStream atEnd]] whileFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4354
            record := self readRevisionLogEntryFromStream:inStream.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4355
            record isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4356
                atEnd := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4357
            ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4358
                revisionRecords add:record.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4359
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4360
            (numRevisions notNil and:[revisionRecords size >= numRevisions]) ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4361
                atEnd := true
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4362
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4363
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4364
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4365
        inStream notNil ifTrue:[inStream shutDown "close"].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4366
        tempDir recursiveRemove
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4367
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4368
    ^ info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4369
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4370
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4371
     SourceCodeManager revisionLogOf:Array 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4372
     SourceCodeManager revisionLogOf:Array numberOfRevisions:5
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4373
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4374
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4375
!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4376
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4377
statusOf:clsOrNil fileName:classFileName directory:packageDir module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4378
    "return info about the status repository container.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4379
     Return nil on failure.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4380
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4381
     The returned information is a structure (IdentityDictionary)
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4382
     filled with:
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4383
            #newestRevision     -> the revisionString of the newest revision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4384
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4385
     This is much faster than revisionLog info (especially, if there are many revisions),
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4386
     and all we need is a classes newest version number.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4387
        "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4388
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4389
    |tempDir fullName modulePath inStream line   
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4390
     info s msg|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4391
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4392
    modulePath :=  moduleDir , '/' , packageDir. 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4393
    fullName :=  modulePath , '/' , classFileName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4394
    tempDir := self createTempDirectory:nil forModule:nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4395
    tempDir isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4396
        ('CVSSourceCodeManager [error]: no tempDir - cannot extract log') errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4397
        ^ nil.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4398
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4399
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4400
    [
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4401
        self createEntryFor:fullName 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4402
             module:moduleDir
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4403
             in:(tempDir construct:modulePath) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4404
             revision:'1.1' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4405
             date:'dummy' 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4406
             special:''
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4407
             overwrite:false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4408
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4409
        msg := 'fetching status info of '.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4410
        clsOrNil isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4411
            msg := msg , fullName.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4412
        ] ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4413
            msg := msg , clsOrNil name.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4414
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4415
        self activityNotification:msg.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4416
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4417
        inStream := self 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4418
                        executeCVSCommand:('status ' , fullName) 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4419
                        module:moduleDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4420
                        inDirectory:tempDir 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4421
                        log:true 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4422
                        pipe:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4423
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4424
        inStream isNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4425
            ('CVSSourceCodeManager [error]: cannot open pipe to cvs log ', fullName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4426
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4427
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4428
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4429
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4430
        "/ read the commands pipe output and extract the container info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4431
        "/
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4432
        info := IdentityDictionary new.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4433
        [inStream atEnd] whileFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4434
            line:= inStream nextLine.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4435
            line notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4436
                line := line withoutSeparators.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4437
            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4438
            line size > 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4439
                |gotIt i|
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4440
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4441
                gotIt := false.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4442
                #(
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4443
                  'Repository revision:'  #newestRevision
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4444
                 ) pairWiseDo:[:word :key |
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4445
                    gotIt ifFalse:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4446
                        s := line restAfter:word withoutSeparators:true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4447
                        s notNil ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4448
                            i := s indexOfSeparator.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4449
                            i ~~ 0 ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4450
                                s := s copyTo:i-1
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4451
                            ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4452
                            info at:key put:s.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4453
                            gotIt := true.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4454
                        ].                        
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4455
                    ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4456
                ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4457
            ]
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4458
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4459
        info isEmpty ifTrue:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4460
            ('CVSSourceCodeManager [warning]: no status for ', fullName) errorPrintCR.
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4461
            ^ nil
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4462
        ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4463
    ] ensure:[
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4464
        inStream notNil ifTrue:[inStream close].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4465
        tempDir recursiveRemove
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4466
    ].
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4467
    ^ info
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4468
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4469
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4470
     SourceCodeManager statusOf:Array 
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4471
     SourceCodeManager statusOf:Array fileName:'Array.st' directory:'libbasic' module:'stx'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4472
     SourceCodeManager statusOf:Filename fileName:'Filename.st' directory:'libbasic' module:'stx'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4473
     SourceCodeManager statusOf:NewSystemBrowser fileName:'NewSystemBrowser.st' directory:'libtool' module:'stx'  
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4474
    "
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4475
! !
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4476
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4477
!CVSSourceCodeManager class methodsFor:'documentation'!
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4478
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4479
version
1407
f8314a9474cf tempDir handling
penk
parents: 1406
diff changeset
  4480
    ^ '$Header: /cvs/stx/stx/libbasic3/CVSSourceCodeManager.st,v 1.289 2004-12-15 10:32:43 penk Exp $'
1362
Claus Gittinger <cg@exept.de>
parents: 1361
diff changeset
  4481
! !
1170
Claus Gittinger <cg@exept.de>
parents: 1159
diff changeset
  4482
130
4abc831b165f oops - invalid ccheckin
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
  4483
CVSSourceCodeManager initialize!