author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 31 Mar 2012 01:14:49 +0100 | |
branch | jv |
changeset 3042 | 48e76977cdc3 |
parent 3037 | e19a3b396c63 |
child 3088 | e1f7c7f799f8 |
permissions | -rw-r--r-- |
2722 | 1 |
" |
2 |
COPYRIGHT (c) 2012 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:#MercurialSourceCodeManager |
|
15 |
instanceVariableNames:'' |
|
16 |
classVariableNames:'Verbose DefaultRepository PerModuleRepositories HGTempDir |
|
17 |
DisabledModules HGCommandSemaphore HGExecutable HGCommitOptions |
|
18 |
HGUpdateOptions HGCommandTimeout |
|
3037 | 19 |
RecentlyCheckedModulesAndPackages WorkDirectory' |
2722 | 20 |
poolDictionaries:'' |
21 |
category:'System-SourceCodeManagement' |
|
22 |
! |
|
23 |
||
24 |
!MercurialSourceCodeManager class methodsFor:'documentation'! |
|
25 |
||
26 |
copyright |
|
27 |
" |
|
28 |
COPYRIGHT (c) 2012 by Claus Gittinger |
|
29 |
All Rights Reserved |
|
30 |
||
31 |
This software is furnished under a license and may be used |
|
32 |
only in accordance with the terms of that license and with the |
|
33 |
inclusion of the above copyright notice. This software may not |
|
34 |
be provided or otherwise made available to, or used by, any |
|
35 |
other person. No title to or ownership of the software is |
|
36 |
hereby transferred. |
|
37 |
" |
|
38 |
! |
|
39 |
||
40 |
documentation |
|
41 |
" |
|
42 |
SourceCodeManager which accesses the sourcecode through hg (mercurial). |
|
43 |
ongoing work - unfinished and unusable |
|
44 |
||
45 |
Comment: |
|
46 |
The code here is a copy-paste mess; it definitely needs some cleanup... |
|
47 |
||
48 |
[author:] |
|
49 |
Claus Gittinger |
|
50 |
||
51 |
[see also:] |
|
52 |
" |
|
53 |
! ! |
|
54 |
||
55 |
!MercurialSourceCodeManager class methodsFor:'initialization'! |
|
56 |
||
57 |
forgetDisabledModules |
|
58 |
DisabledModules := nil. |
|
59 |
! |
|
60 |
||
61 |
initialize |
|
62 |
| s ok | |
|
63 |
||
64 |
HGCommandSemaphore := Semaphore new:10. "/ at most 10 hg activities concurrently |
|
65 |
HGCommitOptions := ''. |
|
66 |
HGUpdateOptions := ''. |
|
67 |
DisabledModules := nil. |
|
68 |
PerModuleRepositories isNil ifTrue:[ |
|
69 |
PerModuleRepositories := Dictionary new. |
|
70 |
]. |
|
71 |
||
3037 | 72 |
"/ will do that lazy later, to avoid making startup slower and slower... |
73 |
"/ ok := OperatingSystem canExecuteCommand:(self hgExecutable). |
|
74 |
"/ ok ifFalse:[ |
|
75 |
"/ 'MercurialSourceCodeManager [warning]: disabled because no >>hg<< command was found' infoPrintCR. |
|
76 |
"/ ^ self |
|
77 |
"/ ]. |
|
2722 | 78 |
|
79 |
CacheDirectoryName isNil ifTrue:[ |
|
80 |
self initCacheDirPath. |
|
81 |
]. |
|
82 |
CachingSources isNil ifTrue:[ |
|
83 |
CachingSources := true. |
|
84 |
]. |
|
85 |
||
86 |
"/ |
|
87 |
"/ optionally set the WorkTreeDirectoryName from $STX_WORKTREE; |
|
88 |
"/ if non-nil, a working tree is kept there |
|
89 |
"/ and updated/commited files are not removed. |
|
90 |
"/ If you use a regular (make-) tree, |
|
91 |
"/ set WorkTreeDirectoryName (or the environment variable) to that. |
|
92 |
"/ |
|
93 |
"/ this is not yet finished. |
|
94 |
"/ |
|
95 |
s := OperatingSystem getEnvironment:'STX_WORKTREE'. |
|
96 |
s notNil ifTrue:[ |
|
97 |
WorkTreeDirectoryName := s. |
|
98 |
UseWorkTree := true. |
|
99 |
] |
|
100 |
||
101 |
" |
|
102 |
AbstractSourceCodeManager initialize |
|
103 |
MercurialSourceCodeManager initialize |
|
104 |
" |
|
105 |
||
106 |
"Created: / 04-11-1995 / 19:14:38 / cg" |
|
107 |
"Modified: / 19-12-1995 / 14:25:46 / stefan" |
|
3037 | 108 |
"Modified (comment): / 20-03-2012 / 19:04:55 / cg" |
2722 | 109 |
! |
110 |
||
111 |
initializeForRepository:aDirectoryName |
|
112 |
"reinitialize. |
|
113 |
Can be used from the launcher to change/configure the repository." |
|
114 |
||
115 |
self repositoryName:aDirectoryName. |
|
116 |
AbstractSourceCodeManager initialize. |
|
117 |
MercurialSourceCodeManager initialize. |
|
118 |
||
119 |
"Created: / 13-08-1997 / 17:20:57 / cg" |
|
120 |
"Modified: / 25-09-1997 / 12:28:05 / stefan" |
|
121 |
"Modified (comment): / 14-01-2012 / 21:40:18 / cg" |
|
122 |
! ! |
|
123 |
||
124 |
!MercurialSourceCodeManager class methodsFor:'accessing'! |
|
125 |
||
126 |
hgBinDirectory:ignoredString |
|
127 |
"ignored - for backward compatibility (to read old settings files)" |
|
128 |
||
129 |
"Created: / 14-01-2012 / 20:49:46 / cg" |
|
130 |
! |
|
131 |
||
132 |
hgCommandTimeout |
|
133 |
^ HGCommandTimeout ? ("360" 120 seconds) |
|
134 |
||
135 |
"Modified (comment): / 08-01-2012 / 19:02:44 / cg" |
|
136 |
"Created: / 14-01-2012 / 20:51:10 / cg" |
|
137 |
! |
|
138 |
||
139 |
hgCommandTimeout:aTimeDuration |
|
140 |
HGCommandTimeout := aTimeDuration asTimeDuration. |
|
141 |
||
142 |
"Created: / 14-01-2012 / 20:51:26 / cg" |
|
143 |
! |
|
144 |
||
145 |
hgCommitOptions |
|
146 |
^ HGCommitOptions ? '' |
|
147 |
||
148 |
"Created: / 14-01-2012 / 20:36:07 / cg" |
|
149 |
! |
|
150 |
||
151 |
hgCommitOptions:aString |
|
152 |
HGCommitOptions := aString. |
|
153 |
||
154 |
"Created: / 14-01-2012 / 20:36:16 / cg" |
|
155 |
! |
|
156 |
||
157 |
hgExecutable |
|
158 |
"return the name of the hg executable." |
|
159 |
||
160 |
^ HGExecutable ? 'hg' |
|
161 |
||
162 |
"Created: / 14-01-2012 / 20:51:38 / cg" |
|
163 |
! |
|
164 |
||
165 |
hgExecutable:aString |
|
166 |
"set the name of the hg executable." |
|
167 |
||
168 |
aString isEmptyOrNil ifTrue:[ |
|
169 |
HGExecutable := nil |
|
170 |
] ifFalse:[ |
|
171 |
HGExecutable := aString. |
|
172 |
]. |
|
173 |
||
174 |
"Modified: / 21-09-2006 / 16:41:33 / cg" |
|
175 |
"Created: / 14-01-2012 / 20:52:02 / cg" |
|
176 |
! |
|
177 |
||
178 |
hgTmpDirectory |
|
179 |
"return the name of the tmp repository. |
|
180 |
That's the directory, where temporary files are created for checkin/checkout. |
|
181 |
If nil, the systems default tempDirectory is used." |
|
182 |
||
183 |
^ (HGTempDir ? Filename tempDirectory pathName) |
|
184 |
||
185 |
" |
|
186 |
CVSTempDir := nil |
|
187 |
" |
|
188 |
||
189 |
"Created: / 14-01-2012 / 20:52:13 / cg" |
|
190 |
! |
|
191 |
||
192 |
hgTmpDirectory:aPathNameString |
|
193 |
"set the name of the tmp repository. |
|
194 |
That's the directory, where temporary files are created for checkin/checkout. |
|
195 |
If nil, the systems default tempDirectory is used." |
|
196 |
||
197 |
HGTempDir := aPathNameString |
|
198 |
||
199 |
"Created: / 14-01-2012 / 20:52:43 / cg" |
|
200 |
! |
|
201 |
||
202 |
hgUpdateOptions |
|
203 |
^ HGUpdateOptions ? '' |
|
204 |
||
205 |
"Created: / 14-01-2012 / 20:36:23 / cg" |
|
206 |
! |
|
207 |
||
208 |
hgUpdateOptions:aString |
|
209 |
HGUpdateOptions := aString. |
|
210 |
||
211 |
"Created: / 14-01-2012 / 20:36:29 / cg" |
|
212 |
! |
|
213 |
||
214 |
knownModules |
|
215 |
"return the modules, we currently know" |
|
216 |
||
217 |
PerModuleRepositories isEmptyOrNil ifTrue:[^ #() ]. |
|
218 |
^ PerModuleRepositories keys |
|
219 |
||
220 |
"Modified: / 14-01-2012 / 21:23:37 / cg" |
|
221 |
! |
|
222 |
||
223 |
knownRepositories |
|
224 |
"return the modules, we currently know" |
|
225 |
||
226 |
^ PerModuleRepositories values copyWith:DefaultRepository |
|
227 |
||
228 |
"Modified: / 14-01-2012 / 21:23:59 / cg" |
|
229 |
! |
|
230 |
||
231 |
repositoryForPackage:packageId |
|
232 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method" |
|
233 |
||
234 |
^self getHGRepositoryForModule: ( packageId upTo:$:) |
|
235 |
||
236 |
"Modified: / 10-10-2011 / 19:38:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
237 |
"Modified: / 14-01-2012 / 21:24:21 / cg" |
|
238 |
! |
|
239 |
||
240 |
repositoryInfoPerModule |
|
241 |
"return the dictionary, which associates hgRepositories to module names. |
|
242 |
If no entry is contained in this dictionary for some module, |
|
243 |
the default crepository will be used." |
|
244 |
||
245 |
^ PerModuleRepositories ? #() |
|
246 |
||
247 |
"Modified (comment): / 14-01-2012 / 21:24:58 / cg" |
|
248 |
! |
|
249 |
||
250 |
repositoryInfoPerModule:aDictionary |
|
251 |
"set the dictionary, which associates repositories to module names. |
|
252 |
If no entry is contained in this dictionary for some module, |
|
253 |
the default repository will be used." |
|
254 |
||
255 |
PerModuleRepositories := aDictionary |
|
256 |
||
257 |
"Modified: / 14-01-2012 / 21:25:21 / cg" |
|
258 |
! |
|
259 |
||
260 |
repositoryName |
|
261 |
"return the name of the global repository. |
|
262 |
This is used, if no per-module repository is defined." |
|
263 |
||
264 |
^ DefaultRepository |
|
265 |
||
266 |
"Created: / 14-09-1996 / 13:22:05 / cg" |
|
267 |
"Modified: / 14-01-2012 / 21:25:42 / cg" |
|
268 |
! |
|
269 |
||
270 |
repositoryName:aDirectoryName |
|
271 |
"set the name of the repository; |
|
272 |
that's the name of the global repository, which is used |
|
273 |
if no specific repository was defined for a module." |
|
274 |
||
275 |
DisabledModules := nil. |
|
276 |
DefaultRepository := aDirectoryName. |
|
277 |
||
278 |
"Created: / 14-09-1996 / 13:22:24 / cg" |
|
279 |
"Modified: / 14-01-2012 / 21:26:17 / cg" |
|
280 |
! |
|
281 |
||
282 |
repositoryName:aRepositoryName forModule:aModuleName |
|
283 |
"set the repository which provides the sources for all |
|
284 |
classes in a particular module. |
|
285 |
This can be used from an rc-script, to specify a repository |
|
286 |
for a particular module. |
|
287 |
If left unspecified, the global (i.e. fallBack) repository is used." |
|
288 |
||
289 |
DisabledModules := nil. |
|
290 |
PerModuleRepositories at:aModuleName put:aRepositoryName |
|
291 |
||
292 |
"Modified (comment): / 14-01-2012 / 21:27:08 / cg" |
|
293 |
! |
|
294 |
||
295 |
repositoryNameForModule:aModuleName |
|
296 |
"return the repository which provides the sources for all |
|
297 |
classes in a particular module. |
|
298 |
Nil is returned for unspecified moduleRoots; in this case, |
|
299 |
the global (i.e. fallBack) repository will be used for source access." |
|
300 |
||
301 |
^ PerModuleRepositories at:aModuleName ifAbsent:nil. |
|
302 |
||
303 |
"Created: / 19-09-1997 / 06:13:06 / cg" |
|
304 |
! |
|
305 |
||
306 |
repositoryNameForPackage:packageId |
|
307 |
"superclass AbstractSourceCodeManager class says that I am responsible to implement this method" |
|
308 |
||
309 |
^ self getHGRepositoryForModule:(packageId upTo:$: ) |
|
310 |
||
311 |
"Created: / 10-10-2011 / 19:44:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
312 |
"Modified: / 14-01-2012 / 21:27:47 / cg" |
|
3037 | 313 |
! |
314 |
||
315 |
workDirectory |
|
316 |
^ WorkDirectory |
|
317 |
||
318 |
"Created: / 03-03-2012 / 11:08:29 / cg" |
|
319 |
! |
|
320 |
||
321 |
workDirectory:aPath |
|
322 |
WorkDirectory := aPath |
|
323 |
||
324 |
"Created: / 03-03-2012 / 11:08:37 / cg" |
|
2722 | 325 |
! ! |
326 |
||
327 |
!MercurialSourceCodeManager class methodsFor:'basic administration'! |
|
328 |
||
329 |
createContainerFor:aClass inModule:moduleName directory:dirName container:fileName |
|
330 |
"create a new container & check into it an initial version of aClass" |
|
331 |
||
332 |
^ self shouldImplement |
|
333 |
! ! |
|
334 |
||
335 |
!MercurialSourceCodeManager class methodsFor:'debugging'! |
|
336 |
||
337 |
verboseSourceCodeAccess |
|
338 |
^ Verbose ? false |
|
339 |
! |
|
340 |
||
341 |
verboseSourceCodeAccess:aBoolean |
|
342 |
Verbose := aBoolean |
|
343 |
! ! |
|
344 |
||
345 |
!MercurialSourceCodeManager class methodsFor:'queries'! |
|
346 |
||
347 |
isResponsibleForPackage:aString |
|
348 |
||
349 |
| id | |
|
350 |
||
351 |
"JV@2011-07-09: The real check is too slow. Cache needed here" |
|
352 |
^true. |
|
353 |
||
354 |
"/ id := aString asPackageId. |
|
355 |
"/ ^self checkForExistingModule: id module directory: id directory. |
|
356 |
||
357 |
"Created: / 09-07-2011 / 14:32:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
358 |
! |
|
359 |
||
360 |
managerTypeName |
|
361 |
^ 'Mercurial' |
|
362 |
||
363 |
"Created: / 16-08-2006 / 11:05:56 / cg" |
|
364 |
! |
|
365 |
||
366 |
nameOfVersionMethodForExtensions |
|
367 |
^ #'extensionsVersion_HG' |
|
368 |
||
369 |
"Modified: / 14-01-2012 / 22:01:19 / cg" |
|
370 |
! |
|
371 |
||
372 |
nameOfVersionMethodInClasses |
|
373 |
^ #'version_HG' |
|
374 |
||
375 |
"Modified: / 14-01-2012 / 22:01:29 / cg" |
|
376 |
! |
|
377 |
||
378 |
settingsApplicationClass |
|
379 |
"link to my settings application (needed for the settings dialog" |
|
380 |
||
381 |
^ MercurialSourceCodeManagementSettingsAppl |
|
382 |
||
383 |
"Created: / 19-04-2011 / 12:43:29 / cg" |
|
384 |
"Modified: / 14-01-2012 / 22:01:36 / cg" |
|
385 |
! ! |
|
386 |
||
387 |
!MercurialSourceCodeManager class methodsFor:'saving'! |
|
388 |
||
389 |
savePreferencesOn:aStream |
|
390 |
aStream nextPutLine:'MercurialSourceCodeManager notNil ifTrue:['. |
|
391 |
self repositoryInfoPerModule notEmptyOrNil ifTrue:[ |
|
392 |
aStream nextPutLine:' MercurialSourceCodeManager repositoryInfoPerModule:' , self repositoryInfoPerModule storeString , '.'. |
|
393 |
]. |
|
394 |
HGExecutable notNil ifTrue:[ |
|
395 |
aStream nextPutLine:' MercurialSourceCodeManager hgExecutable:' , HGExecutable storeString , '.'. |
|
396 |
]. |
|
397 |
(Smalltalk at:#SourceCodeManager) == self ifTrue:[ |
|
398 |
aStream nextPutLine:' Smalltalk at:#SourceCodeManager put: MercurialSourceCodeManager.'. |
|
399 |
aStream nextPutLine:' MercurialSourceCodeManager initializeForRepository:' , self repositoryName storeString , '.'. |
|
400 |
] ifFalse:[ |
|
401 |
aStream nextPutLine:' MercurialSourceCodeManager repositoryName:' , self repositoryName storeString , '.'. |
|
402 |
]. |
|
403 |
aStream nextPutLine:'].'. |
|
404 |
||
405 |
"Created: / 09-11-2006 / 15:09:25 / cg" |
|
406 |
"Modified: / 14-01-2012 / 22:03:40 / cg" |
|
407 |
! ! |
|
408 |
||
409 |
!MercurialSourceCodeManager class methodsFor:'testing'! |
|
410 |
||
411 |
isMercurial |
|
412 |
^ true |
|
413 |
||
414 |
"Created: / 14-01-2012 / 21:54:04 / cg" |
|
415 |
! ! |
|
416 |
||
417 |
!MercurialSourceCodeManager class methodsFor:'documentation'! |
|
418 |
||
419 |
version |
|
3037 | 420 |
^ '$Header: /cvs/stx/stx/libbasic3/MercurialSourceCodeManager.st,v 1.5 2012/03/20 18:06:01 cg Exp $' |
2722 | 421 |
! |
422 |
||
423 |
version_CVS |
|
3037 | 424 |
^ '§Header: /cvs/stx/stx/libbasic3/MercurialSourceCodeManager.st,v 1.5 2012/03/20 18:06:01 cg Exp §' |
3012 | 425 |
! |
426 |
||
427 |
version_SVN |
|
3042
48e76977cdc3
Added info-record processing support into changeset reader
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
3037
diff
changeset
|
428 |
^ '$Id: MercurialSourceCodeManager.st 1909 2012-03-31 00:14:49Z vranyj1 $' |
2722 | 429 |
! ! |
430 |
||
3012 | 431 |
MercurialSourceCodeManager initialize! |