author | Claus Gittinger <cg@exept.de> |
Mon, 06 Nov 1995 20:13:52 +0100 | |
changeset 64 | d8d43638d803 |
parent 63 | abf51a9ae873 |
child 65 | 098be8484211 |
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 |
" |
64 | 26 |
$Header: /cvs/stx/stx/libbasic3/AbstractSourceCodeManager.st,v 1.8 1995-11-06 19:13:52 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 |
||
59 |
path := OperatingSystem getEnvironment:'ST_TMPPATH'. |
|
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 |
|
105 |
! |
|
106 |
||
61 | 107 |
mostRecentSourceStreamForClassNamed:aClassOrClassName |
108 |
|abbrev classFileName revision packageDir moduleDir sourceInfo cls| |
|
109 |
||
110 |
classFileName := Smalltalk fileNameForClass:aClassOrClassName. |
|
111 |
packageDir := Smalltalk sourceDirectoryNameOfClass:aClassOrClassName. |
|
112 |
moduleDir := 'stx'. |
|
63 | 113 |
packageDir isNil ifTrue:[^ nil]. |
61 | 114 |
|
115 |
^ self |
|
116 |
streamForClass:nil |
|
117 |
fileName:classFileName |
|
118 |
revision:#newest |
|
119 |
directory:packageDir |
|
120 |
module:moduleDir |
|
121 |
||
122 |
"Created: 6.11.1995 / 16:09:06 / cg" |
|
63 | 123 |
"Modified: 6.11.1995 / 18:45:58 / cg" |
124 |
! |
|
125 |
||
126 |
checkinClass:aClass |
|
127 |
|cls sourceInfo tempDir packageDir moduleDir tempFile classFileName| |
|
128 |
||
129 |
cls := aClass. |
|
130 |
cls isMeta ifTrue:[ |
|
131 |
cls := cls soleInstance |
|
132 |
]. |
|
133 |
||
134 |
sourceInfo := cls sourceCodeInfo. |
|
135 |
sourceInfo isNil ifTrue:[ |
|
136 |
'SOURCEMGR: cannot extract classes sourceInfo' infoPrintNL. |
|
137 |
^ nil |
|
138 |
]. |
|
139 |
||
140 |
packageDir := sourceInfo at:#directory. |
|
141 |
moduleDir := sourceInfo at:#module. "/ use the modules name as CVS module |
|
142 |
classFileName := Smalltalk fileNameForClass:cls. |
|
143 |
||
144 |
tempDir := (Filename newTemporaryIn:nil) makeDirectory. |
|
145 |
[ |
|
146 |
aClass fileOutIn:tempDir. |
|
147 |
||
148 |
(tempFile := tempDir construct:(classFileName,'.st')) exists ifFalse:[ |
|
149 |
'SOURCEMG: temporary fileout failed' infoPrintNL. |
|
150 |
]. |
|
151 |
||
152 |
^ self |
|
153 |
checkinClass:cls |
|
154 |
fileName:classFileName |
|
155 |
directory:packageDir |
|
156 |
module:moduleDir |
|
157 |
source:(tempFile name) |
|
158 |
] valueNowOrOnUnwindDo:[ |
|
159 |
OperatingSystem recursiveRemoveDirectory:tempDir name |
|
160 |
]. |
|
161 |
||
162 |
" |
|
163 |
SourceCodeManager checkinClass:Array |
|
164 |
" |
|
165 |
||
166 |
"Created: 6.11.1995 / 18:56:00 / cg" |
|
167 |
"Modified: 6.11.1995 / 20:05:17 / cg" |
|
58 | 168 |
! ! |
169 |
||
170 |
!AbstractSourceCodeManager class methodsFor:'private'! |
|
171 |
||
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
172 |
cacheDirectoryName |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
173 |
^ CacheDirectoryName |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
174 |
! |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
175 |
|
58 | 176 |
sourceCacheDirectory |
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
177 |
|dir nm| |
58 | 178 |
|
59
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
179 |
(nm := self cacheDirectoryName) isNil ifTrue:[^ nil]. |
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
180 |
|
3bb0b97dffa2
reorganized; shared methods into AbstractSCMMgr
Claus Gittinger <cg@exept.de>
parents:
58
diff
changeset
|
181 |
(dir := nm asFilename) exists ifFalse:[ |
58 | 182 |
dir makeDirectory. |
183 |
dir asFilename exists ifFalse:[ |
|
184 |
'SOURCEMGR: could not create cache dir ''' , CacheDirectoryName , '''' infoPrintNL. |
|
185 |
^ nil |
|
186 |
]. |
|
187 |
]. |
|
188 |
^ dir |
|
189 |
! |
|
190 |
||
191 |
streamForClass:cls fileName:classFileName revision:revision directory:packageDir module:moduleDir |
|
56
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
192 |
self subclassResponsibility. |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
193 |
^ nil |
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
194 |
|
6705671acee8
source code managers (optional) These are involved, if no
Claus Gittinger <cg@exept.de>
parents:
diff
changeset
|
195 |
"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
|
196 |
"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
|
197 |
! ! |