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