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