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