author | Claus Gittinger <cg@exept.de> |
Wed, 22 Nov 1995 21:59:18 +0100 | |
changeset 83 | 250202dc956e |
parent 77 | 4cc959f6b639 |
child 87 | e0f5b58481a6 |
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 |
Object subclass:#AbstractSourceCodeManager |
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:'CacheDirectoryName' |
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 |
!AbstractSourceCodeManager class methodsFor:'documentation'! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
21 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
22 |
copyright |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
23 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
25 |
All Rights Reserved |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
26 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
27 |
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
|
28 |
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
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
hereby transferred. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
33 |
" |
71 | 34 |
! |
35 |
||
36 |
documentation |
|
37 |
" |
|
38 |
Abstract superclass for sourceCodeManagers. |
|
39 |
Concrete subclasses provide access to a source repository. |
|
40 |
All protocol here traps into subclassResponsbility errors. |
|
41 |
Please read more documentation in concrete subclasses |
|
42 |
(especially: CVSSourceCodeManager) for how to use this manager. |
|
43 |
" |
|
44 |
! |
|
45 |
||
46 |
version |
|
83
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
47 |
^ '$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.20 1995-11-22 20:59:18 cg Exp $'! ! |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
48 |
|
63 | 49 |
!AbstractSourceCodeManager class methodsFor:'initialization'! |
50 |
||
51 |
initCacheDirPath |
|
52 |
|path| |
|
53 |
||
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
54 |
path := OperatingSystem getEnvironment:'STX_TMPPATH'. |
63 | 55 |
path isNil ifTrue:[ |
56 |
path := OperatingSystem getEnvironment:'TMPPATH'. |
|
57 |
path isNil ifTrue:[ |
|
58 |
path := '/tmp' |
|
59 |
] |
|
60 |
]. |
|
64 | 61 |
CacheDirectoryName := path , '/stx_sourceCache'. |
63 | 62 |
! ! |
63 |
||
71 | 64 |
!AbstractSourceCodeManager class methodsFor:'private'! |
65 |
||
66 |
cacheDirectoryName |
|
67 |
^ CacheDirectoryName |
|
68 |
! |
|
69 |
||
70 |
sourceCacheDirectory |
|
71 |
|dir nm| |
|
72 |
||
73 |
(nm := self cacheDirectoryName) isNil ifTrue:[^ nil]. |
|
69 | 74 |
|
71 | 75 |
(dir := nm asFilename) exists ifFalse:[ |
76 |
dir makeDirectory. |
|
77 |
dir asFilename exists ifFalse:[ |
|
78 |
'SOURCEMGR: could not create cache dir ''' , CacheDirectoryName , '''' infoPrintNL. |
|
79 |
^ nil |
|
80 |
]. |
|
81 |
]. |
|
82 |
^ dir |
|
83 |
! |
|
69 | 84 |
|
71 | 85 |
streamForClass:cls fileName:classFileName revision:revision directory:packageDir module:moduleDir cache:cacheIt |
86 |
self subclassResponsibility. |
|
87 |
^ nil |
|
88 |
||
89 |
"Created: 4.11.1995 / 19:09:12 / cg" |
|
90 |
"Modified: 4.11.1995 / 19:15:43 / cg" |
|
77 | 91 |
! |
92 |
||
93 |
revisionAfter:aRevisionString |
|
94 |
|idx s| |
|
95 |
||
96 |
idx := aRevisionString lastIndexOf:$.. |
|
97 |
idx == 0 ifTrue:[ |
|
98 |
^ ((Integer readFrom:aRevisionString) + 1) printString |
|
99 |
]. |
|
100 |
||
101 |
^ (aRevisionString copyTo:idx) , ((Integer readFrom:(aRevisionString copyFrom:(idx+1)))+1) printString |
|
102 |
||
103 |
" |
|
104 |
SourceCodeManager revisionAfter:'1.2.3.4' |
|
105 |
SourceCodeManager revisionAfter:'123' |
|
106 |
SourceCodeManager revisionAfter:'1.24' |
|
107 |
" |
|
108 |
||
109 |
"Created: 20.11.1995 / 12:54:05 / cg" |
|
69 | 110 |
! ! |
111 |
||
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
112 |
!AbstractSourceCodeManager class methodsFor:'source code access'! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
113 |
|
72 | 114 |
checkinClass:aClass logMessage:logMessage |
71 | 115 |
"checkin of a class into the source repository. |
116 |
Return true if ok, false if not." |
|
117 |
||
118 |
|cls sourceInfo tempDir packageDir moduleDir tempFile classFileName ok| |
|
119 |
||
120 |
cls := aClass. |
|
121 |
cls isMeta ifTrue:[ |
|
72 | 122 |
cls := cls soleInstance |
71 | 123 |
]. |
124 |
||
125 |
sourceInfo := cls sourceCodeInfo. |
|
126 |
sourceInfo isNil ifTrue:[ |
|
72 | 127 |
'SOURCEMGR: cannot extract classes sourceInfo' infoPrintNL. |
128 |
^ false |
|
71 | 129 |
]. |
130 |
||
131 |
packageDir := sourceInfo at:#directory. |
|
132 |
moduleDir := sourceInfo at:#module. "/ use the modules name as CVS module |
|
133 |
classFileName := Smalltalk fileNameForClass:cls. |
|
134 |
||
135 |
tempDir := (Filename newTemporaryIn:nil) makeDirectory. |
|
136 |
[ |
|
72 | 137 |
|aStream| |
71 | 138 |
|
72 | 139 |
tempFile := tempDir construct:(classFileName,'.st'). |
140 |
aStream := tempFile writeStream. |
|
141 |
aStream isNil ifTrue:[ |
|
142 |
'SOURCEMGR: temporary fileout failed' infoPrintNL. |
|
143 |
^ false |
|
144 |
]. |
|
75 | 145 |
|
72 | 146 |
aClass fileOutOn:aStream withTimeStamp:false. |
147 |
aStream close. |
|
71 | 148 |
|
72 | 149 |
(tempFile := tempDir construct:(classFileName,'.st')) exists ifFalse:[ |
150 |
'SOURCEMGR: temporary fileout failed' infoPrintNL. |
|
151 |
^ false |
|
152 |
]. |
|
71 | 153 |
|
75 | 154 |
ok := self |
72 | 155 |
checkinClass:cls |
156 |
fileName:classFileName |
|
157 |
directory:packageDir |
|
158 |
module:moduleDir |
|
159 |
source:(tempFile name) |
|
75 | 160 |
logMessage:logMessage. |
161 |
||
162 |
ok ifTrue:[ |
|
163 |
Class addChangeRecordForClassCheckIn:cls. |
|
164 |
]. |
|
165 |
^ ok |
|
71 | 166 |
] valueNowOrOnUnwindDo:[ |
72 | 167 |
tempDir recursiveRemove |
71 | 168 |
]. |
169 |
^ false |
|
170 |
||
171 |
" |
|
172 |
SourceCodeManager checkinClass:Array |
|
173 |
" |
|
174 |
||
175 |
"Created: 6.11.1995 / 18:56:00 / cg" |
|
75 | 176 |
"Modified: 18.11.1995 / 17:06:05 / cg" |
71 | 177 |
! |
178 |
||
179 |
mostRecentSourceStreamForClassNamed:aClassOrClassName |
|
180 |
|classFileName packageDir moduleDir| |
|
181 |
||
182 |
classFileName := Smalltalk fileNameForClass:aClassOrClassName. |
|
183 |
packageDir := Smalltalk sourceDirectoryNameOfClass:aClassOrClassName. |
|
184 |
moduleDir := 'stx'. |
|
185 |
packageDir isNil ifTrue:[^ nil]. |
|
186 |
||
187 |
^ self |
|
188 |
streamForClass:nil |
|
189 |
fileName:classFileName |
|
190 |
revision:#newest |
|
191 |
directory:packageDir |
|
192 |
module:moduleDir |
|
193 |
cache:false |
|
194 |
||
195 |
"Created: 6.11.1995 / 16:09:06 / cg" |
|
196 |
"Modified: 9.11.1995 / 14:34:15 / cg" |
|
197 |
! |
|
198 |
||
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
199 |
sourceStreamFor:aClass |
58 | 200 |
"extract a classes source code and return an open readStream on it. |
201 |
The classes source code is extracted using the revision and the sourceCodeInfo, |
|
202 |
which itself is extracted from the classes packageString." |
|
203 |
||
83
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
204 |
^ self sourceStreamFor:aClass revision:nil |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
205 |
! |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
206 |
|
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
207 |
sourceStreamFor:aClass revision:aRevisionStringOrNil |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
208 |
"extract a classes source code and return an open readStream on it. |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
209 |
A revision of nil selects the current (in image) revision. |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
210 |
The classes source code is extracted using the revision and the sourceCodeInfo, |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
211 |
which itself is extracted from the classes packageString." |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
212 |
|
58 | 213 |
|classFileName revision packageDir moduleDir sourceInfo cls| |
214 |
||
215 |
cls := aClass. |
|
216 |
cls isMeta ifTrue:[ |
|
217 |
cls := cls soleInstance |
|
218 |
]. |
|
219 |
||
83
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
220 |
aRevisionStringOrNil isNil ifTrue:[ |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
221 |
revision := cls revision. |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
222 |
revision isNil ifTrue:[ |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
223 |
'SOURCEMGR: class ' , cls name , ' has no revision string' infoPrintNL. |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
224 |
^ nil. |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
225 |
] |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
226 |
] ifFalse:[ |
250202dc956e
added sourceStreamFor:revision: - to access a specific (older) revision
Claus Gittinger <cg@exept.de>
parents:
77
diff
changeset
|
227 |
revision := aRevisionStringOrNil |
58 | 228 |
]. |
229 |
||
230 |
sourceInfo := cls sourceCodeInfo. |
|
231 |
sourceInfo isNil ifTrue:[ |
|
66 | 232 |
('SOURCEMGR: class ' , cls name , ' has no sourceInfo.') infoPrintNL. |
58 | 233 |
^ nil |
234 |
]. |
|
235 |
||
236 |
packageDir := sourceInfo at:#directory. |
|
237 |
moduleDir := sourceInfo at:#module. "/ use the modules name as CVS module |
|
238 |
classFileName := Smalltalk fileNameForClass:cls. |
|
239 |
||
240 |
^ self |
|
241 |
streamForClass:cls |
|
242 |
fileName:classFileName |
|
243 |
revision:revision |
|
244 |
directory:packageDir |
|
245 |
module:moduleDir |
|
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
246 |
cache:true |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
247 |
|
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
248 |
"Modified: 9.11.1995 / 14:34:10 / cg" |
58 | 249 |
! ! |
250 |
||
71 | 251 |
!AbstractSourceCodeManager class methodsFor:'source code administration'! |
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
252 |
|
77 | 253 |
writeRevisionLogOf:aClass to:aStream |
254 |
"extract a classes log and append it to aStream." |
|
73 | 255 |
|
77 | 256 |
^ self |
257 |
writeRevisionLogOf:aClass fromRevision:nil toRevision:nil to:aStream |
|
258 |
||
259 |
" |
|
260 |
SourceCodeManager writeRevisionLogOf:Array to:Transcript |
|
261 |
" |
|
73 | 262 |
! |
263 |
||
77 | 264 |
writeRevisionLogOf:aClass fromRevision:rev1 toRevision:rev2 to:aStream |
73 | 265 |
"extract a classes log and append it to aStream." |
266 |
||
267 |
|cls sourceInfo tempDir packageDir moduleDir tempFile classFileName ok| |
|
268 |
||
269 |
cls := aClass. |
|
270 |
cls isMeta ifTrue:[ |
|
75 | 271 |
cls := cls soleInstance |
73 | 272 |
]. |
273 |
||
274 |
sourceInfo := cls sourceCodeInfo. |
|
275 |
sourceInfo isNil ifTrue:[ |
|
75 | 276 |
'SOURCEMGR: cannot extract classes sourceInfo' infoPrintNL. |
277 |
^ false |
|
73 | 278 |
]. |
58 | 279 |
|
73 | 280 |
packageDir := sourceInfo at:#directory. |
281 |
moduleDir := sourceInfo at:#module. "/ use the modules name as CVS module |
|
282 |
classFileName := Smalltalk fileNameForClass:cls. |
|
283 |
||
284 |
^ self |
|
75 | 285 |
writeRevisionLogOf:cls |
77 | 286 |
fromRevision:rev1 |
287 |
toRevision:rev2 |
|
75 | 288 |
fileName:classFileName |
289 |
directory:packageDir |
|
290 |
module:moduleDir |
|
291 |
to:aStream |
|
73 | 292 |
|
293 |
" |
|
77 | 294 |
SourceCodeManager writeRevisionLogOf:Array fromRevision:'1.40' toRevision:'1.43' to:Transcript |
73 | 295 |
" |
296 |
||
297 |
"Created: 6.11.1995 / 18:56:00 / cg" |
|
77 | 298 |
"Modified: 20.11.1995 / 12:19:47 / cg" |
299 |
! |
|
300 |
||
301 |
writeRevisionLogOf:cls fromRevision:rev1 toRevision:rev2 fileName:classFileName directory:packageDir module:moduleDir to:aStream |
|
302 |
self subclassResponsibility. |
|
303 |
||
304 |
"Created: 15.11.1995 / 18:12:51 / cg" |
|
305 |
"Modified: 20.11.1995 / 12:20:12 / cg" |
|
306 |
! |
|
307 |
||
71 | 308 |
! ! |