author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 12 Mar 2013 10:31:15 +0000 | |
branch | jv |
changeset 3125 | 08d6603c4fe9 |
parent 3063 | 5334204e354f |
child 3128 | 87750af738dc |
permissions | -rw-r--r-- |
2674 | 1 |
" |
2 |
COPYRIGHT (c) 2011 by Claus Gittinger |
|
3 |
All Rights Reserved |
|
4 |
||
5 |
This software is furnished under a license and may be used |
|
6 |
only in accordance with the terms of that license and with the |
|
7 |
inclusion of the above copyright notice. This software may not |
|
8 |
be provided or otherwise made available to, or used by, any |
|
9 |
other person. No title to or ownership of the software is |
|
10 |
hereby transferred. |
|
11 |
" |
|
12 |
"{ Package: 'stx:libbasic3' }" |
|
13 |
||
14 |
AbstractSourceCodeManager subclass:#DataBaseSourceCodeManager |
|
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
15 |
instanceVariableNames:'' |
2733
e164eb9dbd69
shownInSourceCodeManager from superclass
Claus Gittinger <cg@exept.de>
parents:
2717
diff
changeset
|
16 |
classVariableNames:'Verbose RepositoryName ModuleDBs CachedDBHandles' |
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
17 |
poolDictionaries:'' |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
18 |
category:'System-SourceCodeManagement' |
2674 | 19 |
! |
20 |
||
21 |
!DataBaseSourceCodeManager class methodsFor:'documentation'! |
|
22 |
||
23 |
copyright |
|
24 |
" |
|
25 |
COPYRIGHT (c) 2011 by Claus Gittinger |
|
26 |
All Rights Reserved |
|
27 |
||
28 |
This software is furnished under a license and may be used |
|
29 |
only in accordance with the terms of that license and with the |
|
30 |
inclusion of the above copyright notice. This software may not |
|
31 |
be provided or otherwise made available to, or used by, any |
|
32 |
other person. No title to or ownership of the software is |
|
33 |
hereby transferred. |
|
34 |
" |
|
35 |
! |
|
36 |
||
37 |
documentation |
|
38 |
" |
|
2687 | 39 |
A simple database sourceCodeManager, which saves versions in a relational db |
2674 | 40 |
|
2687 | 41 |
unfinished |
2674 | 42 |
|
43 |
[author:] |
|
44 |
Claus Gittinger |
|
45 |
" |
|
46 |
! ! |
|
47 |
||
48 |
!DataBaseSourceCodeManager class methodsFor:'accessing'! |
|
49 |
||
2687 | 50 |
getRepositoryDBForModule:aModuleName |
2674 | 51 |
"internal: used when accessing a source repository. |
2687 | 52 |
Return the db-name for a particular module. |
53 |
If no specific db was defined for that module, return the value of |
|
54 |
the global (fallBack) repositoryDB. |
|
2674 | 55 |
Nil is returned if no repository is available." |
56 |
||
2687 | 57 |
ModuleDBs isNil ifTrue:[^ RepositoryName]. |
58 |
aModuleName isNil ifTrue:[^ RepositoryName]. |
|
59 |
^ ModuleDBs at:aModuleName ifAbsent:RepositoryName. |
|
2674 | 60 |
|
61 |
"Modified: / 20-05-1998 / 16:30:12 / cg" |
|
2687 | 62 |
"Created: / 26-12-2011 / 00:30:17 / cg" |
2674 | 63 |
! |
64 |
||
65 |
knownModules |
|
66 |
"return the modules, we currently know" |
|
67 |
||
2687 | 68 |
ModuleDBs isEmptyOrNil ifTrue:[^ #() ]. |
69 |
^ ModuleDBs keys |
|
70 |
||
71 |
"Modified: / 26-12-2011 / 00:48:51 / cg" |
|
72 |
! |
|
2674 | 73 |
|
2687 | 74 |
repositoryName |
75 |
"return the default repository" |
|
76 |
||
2717 | 77 |
^ RepositoryName ? self defaultRepositoryName |
2687 | 78 |
|
79 |
"Created: / 26-12-2011 / 00:34:14 / cg" |
|
2674 | 80 |
! |
81 |
||
2687 | 82 |
repositoryName:aDBSpec |
83 |
"set the default repository" |
|
84 |
||
85 |
RepositoryName := aDBSpec. |
|
86 |
||
87 |
"Created: / 26-12-2011 / 01:13:59 / cg" |
|
88 |
! ! |
|
89 |
||
90 |
!DataBaseSourceCodeManager class methodsFor:'private'! |
|
91 |
||
92 |
dbHandleForModule:aModuleName |
|
93 |
|dbName handle| |
|
94 |
||
95 |
CachedDBHandles isNil ifTrue:[ |
|
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
96 |
CachedDBHandles := WeakValueDictionary new. |
2687 | 97 |
]. |
2674 | 98 |
|
2687 | 99 |
handle := CachedDBHandles at:aModuleName ifAbsent:nil. |
100 |
handle notNil ifTrue:[^ handle ]. |
|
101 |
||
102 |
dbName := self getRepositoryDBForModule:aModuleName. |
|
103 |
dbName isNil ifTrue:[ |
|
104 |
self error:'no database'. |
|
105 |
^ nil |
|
106 |
]. |
|
2674 | 107 |
|
2687 | 108 |
handle := self openDB:dbName. |
109 |
handle isNil ifTrue:[ |
|
110 |
self error:'no database'. |
|
111 |
^ nil |
|
112 |
]. |
|
113 |
CachedDBHandles at:aModuleName put:handle. |
|
114 |
^ handle. |
|
115 |
||
116 |
"Created: / 26-12-2011 / 00:59:49 / cg" |
|
2684
4fed20db7ecb
added: #repositoryPath: (fixes preference save/load problem)
vrany
parents:
2674
diff
changeset
|
117 |
! |
4fed20db7ecb
added: #repositoryPath: (fixes preference save/load problem)
vrany
parents:
2674
diff
changeset
|
118 |
|
2687 | 119 |
openDB:aDBName |
120 |
|idx dbType dbSpec| |
|
121 |
||
122 |
idx := aDBName indexOf:$:. |
|
123 |
dbType := aDBName copyTo:idx-1. |
|
124 |
dbSpec := aDBName copyFrom:idx+1. |
|
125 |
||
126 |
dbType = 'sqlite' ifTrue:[ |
|
127 |
^ self openSQLite:dbSpec |
|
128 |
]. |
|
129 |
dbType = 'odbc' ifTrue:[ |
|
130 |
^ self openODBC:dbSpec |
|
131 |
]. |
|
132 |
self error:'unsupported dbtype' |
|
133 |
||
134 |
"Created: / 26-12-2011 / 01:05:57 / cg" |
|
135 |
! |
|
136 |
||
137 |
openODBC:dbSpec |
|
138 |
self halt. |
|
2684
4fed20db7ecb
added: #repositoryPath: (fixes preference save/load problem)
vrany
parents:
2674
diff
changeset
|
139 |
|
2687 | 140 |
"Created: / 26-12-2011 / 01:06:41 / cg" |
141 |
! |
|
142 |
||
143 |
openSQLite:dbSpec |
|
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
144 |
|file con crsr tables row| |
2687 | 145 |
|
146 |
file := dbSpec. |
|
147 |
con := SQLiteConnection fileNamed:file. |
|
148 |
con open. |
|
2684
4fed20db7ecb
added: #repositoryPath: (fixes preference save/load problem)
vrany
parents:
2674
diff
changeset
|
149 |
|
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
150 |
tables := OrderedCollection new. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
151 |
|
2687 | 152 |
SqliteError handle:[:ex | |
153 |
] do:[ |
|
154 |
crsr := con executeQuery:'SELECT * FROM sqlite_master WHERE type=''table'';'. |
|
155 |
]. |
|
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
156 |
crsr notNil ifTrue:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
157 |
[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
158 |
crsr next. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
159 |
row := crsr rowAsDictionary. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
160 |
row notNil |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
161 |
] whileTrue:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
162 |
tables add:(row at:'name') |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
163 |
]. |
2687 | 164 |
]. |
165 |
||
2689
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
166 |
(tables includes:'versions') ifTrue:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
167 |
Transcript showCR:'table "versions" already present.'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
168 |
] ifFalse:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
169 |
Transcript showCR:'creating table "versions"...'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
170 |
con executeQuery:'CREATE table versions (versionId, name, packageId, author, timestamp);'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
171 |
]. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
172 |
(tables includes:'packages') ifTrue:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
173 |
Transcript showCR:'table "packages" already present.'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
174 |
] ifFalse:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
175 |
Transcript showCR:'creating table "packages"...'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
176 |
con executeQuery:'CREATE table packages (packageId, name);'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
177 |
]. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
178 |
(tables includes:'classes') ifTrue:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
179 |
Transcript showCR:'table "classes" already present.'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
180 |
] ifFalse:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
181 |
Transcript showCR:'creating table "classes"...'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
182 |
con executeQuery:'CREATE table classes (id, name, superclass, category, definition, packageId, versionId);'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
183 |
]. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
184 |
(tables includes:'methods') ifTrue:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
185 |
Transcript showCR:'table "methods" already present.'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
186 |
] ifFalse:[ |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
187 |
Transcript showCR:'creating table "methods"...'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
188 |
con executeQuery:'CREATE table methods (id, className, selector, source, bytecode, packageId, versionId);'. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
189 |
]. |
0c20a2edaac8
variable renamed in: #dbHandleForModule:
Claus Gittinger <cg@exept.de>
parents:
2687
diff
changeset
|
190 |
|
2687 | 191 |
^ con |
192 |
||
193 |
"Created: / 26-12-2011 / 01:06:37 / cg" |
|
2674 | 194 |
! ! |
195 |
||
196 |
!DataBaseSourceCodeManager class methodsFor:'queries'! |
|
197 |
||
198 |
defaultRepositoryName |
|
199 |
"/ '<db-type>:[<user>[.<password>]@][<host>]<db-name>[:<table-name>]' |
|
200 |
||
201 |
^ 'sqlite:repository.db' |
|
202 |
||
203 |
"Created: / 22-12-2011 / 00:19:43 / cg" |
|
204 |
! |
|
205 |
||
206 |
enabled |
|
207 |
^ true "/ false. |
|
208 |
||
209 |
"Created: / 21-12-2011 / 17:53:34 / cg" |
|
210 |
! |
|
211 |
||
212 |
isContainerBased |
|
213 |
"true, if the SCM uses some kind of source container (,v files). |
|
214 |
False, if it is like a database or filesystem." |
|
215 |
||
216 |
^ false |
|
217 |
||
218 |
"Created: / 21-12-2011 / 18:53:55 / cg" |
|
219 |
! |
|
220 |
||
221 |
isResponsibleForPackage:aString |
|
222 |
^ true. |
|
223 |
||
224 |
"Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
225 |
"Modified (format): / 22-12-2011 / 00:05:39 / cg" |
|
226 |
! |
|
227 |
||
228 |
managerTypeName |
|
229 |
^ 'DBRepository' |
|
230 |
||
231 |
"Created: / 16-08-2006 / 11:05:56 / cg" |
|
232 |
! |
|
233 |
||
234 |
nameOfVersionMethodForExtensions |
|
235 |
^ #'extensionsVersion_DB' |
|
236 |
||
237 |
"Modified: / 22-12-2011 / 00:06:15 / cg" |
|
238 |
! |
|
239 |
||
240 |
nameOfVersionMethodInClasses |
|
241 |
^ #'version_DB' |
|
242 |
||
243 |
"Modified: / 22-12-2011 / 00:06:21 / cg" |
|
244 |
! |
|
245 |
||
246 |
repositoryNameForPackage:packageId |
|
247 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method" |
|
248 |
||
249 |
^ self getDBNameForModule:(packageId upTo:$: ) |
|
250 |
||
251 |
"Created: / 21-12-2011 / 23:07:02 / cg" |
|
252 |
! |
|
253 |
||
254 |
settingsApplicationClass |
|
255 |
"link to my settings application (needed for the settings dialog" |
|
256 |
||
257 |
^ DataBaseSourceCodeManagementSettingsAppl |
|
258 |
||
259 |
"Created: / 19-04-2011 / 12:43:29 / cg" |
|
260 |
"Modified: / 22-12-2011 / 00:06:53 / cg" |
|
261 |
! ! |
|
262 |
||
263 |
!DataBaseSourceCodeManager class methodsFor:'saving'! |
|
264 |
||
265 |
savePreferencesOn:aStream |
|
266 |
aStream nextPutLine:'DataBaseSourceCodeManager notNil ifTrue:['. |
|
267 |
self repositoryInfoPerModule notEmptyOrNil ifTrue:[ |
|
268 |
aStream nextPutLine:' DataBaseSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'. |
|
269 |
]. |
|
270 |
(Smalltalk at:#SourceCodeManager) == self ifTrue:[ |
|
271 |
aStream nextPutLine:' Smalltalk at:#SourceCodeManager put:DataBaseSourceCodeManager.'. |
|
272 |
]. |
|
2694 | 273 |
aStream nextPutLine:' DataBaseSourceCodeManager repositoryName:' , self repositoryName storeString , '.'. |
2674 | 274 |
aStream nextPutLine:'].'. |
275 |
||
276 |
"Created: / 09-11-2006 / 15:09:25 / cg" |
|
277 |
"Modified: / 22-12-2011 / 00:48:25 / cg" |
|
2694 | 278 |
"Modified: / 01-01-2012 / 17:02:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2674 | 279 |
! ! |
280 |
||
281 |
!DataBaseSourceCodeManager class methodsFor:'source code administration'! |
|
282 |
||
283 |
checkForExistingContainer:fileName inModule:moduleName directory:dirName |
|
284 |
^ self checkForExistingModule:moduleName directory:dirName |
|
285 |
||
286 |
"Created: / 21-12-2011 / 17:56:23 / cg" |
|
287 |
! |
|
288 |
||
289 |
checkForExistingModule:moduleDir |
|
290 |
"check for a package directory to be present" |
|
291 |
||
2687 | 292 |
^ true. |
2674 | 293 |
"/ |
294 |
"/ dir := self moduleDirectoryFor:moduleDir. |
|
295 |
"/ ^ dir exists |
|
296 |
||
297 |
"Created: / 21-12-2011 / 18:37:28 / cg" |
|
298 |
! |
|
299 |
||
300 |
checkForExistingModule:moduleDir directory:packageDir |
|
2687 | 301 |
"check for a package directory to be present; return true, if it does" |
302 |
||
303 |
|handle packagePresent name| |
|
304 |
||
305 |
handle := self dbHandleForModule:moduleDir. |
|
306 |
name := moduleDir,':',packageDir. |
|
2674 | 307 |
|
2687 | 308 |
packagePresent := false. |
309 |
handle |
|
310 |
withResultForQuery: ('select * from packages where name = "%1"' bindWith:name) |
|
311 |
do:[:result | |
|
312 |
packagePresent := result numRows > 0. |
|
313 |
]. |
|
314 |
||
315 |
^ packagePresent |
|
2674 | 316 |
|
317 |
"Created: / 21-12-2011 / 18:03:33 / cg" |
|
318 |
! |
|
319 |
||
320 |
checkinClass:aClass fileName:classFileName directory:packageDir module:moduleDir source:sourceFile logMessage:logMessage force:force |
|
321 |
"Return true if ok, false if not." |
|
322 |
||
2687 | 323 |
aClass definition. |
324 |
||
325 |
||
2674 | 326 |
self halt. |
327 |
"/ |targetDir newestRevision newRevision newFile packageMode filter outStream| |
|
328 |
"/ |
|
329 |
"/ targetDir := self packageDirectoryForModule:moduleDir package:packageDir. |
|
330 |
"/ |
|
331 |
"/ (targetDir filesMatching:(classFileName,'_*')) do:[:eachVersionFile | |
|
332 |
"/ |versionString| |
|
333 |
"/ |
|
334 |
"/ versionString := eachVersionFile copyFrom:(classFileName size + 2). |
|
335 |
"/ (newestRevision isNil |
|
336 |
"/ or:[ self isRevision:versionString after:newestRevision ]) ifTrue:[ |
|
337 |
"/ newestRevision := versionString |
|
338 |
"/ ]. |
|
339 |
"/ ]. |
|
340 |
"/ |
|
341 |
"/ newestRevision isNil ifTrue:[ |
|
342 |
"/ newRevision := '1' |
|
343 |
"/ ] ifFalse:[ |
|
344 |
"/ newRevision := self revisionAfter:newestRevision |
|
345 |
"/ ]. |
|
346 |
"/ newFile := (targetDir construct:classFileName,'_',newRevision printString). |
|
347 |
"/ |
|
348 |
"/ self updateVersionMethodOf:aClass for:(self revisionStringFor:aClass inModule:moduleDir directory:packageDir container:classFileName revision:newRevision). |
|
349 |
"/ |
|
350 |
"/ packageMode := self checkMethodPackagesOf:aClass. |
|
351 |
"/ packageMode == #base ifTrue:[ |
|
352 |
"/ filter := [:mthd | mthd package = aClass package]. |
|
353 |
"/ ]. |
|
354 |
"/ |
|
355 |
"/ [ |
|
356 |
"/ outStream := newFile writeStream. |
|
357 |
"/ ] on:FileStream openErrorSignal do:[:ex| |
|
358 |
"/ self reportError:('fileout failed'). |
|
359 |
"/ ^ false |
|
360 |
"/ ]. |
|
361 |
"/ |
|
362 |
"/ Method flushSourceStreamCache. |
|
363 |
"/ Class fileOutErrorSignal handle:[:ex | |
|
364 |
"/ outStream close. |
|
365 |
"/ newFile delete. |
|
366 |
"/ self reportError:('fileout failed (',ex description,')'). |
|
367 |
"/ ^ false |
|
368 |
"/ ] do:[ |
|
369 |
"/ self |
|
370 |
"/ fileOutSourceCodeOf:aClass |
|
371 |
"/ on:outStream |
|
372 |
"/ withTimeStamp:false |
|
373 |
"/ withInitialize:true |
|
374 |
"/ withDefinition:true |
|
375 |
"/ methodFilter:filter. |
|
376 |
"/ ]. |
|
377 |
"/ outStream close. |
|
378 |
"/ |
|
379 |
"/ newFile exists ifFalse:[ |
|
380 |
"/ self reportError:'fileout failed'. |
|
381 |
"/ ^ false. |
|
382 |
"/ ]. |
|
383 |
"/ |
|
384 |
"/ ^ true |
|
385 |
"/ |
|
386 |
"/ |
|
387 |
||
388 |
"Created: / 21-12-2011 / 19:01:07 / cg" |
|
389 |
! |
|
390 |
||
391 |
createModule:moduleDir |
|
392 |
"create a module directory" |
|
393 |
||
394 |
self halt. |
|
395 |
"/ |dir| |
|
396 |
"/ |
|
397 |
"/ dir := self moduleDirectoryFor:moduleDir. |
|
398 |
"/ dir recursiveMakeDirectory. |
|
399 |
"/ ^ dir exists. |
|
400 |
||
401 |
"Created: / 21-12-2011 / 18:38:22 / cg" |
|
402 |
! |
|
403 |
||
404 |
createModule:moduleDir directory:packageDir |
|
405 |
"create a package directory" |
|
406 |
||
2687 | 407 |
|handle id name| |
408 |
||
409 |
id := UUID new. |
|
410 |
name := (moduleDir,':',packageDir). |
|
411 |
||
412 |
handle := self dbHandleForModule:moduleDir. |
|
413 |
handle |
|
414 |
withResultForQuery: ('insert into packages values (''%1'', ''%2'')' bindWith:id with:name) |
|
415 |
do:[:result | |
|
416 |
]. |
|
417 |
||
2674 | 418 |
self halt. |
419 |
"/ |dir| |
|
420 |
"/ |
|
421 |
"/ dir := self packageDirectoryForModule:moduleDir package:packageDir. |
|
422 |
"/ dir recursiveMakeDirectory. |
|
423 |
"/ ^ dir exists. |
|
424 |
||
425 |
"Created: / 21-12-2011 / 18:44:20 / cg" |
|
426 |
! |
|
427 |
||
428 |
initialRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName |
|
429 |
"return a string usable as initial revision string" |
|
430 |
||
431 |
^ self |
|
432 |
revisionStringFor:aClass |
|
433 |
inModule:moduleDir |
|
434 |
directory:packageDir |
|
435 |
container:fileName |
|
436 |
revision:'1' |
|
437 |
||
438 |
"Created: / 21-12-2011 / 18:14:03 / cg" |
|
439 |
! |
|
440 |
||
441 |
revisionInfoFromString:aString |
|
442 |
"{ Pragma: +optSpace }" |
|
443 |
||
444 |
"return a VersionInfo object filled with revision info. |
|
445 |
This extracts the relevant info from aString." |
|
446 |
||
3063 | 447 |
^ self revisionInfoFromStandardVersionString:aString |
2674 | 448 |
|
449 |
" |
|
450 |
self revisionInfoFromString:'Path: stx/libbasic/Array.st, Version: 123, User: cg, Time: 2011-12-21T21:03:08.826' |
|
451 |
" |
|
452 |
||
453 |
"Created: / 21-12-2011 / 14:50:12 / cg" |
|
454 |
! |
|
455 |
||
456 |
revisionLogOf:clsOrNil fromRevision:rev1OrNil toRevision:rev2OrNil numberOfRevisions:limitOrNil fileName:classFileName directory:packageDir module:moduleDir |
|
457 |
"Return true if ok, false if not." |
|
458 |
||
459 |
self halt. |
|
460 |
"/ |info log targetDir count newestRevision| |
|
461 |
"/ |
|
462 |
"/ targetDir := self packageDirectoryForModule:moduleDir package:packageDir. |
|
463 |
"/ targetDir exists ifFalse:[^ nil ]. |
|
464 |
"/ |
|
465 |
"/ info := IdentityDictionary new. |
|
466 |
"/ log := OrderedCollection new. |
|
467 |
"/ count := 0. |
|
468 |
"/ |
|
469 |
"/ (targetDir filesMatching:(classFileName,'_*')) do:[:eachVersionFile | |
|
470 |
"/ |versionString cs versionChange info| |
|
471 |
"/ |
|
472 |
"/ versionString := eachVersionFile copyFrom:(classFileName size + 2). |
|
473 |
"/ count := count + 1. |
|
474 |
"/ (newestRevision isNil |
|
475 |
"/ or:[ self isRevision:versionString after:newestRevision ]) ifTrue:[ |
|
476 |
"/ newestRevision := versionString |
|
477 |
"/ ]. |
|
478 |
"/ |
|
479 |
"/ (rev1OrNil isNil |
|
480 |
"/ or:[ rev1OrNil = 0 |
|
481 |
"/ or:[ versionString = rev1OrNil |
|
482 |
"/ or:[ self isRevision:versionString after:rev1OrNil ]]]) |
|
483 |
"/ ifTrue:[ |
|
484 |
"/ (rev2OrNil isNil |
|
485 |
"/ or:[ rev2OrNil = 0 |
|
486 |
"/ or:[ versionString = rev2OrNil |
|
487 |
"/ or:[ self isRevision:rev2OrNil after:versionString ]]]) |
|
488 |
"/ ifTrue:[ |
|
489 |
"/ (limitOrNil isNil |
|
490 |
"/ or:[ log size < limitOrNil ]) |
|
491 |
"/ ifTrue:[ |
|
492 |
"/ cs := ChangeSet fromFile:(targetDir construct:eachVersionFile). |
|
493 |
"/ versionChange := cs detect:[:chg | chg isMethodChange |
|
494 |
"/ and:[chg selector = self nameOfVersionMethodInClasses]] |
|
495 |
"/ ifNone:nil. |
|
496 |
"/ versionChange notNil ifTrue:[ |
|
497 |
"/ info := self revisionInfoFromString:versionChange source. |
|
498 |
"/ ] ifFalse:[ |
|
499 |
"/ info := VersionInfo new. |
|
500 |
"/ ]. |
|
501 |
"/ |
|
502 |
"/ info revision:versionString. |
|
503 |
"/ log add:info. |
|
504 |
"/ ] |
|
505 |
"/ ]. |
|
506 |
"/ ]. |
|
507 |
"/ ]. |
|
508 |
"/ log sort:[:a :b | self isRevision:b revision after:a revision]. |
|
509 |
"/ |
|
510 |
"/ info at:#revisions put:log. |
|
511 |
"/ info at:#numberOfRevisions put:count. |
|
512 |
"/ info at:#newestRevision put:newestRevision. |
|
513 |
"/ |
|
514 |
"/ ^ info |
|
515 |
"/ |
|
516 |
"/ |
|
517 |
||
518 |
"Created: / 21-12-2011 / 20:39:31 / cg" |
|
519 |
! |
|
520 |
||
521 |
revisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString |
|
3063 | 522 |
"utility function: return a string usable as initial revision string" |
2674 | 523 |
|
3063 | 524 |
^ self standardRevisionStringFor:aClass inModule:moduleDir directory:packageDir container:fileName revision:revisionString |
2674 | 525 |
|
526 |
" |
|
3063 | 527 |
self |
528 |
revisionStringFor:Array |
|
529 |
inModule:'stx' |
|
530 |
directory:'libbasic' |
|
531 |
container:'Array.st' |
|
532 |
revision:'123' |
|
2674 | 533 |
" |
534 |
||
535 |
"Created: / 21-12-2011 / 19:33:33 / cg" |
|
536 |
! |
|
537 |
||
538 |
streamForClass:aClass fileName:classFileName revision:revision directory:packageDir module:moduleDir cache:doCache |
|
539 |
self halt. |
|
540 |
"/ |targetDir oldFile| |
|
541 |
"/ |
|
542 |
"/ targetDir := self packageDirectoryForModule:moduleDir package:packageDir. |
|
543 |
"/ oldFile := (targetDir construct:classFileName,'_',revision). |
|
544 |
"/ ^ oldFile readStream |
|
545 |
||
546 |
"Created: / 21-12-2011 / 20:49:01 / cg" |
|
547 |
! ! |
|
548 |
||
549 |
!DataBaseSourceCodeManager class methodsFor:'documentation'! |
|
550 |
||
551 |
version |
|
3063 | 552 |
^ '$Header: /cvs/stx/stx/libbasic3/DataBaseSourceCodeManager.st,v 1.10 2012/07/24 07:44:39 cg Exp $' |
2674 | 553 |
! |
554 |
||
555 |
version_CVS |
|
3063 | 556 |
^ '§Header: /cvs/stx/stx/libbasic3/DataBaseSourceCodeManager.st,v 1.10 2012/07/24 07:44:39 cg Exp §' |
3012 | 557 |
! |
558 |
||
3125
08d6603c4fe9
New check in ProjectChecker.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3063
diff
changeset
|
559 |
version_HG |
08d6603c4fe9
New check in ProjectChecker.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3063
diff
changeset
|
560 |
|
08d6603c4fe9
New check in ProjectChecker.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3063
diff
changeset
|
561 |
^ '$Changeset: <not expanded> $' |
08d6603c4fe9
New check in ProjectChecker.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3063
diff
changeset
|
562 |
! |
08d6603c4fe9
New check in ProjectChecker.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3063
diff
changeset
|
563 |
|
3012 | 564 |
version_SVN |
3063 | 565 |
^ '$Id: DataBaseSourceCodeManager.st 1937 2012-07-25 08:46:08Z vranyj1 $' |
3012 | 566 |
! ! |
3125
08d6603c4fe9
New check in ProjectChecker.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3063
diff
changeset
|
567 |