author | Claus Gittinger <cg@exept.de> |
Mon, 20 Nov 1995 14:19:50 +0100 | |
changeset 77 | 4cc959f6b639 |
parent 76 | df46581e46be |
child 78 | 5c81ea9f4c28 |
permissions | -rw-r--r-- |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
1 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
3 |
All Rights Reserved |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
4 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
5 |
This software is furnished under a license and may be used |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
10 |
hereby transferred. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
11 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
12 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
13 |
AbstractSourceCodeManager subclass:#CVSSourceCodeManager |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
14 |
instanceVariableNames:'' |
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
15 |
classVariableNames:'Verbose CVSRoot' |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
16 |
poolDictionaries:'' |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
17 |
category:'System-Support' |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
18 |
! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
19 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
20 |
!CVSSourceCodeManager class methodsFor:'documentation'! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
21 |
|
73 | 22 |
copyright |
23 |
" |
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
|
25 |
All Rights Reserved |
|
26 |
||
27 |
This software is furnished under a license and may be used |
|
28 |
only in accordance with the terms of that license and with the |
|
29 |
inclusion of the above copyright notice. This software may not |
|
30 |
be provided or otherwise made available to, or used by, any |
|
31 |
other person. No title to or ownership of the software is |
|
32 |
hereby transferred. |
|
33 |
" |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
34 |
! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
35 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
36 |
documentation |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
37 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
38 |
SourceCodeManager which accesses sourcecode through cvs. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
39 |
It requires the shell environment variable CVSROOT to be set |
57 | 40 |
to the top of the repository tree. Under that top, for each module |
41 |
(especially the stx module itself), a subdirectory containing that modules |
|
42 |
directories must exist. |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
43 |
|
57 | 44 |
If not specified otherwise, the module defaults to 'stx'. |
45 |
If a class has its home in another module, it has to be compiled |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
46 |
with a corresponding entry in the package string (see below). |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
47 |
Within a module, classes are organized in classlibraries, and the corresponding |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
48 |
source code is found in various subdirectories of CVSROOT. The directories |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
49 |
name can also be provided by the package string - if not, it defaults to the |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
50 |
libraries name. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
51 |
The package string controls all this, and is REQUIRED in order for the sourceCodeManager |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
52 |
to be able to retrieve a classes source. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
53 |
The package strings format is: |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
54 |
'...any infotext....(sourceCodeInfo)' |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
55 |
the sourceCOdeInfo consists of multiple entries, separated by colons. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
56 |
The following formats are allowed: |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
57 |
(libraryName) - module defaults to 'stx'; directory to the name of the library |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
58 |
(foo/bar/x) - module defaults to 'stx'; dir is 'foo/bar/x'; library name defaults to x |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
59 |
(module:directory:libname) - specifies all components |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
60 |
The first formats are intermediate, for backward compatibility. We urge everyone |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
61 |
to use the last format (by changing the Make.proto files and add a -P flag to |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
62 |
the stc compiler flags (see libbasic/Make.proto as an example). |
57 | 63 |
|
64 |
Notice, that the sourceCodeManager is (currently) only consulted, if no |
|
65 |
source subdirectory exists, or no source file is found there. If it does exist, |
|
66 |
that one is supposed to contain an up-to-date version of the classes source |
|
67 |
(this is temporary - in the future the probe order will be reversed, trying |
|
68 |
the source repository first). |
|
69 |
The source directory is required for systems which do NO source code control. |
|
70 |
||
71 |
Setup: |
|
72 |
- make certain, that the commands 'cvs' and 'co' are available on your system. |
|
73 |
- add setup for the CVSROOT environment variable to your .bashrc / .login / .profile |
|
74 |
- Make certain that either no local source directory exists, or it is empty or it contains |
|
75 |
only source code for files NOT found in the repository (this will not be required in future versions). |
|
76 |
||
77 |
Caveat: |
|
78 |
currently, the rcs container is accessed directly, since cvs mangles the files ident-string and |
|
79 |
thus does not correctly recreate the original file (all source is offset by some characters w.r.t. the |
|
80 |
compiled file). |
|
81 |
Therefore, sevrer-mode CVS is not supported. |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
82 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
83 |
! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
84 |
|
73 | 85 |
version |
77 | 86 |
^ '$Header: /cvs/stx/stx/libbasic3/Attic/CVSSCMgr.st,v 1.16 1995-11-20 13:19:50 cg Exp $'! ! |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
87 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
88 |
!CVSSourceCodeManager class methodsFor:'initialization'! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
89 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
90 |
initialize |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
91 |
"/ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
92 |
"/ if CVSROOT is non-empty and both cvs and co are available |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
93 |
"/ as commands, assume this system uses a cvs source code management. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
94 |
"/ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
95 |
(CVSRoot := OperatingSystem getEnvironment:'CVSROOT') notNil ifTrue:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
96 |
(OperatingSystem canExecuteCommand:'cvs') ifTrue:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
97 |
(OperatingSystem canExecuteCommand:'co') ifTrue:[ |
63 | 98 |
self initCacheDirPath. |
99 |
Smalltalk at:#SourceCodeManager put:self. |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
100 |
'CVS SourceCodeManager installed.' infoPrintNL. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
101 |
] |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
102 |
] |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
103 |
] |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
104 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
105 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
106 |
CVSSourceCodeManager initialize |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
107 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
108 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
109 |
"Created: 4.11.1995 / 19:14:38 / cg" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
110 |
! ! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
111 |
|
73 | 112 |
!CVSSourceCodeManager class methodsFor:'source code access'! |
113 |
||
114 |
checkinClass:cls fileName:classFileName directory:packageDir module:moduleDir source:sourceFileName logMessage:logMessage |
|
115 |
"enter a classes source code (which has been already filed out into sourceFileName) |
|
116 |
into the source repository. |
|
117 |
Return true if ok, false if not." |
|
118 |
||
77 | 119 |
|tempdir dir cmd checkoutName logMsg revision merge cmdOut whatHappened s| |
76 | 120 |
|
121 |
merge := false. "/ for now .... |
|
77 | 122 |
merge := true. "/ for now .... |
76 | 123 |
|
124 |
merge ifTrue:[ |
|
125 |
revision := cls revision. |
|
126 |
revision isNil ifTrue:[ |
|
127 |
'CVSMGR: class ' , cls name , ' has no revision string' infoPrintNL. |
|
128 |
^ nil. |
|
129 |
]. |
|
130 |
]. |
|
73 | 131 |
|
74 | 132 |
logMsg := logMessage. |
133 |
(logMsg isNil or:[logMsg isEmpty]) ifTrue:[ |
|
76 | 134 |
logMsg := 'checkin from browser'. |
73 | 135 |
]. |
136 |
||
77 | 137 |
cmdOut := Filename newTemporary. |
138 |
cmdOut exists ifTrue:[ |
|
139 |
cmdOut remove. |
|
140 |
]. |
|
141 |
||
73 | 142 |
"/ |
143 |
"/ in CVS, we have to checkout the file first, in order |
|
144 |
"/ to get up-to-date CVS entries, and also to be able to merge in |
|
145 |
"/ other users changes. |
|
146 |
"/ |
|
147 |
||
148 |
"/ |
|
149 |
"/ first, create a temporary work tree |
|
150 |
"/ |
|
151 |
tempdir := Filename newTemporaryIn:nil. |
|
152 |
tempdir exists ifTrue:[ |
|
76 | 153 |
tempdir recursiveRemove. |
73 | 154 |
]. |
155 |
tempdir makeDirectory. |
|
156 |
dir := tempdir construct:moduleDir. |
|
157 |
dir makeDirectory. |
|
158 |
dir := dir construct:packageDir. |
|
159 |
dir makeDirectory. |
|
160 |
||
161 |
"/ |
|
162 |
"/ check it out there |
|
163 |
"/ |
|
164 |
checkoutName := moduleDir , '/' , packageDir , '/' , classFileName , '.st'. |
|
70 | 165 |
|
76 | 166 |
merge ifTrue:[ |
77 | 167 |
cmd := 'cd ' , tempdir name , ';cvs checkout -r ' , revision , ' ', checkoutName. |
76 | 168 |
] ifFalse:[ |
169 |
cmd := 'cd ' , tempdir name , ';cvs checkout ' , checkoutName. |
|
170 |
]. |
|
77 | 171 |
('checkout: ' , cmd) printNL. |
76 | 172 |
|
73 | 173 |
(OperatingSystem executeCommand:cmd) ifFalse:[ |
174 |
'failed: ' errorPrint. cmd errorPrintNL. |
|
76 | 175 |
tempdir recursiveRemove. |
176 |
('CVSMGR: cannot checkout ' , checkoutName) errorPrintNL. |
|
177 |
^ false. |
|
73 | 178 |
]. |
179 |
||
180 |
"/ |
|
181 |
"/ copy-over our current version |
|
182 |
"/ |
|
183 |
cmd := 'mv ' , sourceFileName , ' ' , tempdir name , '/' , checkoutName. |
|
184 |
(OperatingSystem executeCommand:cmd) ifFalse:[ |
|
185 |
'failed: ' errorPrint. cmd errorPrintNL. |
|
76 | 186 |
'CVSMGR: cannot copy-over filedOut class source' errorPrintNL. |
187 |
^ false. |
|
73 | 188 |
]. |
70 | 189 |
|
77 | 190 |
merge ifTrue:[ |
191 |
"/ |
|
192 |
"/ synchronize i.e. merge in any changes |
|
193 |
"/ |
|
194 |
cmd := 'cd ' , tempdir name , ';cvs update ' , checkoutName , ' > ' , cmdOut name. |
|
195 |
('update: ' , cmd) printNL. |
|
196 |
(OperatingSystem executeCommand:cmd) ifFalse:[ |
|
197 |
'failed: ' errorPrint. cmd errorPrintNL. |
|
198 |
'CVSMGR: cannot copy-over filedOut class source' errorPrintNL. |
|
199 |
^ false. |
|
200 |
]. |
|
201 |
||
202 |
"/ |
|
203 |
"/ check what happened - the contents of the cmdOut file may be: |
|
204 |
"/ empty -> nothing changed |
|
205 |
"/ M xxx -> merged-in changes from other users |
|
206 |
"/ C xxx -> a conflict occured and the differences have been merged into the source |
|
207 |
"/ needs special action |
|
208 |
whatHappened := cmdOut contentsOfEntireFile asString. |
|
209 |
(whatHappened isNil or:[whatHappened isEmpty]) ifTrue:[ |
|
210 |
"/ |
|
211 |
"/ no change |
|
212 |
"/ |
|
213 |
self information:'nothing changed' |
|
214 |
] ifFalse:[ |
|
215 |
(whatHappened startsWith:'M ') ifTrue:[ |
|
216 |
"/ |
|
217 |
"/ merged in changes |
|
218 |
"/ |
|
219 |
s := WriteStream on:String new. |
|
220 |
self writeRevisionLogOf:Array fromRevision:(self revisionAfter:revision) toRevision:nil to:s. |
|
221 |
||
222 |
self information:'The source has been changed in the meanwhile as follows: |
|
223 |
' , (s contents) , ' |
|
224 |
I have merged your new changes (based upon rev. ' , revision , ') into the newest revision. |
|
225 |
||
226 |
You should update your class from the repository.' |
|
227 |
] ifFalse:[ |
|
228 |
(whatHappened startsWith:'C ') ifTrue:[ |
|
229 |
"/ |
|
230 |
"/ conflict |
|
231 |
"/ |
|
232 |
s := WriteStream on:String new. |
|
233 |
self writeRevisionLogOf:Array fromRevision:(self revisionAfter:revision) toRevision:nil to:s. |
|
234 |
||
235 |
self information:'The source has been changed in the meanwhile as follows: |
|
236 |
' , (s contents) , ' |
|
237 |
Your new changes (based upon rev. ' , revision , ') CONFLICT with those changes - please fix.' |
|
238 |
'CVSMGR: cannot (for now) checkin; conflicts found' errorPrintNL. |
|
239 |
^ false. |
|
240 |
] ifFalse:[ |
|
241 |
"/ |
|
242 |
"/ unexpected |
|
243 |
"/ |
|
244 |
self information:'unexpected message from CVS: |
|
245 |
' , whatHappened |
|
246 |
] |
|
247 |
] |
|
248 |
]. |
|
249 |
]. |
|
76 | 250 |
|
73 | 251 |
"/ |
252 |
"/ now check it in again |
|
253 |
"/ |
|
74 | 254 |
cmd := 'cd ' , tempdir name , ';cvs commit -m "', logMsg ,'" ' . |
73 | 255 |
(OperatingSystem executeCommand:cmd) ifFalse:[ |
256 |
'failed: ' errorPrint. cmd errorPrintNL. |
|
76 | 257 |
'CVSMGR: cannot checkin modified class source' errorPrintNL. |
258 |
^ false. |
|
73 | 259 |
]. |
70 | 260 |
|
73 | 261 |
tempdir recursiveRemove. |
262 |
^ true |
|
263 |
||
264 |
" |
|
77 | 265 |
SourceCodeManager checkinClass:Array logMessage:'testing only' |
73 | 266 |
" |
267 |
||
268 |
"Created: 6.11.1995 / 18:57:05 / cg" |
|
77 | 269 |
"Modified: 20.11.1995 / 12:58:46 / cg" |
73 | 270 |
! |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
271 |
|
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
272 |
streamForClass:cls fileName:classFileName revision:revision directory:packageDir module:moduleDir cache:cacheIt |
58 | 273 |
"extract a source file and return an open readStream on it." |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
274 |
|
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
275 |
|dir cachedSourceFilename temporaryFile file cmd fullName revisionArg stream| |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
276 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
277 |
CVSRoot isNil ifTrue:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
278 |
'CVSMGR: CVSROOT not set' infoPrintNL. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
279 |
^ nil |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
280 |
]. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
281 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
282 |
"/ if not already existing, create a temp directory |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
283 |
"/ where we deposit sources. |
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
284 |
"/ this is used as a cache for further requests, since |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
285 |
"/ accessing the repository may be slow. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
286 |
"/ (if cvs uses a remote connection via ppp, for example) |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
287 |
"/ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
288 |
|
58 | 289 |
(dir := self sourceCacheDirectory) isNil ifTrue:[ |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
290 |
^ nil |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
291 |
]. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
292 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
293 |
fullName := moduleDir , '/' , packageDir , '/' , classFileName , '.st'. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
294 |
|
62 | 295 |
(revision isNil or:[revision == #newest]) ifTrue:[ |
296 |
cachedSourceFilename := classFileName. |
|
297 |
] ifFalse:[ |
|
298 |
cachedSourceFilename := classFileName , '_' , revision. |
|
299 |
]. |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
300 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
301 |
file := (dir construct:cachedSourceFilename) asFilename. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
302 |
file exists ifTrue:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
303 |
"/ ('CVSMGR: found existing: ', file name) infoPrintNL. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
304 |
] ifFalse:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
305 |
"/ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
306 |
"/ ok, ask cvs to extract the corresponding source code |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
307 |
"/ into the cache directory ... |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
308 |
"/ |
58 | 309 |
"/ claus: cannot use 'cvs' (it mangles the header's filename string |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
310 |
"/ by expanding symbolic links). This may make the extracted files |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
311 |
"/ contents different from the compiled one and thus invalidates the |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
312 |
"/ methods source-offsets. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
313 |
"/ By directly calling 'co', this trouble goes away. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
314 |
"/ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
315 |
temporaryFile := (Filename newTemporaryIn:nil) name. |
61 | 316 |
(revision isNil or:[revision == #newest]) ifTrue:[ |
317 |
revisionArg := '' |
|
318 |
] ifFalse:[ |
|
319 |
revisionArg := '-r' , revision |
|
320 |
]. |
|
321 |
cmd := '(cd ' , CacheDirectoryName , '; co -q ' , revisionArg , ' -p ' , CVSRoot , '/' , fullName , ' > ' , temporaryFile , ')'. |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
322 |
Verbose == true ifTrue:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
323 |
('CVSMGR: executing: ' , cmd ) infoPrintNL. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
324 |
]. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
325 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
326 |
(OperatingSystem executeCommand:cmd) ifFalse:[ |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
327 |
'CVSMGR: checkout failed' infoPrintNL. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
328 |
^ nil |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
329 |
]. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
330 |
|
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
331 |
cacheIt ifTrue:[ |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
332 |
(OperatingSystem renameFile:(CacheDirectoryName , '/' , temporaryFile) |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
333 |
to:(CacheDirectoryName , '/' , cachedSourceFilename)) ifFalse:[ |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
334 |
('CVSMGR: failed to rename ', temporaryFile, ' to ', cachedSourceFilename) infoPrintNL. |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
335 |
^ nil |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
336 |
] |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
337 |
] ifFalse:[ |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
338 |
stream := (CacheDirectoryName , '/' , temporaryFile) asFilename readStream. |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
339 |
OperatingSystem removeFile:(CacheDirectoryName , '/' , temporaryFile). |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
340 |
^ stream |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
341 |
] |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
342 |
]. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
343 |
^ file readStream |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
344 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
345 |
"Created: 4.11.1995 / 19:46:20 / cg" |
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
63
diff
changeset
|
346 |
"Modified: 9.11.1995 / 14:32:55 / cg" |
73 | 347 |
! ! |
348 |
||
349 |
!CVSSourceCodeManager class methodsFor:'source code administration'! |
|
350 |
||
77 | 351 |
writeRevisionLogOf:cls fromRevision:rev1 toRevision:rev2 fileName:classFileName directory:packageDir module:moduleDir to:aStream |
352 |
"send (part of) the revisionlog to aStream" |
|
73 | 353 |
|
77 | 354 |
|file cmd fullName inStream skip atEnd line revArg revLine1 revLine2 idx| |
63 | 355 |
|
73 | 356 |
CVSRoot isNil ifTrue:[ |
76 | 357 |
'CVSMGR: CVSROOT not set' infoPrintNL. |
358 |
^ nil |
|
73 | 359 |
]. |
69 | 360 |
|
73 | 361 |
fullName := CVSRoot , '/' , moduleDir , '/' , packageDir , '/' , classFileName , '.st,v'. |
362 |
file := fullName asFilename. |
|
363 |
file exists ifFalse:[ |
|
76 | 364 |
('CVSMGR: non existing repository file: ', file name) infoPrintNL. |
365 |
^ false |
|
73 | 366 |
]. |
69 | 367 |
|
77 | 368 |
revArg := ''. |
369 |
(rev1 notNil or:[rev2 notNil]) ifTrue:[ |
|
370 |
revArg := '-r'. |
|
371 |
rev1 notNil ifTrue:[ |
|
372 |
revArg := revArg , rev1 |
|
373 |
]. |
|
374 |
revArg := revArg , ':'. |
|
375 |
rev2 notNil ifTrue:[ |
|
376 |
revArg := revArg , rev2 |
|
377 |
] |
|
378 |
]. |
|
379 |
||
380 |
inStream := PipeStream readingFrom:('rlog ' , revArg , ' ' , file name). |
|
73 | 381 |
inStream isNil ifTrue:[ |
76 | 382 |
('CVSMGR: cannot open pipe to rlog ', file name) infoPrintNL. |
383 |
^ false |
|
72 | 384 |
]. |
69 | 385 |
|
73 | 386 |
skip := true. |
387 |
[skip and:[inStream atEnd not]] whileTrue:[ |
|
76 | 388 |
line:= inStream nextLine. |
77 | 389 |
line notNil ifTrue:[ |
390 |
(line startsWith:'description:') ifTrue:[skip := false]. |
|
391 |
] |
|
69 | 392 |
]. |
73 | 393 |
inStream nextLine. "/ skip separating line. |
394 |
atEnd := false. |
|
395 |
[atEnd or:[inStream atEnd]] whileFalse:[ |
|
69 | 396 |
|
76 | 397 |
revLine1 := inStream nextLine. |
398 |
revLine2 := inStream nextLine. |
|
399 |
(idx := revLine2 indexOfSubCollection:'state:') ~~ 0 ifTrue:[ |
|
400 |
revLine2 := revLine2 copyTo:idx - 1 |
|
401 |
]. |
|
402 |
aStream cr. |
|
403 |
aStream nextPutAll:revLine1; nextPutAll:' '. |
|
404 |
aStream nextPutAll:revLine2; cr. |
|
69 | 405 |
|
76 | 406 |
line := inStream nextLine. |
407 |
[atEnd or:[line startsWith:'--------']] whileFalse:[ |
|
408 |
(line startsWith:'==========') ifTrue:[ |
|
409 |
atEnd := true. |
|
410 |
] ifFalse:[ |
|
411 |
(line withoutSpaces = '.') ifTrue:[ |
|
412 |
line := '*** empty log message ***' |
|
413 |
]. |
|
414 |
aStream nextPutAll:' '; nextPutAll:line; cr. |
|
415 |
line := inStream nextLine. |
|
416 |
] |
|
417 |
] |
|
69 | 418 |
]. |
73 | 419 |
inStream close. |
69 | 420 |
^ true |
63 | 421 |
|
77 | 422 |
" |
423 |
SourceCodeManager writeRevisionLogOf:Array to:Transcript |
|
424 |
SourceCodeManager writeRevisionLogOf:Array fromRevision:'1.40' toRevision:'1.43' to:Transcript |
|
425 |
SourceCodeManager writeRevisionLogOf:Array fromRevision:'1.40' toRevision:nil to:Transcript |
|
426 |
SourceCodeManager writeRevisionLogOf:Array fromRevision:nil toRevision:'1.3' to:Transcript |
|
427 |
" |
|
428 |
||
73 | 429 |
"Created: 16.11.1995 / 13:25:30 / cg" |
77 | 430 |
"Modified: 20.11.1995 / 13:42:41 / cg" |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
431 |
! ! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
432 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
433 |
CVSSourceCodeManager initialize! |