author | Claus Gittinger <cg@exept.de> |
Thu, 09 Nov 1995 14:44:21 +0100 | |
changeset 65 | 098be8484211 |
parent 64 | d8d43638d803 |
child 66 | 9a2555d62cdd |
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 |
'From Smalltalk/X, Version:2.10.8 on 4-nov-1995 at 10:07:36 pm' ! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
14 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
15 |
Object subclass:#AbstractSourceCodeManager |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
16 |
instanceVariableNames:'' |
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
17 |
classVariableNames:'CacheDirectoryName' |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
18 |
poolDictionaries:'' |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
19 |
category:'System-Support' |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
20 |
! |
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 |
!AbstractSourceCodeManager class methodsFor:'documentation'! |
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 |
version |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
25 |
" |
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
26 |
$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.9 1995-11-09 13:44:18 cg Exp $ |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
27 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
28 |
! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
29 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
30 |
documentation |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
31 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
32 |
Abstract superclass for sourceCodeManagers. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
33 |
Concrete subclasses provide access to a source repository. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
34 |
All protocol here traps into subclassResponsbility errors. |
57 | 35 |
Please read more documentation in concrete subclasses |
36 |
(especially: CVSSourceCodeManager) for how to use this manager. |
|
56
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 |
! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
39 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
40 |
copyright |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
41 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
42 |
COPYRIGHT (c) 1995 by Claus Gittinger |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
43 |
All Rights Reserved |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
44 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
45 |
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
|
46 |
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
|
47 |
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
|
48 |
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
|
49 |
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
|
50 |
hereby transferred. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
51 |
" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
52 |
! ! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
53 |
|
63 | 54 |
!AbstractSourceCodeManager class methodsFor:'initialization'! |
55 |
||
56 |
initCacheDirPath |
|
57 |
|path| |
|
58 |
||
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
59 |
path := OperatingSystem getEnvironment:'STX_TMPPATH'. |
63 | 60 |
path isNil ifTrue:[ |
61 |
path := OperatingSystem getEnvironment:'TMPPATH'. |
|
62 |
path isNil ifTrue:[ |
|
63 |
path := '/tmp' |
|
64 |
] |
|
65 |
]. |
|
64 | 66 |
CacheDirectoryName := path , '/stx_sourceCache'. |
63 | 67 |
! ! |
68 |
||
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
69 |
!AbstractSourceCodeManager class methodsFor:'source code access'! |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
70 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
71 |
sourceStreamFor:aClass |
58 | 72 |
"extract a classes source code and return an open readStream on it. |
73 |
The classes source code is extracted using the revision and the sourceCodeInfo, |
|
74 |
which itself is extracted from the classes packageString." |
|
75 |
||
76 |
|classFileName revision packageDir moduleDir sourceInfo cls| |
|
77 |
||
78 |
cls := aClass. |
|
79 |
cls isMeta ifTrue:[ |
|
80 |
cls := cls soleInstance |
|
81 |
]. |
|
82 |
||
83 |
revision := cls revision. |
|
84 |
revision isNil ifTrue:[ self halt. |
|
85 |
'SOURCEMGR: class has no revision string' infoPrintNL. |
|
86 |
^ nil. |
|
87 |
]. |
|
88 |
||
89 |
sourceInfo := cls sourceCodeInfo. |
|
90 |
sourceInfo isNil ifTrue:[ |
|
91 |
'SOURCEMGR: cannot extract classes sourceInfo' infoPrintNL. |
|
92 |
^ nil |
|
93 |
]. |
|
94 |
||
95 |
packageDir := sourceInfo at:#directory. |
|
96 |
moduleDir := sourceInfo at:#module. "/ use the modules name as CVS module |
|
97 |
classFileName := Smalltalk fileNameForClass:cls. |
|
98 |
||
99 |
^ self |
|
100 |
streamForClass:cls |
|
101 |
fileName:classFileName |
|
102 |
revision:revision |
|
103 |
directory:packageDir |
|
104 |
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
|
105 |
cache:true |
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
106 |
|
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
107 |
"Modified: 9.11.1995 / 14:34:10 / cg" |
58 | 108 |
! |
109 |
||
61 | 110 |
mostRecentSourceStreamForClassNamed:aClassOrClassName |
111 |
|abbrev classFileName revision packageDir moduleDir sourceInfo cls| |
|
112 |
||
113 |
classFileName := Smalltalk fileNameForClass:aClassOrClassName. |
|
114 |
packageDir := Smalltalk sourceDirectoryNameOfClass:aClassOrClassName. |
|
115 |
moduleDir := 'stx'. |
|
63 | 116 |
packageDir isNil ifTrue:[^ nil]. |
61 | 117 |
|
118 |
^ self |
|
119 |
streamForClass:nil |
|
120 |
fileName:classFileName |
|
121 |
revision:#newest |
|
122 |
directory:packageDir |
|
123 |
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
|
124 |
cache:false |
61 | 125 |
|
126 |
"Created: 6.11.1995 / 16:09:06 / cg" |
|
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
127 |
"Modified: 9.11.1995 / 14:34:15 / cg" |
63 | 128 |
! |
129 |
||
130 |
checkinClass:aClass |
|
131 |
|cls sourceInfo tempDir packageDir moduleDir tempFile classFileName| |
|
132 |
||
133 |
cls := aClass. |
|
134 |
cls isMeta ifTrue:[ |
|
135 |
cls := cls soleInstance |
|
136 |
]. |
|
137 |
||
138 |
sourceInfo := cls sourceCodeInfo. |
|
139 |
sourceInfo isNil ifTrue:[ |
|
140 |
'SOURCEMGR: cannot extract classes sourceInfo' infoPrintNL. |
|
141 |
^ nil |
|
142 |
]. |
|
143 |
||
144 |
packageDir := sourceInfo at:#directory. |
|
145 |
moduleDir := sourceInfo at:#module. "/ use the modules name as CVS module |
|
146 |
classFileName := Smalltalk fileNameForClass:cls. |
|
147 |
||
148 |
tempDir := (Filename newTemporaryIn:nil) makeDirectory. |
|
149 |
[ |
|
150 |
aClass fileOutIn:tempDir. |
|
151 |
||
152 |
(tempFile := tempDir construct:(classFileName,'.st')) exists ifFalse:[ |
|
153 |
'SOURCEMG: temporary fileout failed' infoPrintNL. |
|
154 |
]. |
|
155 |
||
156 |
^ self |
|
157 |
checkinClass:cls |
|
158 |
fileName:classFileName |
|
159 |
directory:packageDir |
|
160 |
module:moduleDir |
|
161 |
source:(tempFile name) |
|
162 |
] valueNowOrOnUnwindDo:[ |
|
163 |
OperatingSystem recursiveRemoveDirectory:tempDir name |
|
164 |
]. |
|
165 |
||
166 |
" |
|
167 |
SourceCodeManager checkinClass:Array |
|
168 |
" |
|
169 |
||
170 |
"Created: 6.11.1995 / 18:56:00 / cg" |
|
171 |
"Modified: 6.11.1995 / 20:05:17 / cg" |
|
58 | 172 |
! ! |
173 |
||
174 |
!AbstractSourceCodeManager class methodsFor:'private'! |
|
175 |
||
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
176 |
cacheDirectoryName |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
177 |
^ CacheDirectoryName |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
178 |
! |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
179 |
|
58 | 180 |
sourceCacheDirectory |
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
181 |
|dir nm| |
58 | 182 |
|
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
183 |
(nm := self cacheDirectoryName) isNil ifTrue:[^ nil]. |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
184 |
|
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
185 |
(dir := nm asFilename) exists ifFalse:[ |
58 | 186 |
dir makeDirectory. |
187 |
dir asFilename exists ifFalse:[ |
|
188 |
'SOURCEMGR: could not create cache dir ''' , CacheDirectoryName , '''' infoPrintNL. |
|
189 |
^ nil |
|
190 |
]. |
|
191 |
]. |
|
192 |
^ dir |
|
193 |
! |
|
194 |
||
65
098be8484211
dont cache classes of which the newest rev. has been checked out
Claus Gittinger <cg@exept.de>
parents:
64
diff
changeset
|
195 |
streamForClass:cls fileName:classFileName revision:revision directory:packageDir module:moduleDir cache:cacheIt |
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
196 |
self subclassResponsibility. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
197 |
^ nil |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
198 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
199 |
"Created: 4.11.1995 / 19:09:12 / cg" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
200 |
"Modified: 4.11.1995 / 19:15:43 / cg" |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
201 |
! ! |