2848
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2012 eXept Software AG
|
|
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 |
SourceCodeManagerUtilities subclass:#SourceCodeManagerUtilitiesForContainerBasedManagers
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-SourceCodeManagement'
|
|
19 |
!
|
|
20 |
|
|
21 |
!SourceCodeManagerUtilitiesForContainerBasedManagers class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
|
25 |
COPYRIGHT (c) 2012 eXept Software AG
|
|
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 |
!SourceCodeManagerUtilitiesForContainerBasedManagers methodsFor:'utilities-cvs'!
|
|
38 |
|
|
39 |
checkinBuildSupportFilesForPackage:packageID
|
|
40 |
|anyFailure module directory mgr defClass |
|
|
41 |
|
|
42 |
mgr := self sourceCodeManagerFor: packageID.
|
|
43 |
defClass := ProjectDefinition definitionClassForPackage: packageID.
|
|
44 |
|
|
45 |
defClass validateDescription.
|
|
46 |
|
|
47 |
anyFailure := false.
|
|
48 |
|
|
49 |
module := packageID asPackageId module.
|
|
50 |
directory := packageID asPackageId directory.
|
|
51 |
|
|
52 |
self activityNotification:(resources string:'checking in build-support files...').
|
|
53 |
(mgr checkForExistingModule:module directory:directory) ifFalse:[
|
|
54 |
mgr createModule:module directory:directory
|
|
55 |
].
|
|
56 |
|
|
57 |
defClass forEachFileNameAndGeneratedContentsDo:[:fileName :fileContents |
|
|
58 |
|realFileName realDirectory|
|
|
59 |
|
|
60 |
"/ care for subdirectories
|
|
61 |
(fileName includes:$/) ifTrue:[
|
|
62 |
realDirectory := (directory asFilename construct:(fileName asFilename directoryName)) name.
|
|
63 |
realFileName := fileName asFilename baseName.
|
|
64 |
] ifFalse:[
|
|
65 |
realDirectory := directory.
|
|
66 |
realFileName := fileName.
|
|
67 |
].
|
|
68 |
realDirectory := realDirectory replaceAll:$\ with:$/.
|
|
69 |
|
|
70 |
self activityNotification:(resources string:'checking in %1...' with:realFileName).
|
|
71 |
|
|
72 |
UserInformation
|
|
73 |
handle:[:ex | Transcript showCR:ex description ]
|
|
74 |
do:[
|
|
75 |
(mgr isContainerBased
|
|
76 |
and:[
|
|
77 |
(mgr checkForExistingContainer:realFileName inModule:module directory:realDirectory) not
|
|
78 |
]) ifTrue:[
|
|
79 |
realDirectory ~= directory ifTrue:[
|
|
80 |
(mgr checkForExistingModule:module directory:realDirectory) ifFalse:[
|
|
81 |
mgr createModule:module directory:realDirectory
|
|
82 |
].
|
|
83 |
].
|
|
84 |
(mgr
|
|
85 |
createContainerForText:fileContents
|
|
86 |
inModule:module
|
|
87 |
package:realDirectory
|
|
88 |
container:realFileName)
|
|
89 |
ifFalse:[
|
|
90 |
Dialog warn:(resources
|
|
91 |
stringWithCRs:'Cannot create new container: ''%3'' (in %1:%2)'
|
|
92 |
with:module
|
|
93 |
with:realDirectory
|
|
94 |
with:realFileName)
|
|
95 |
].
|
|
96 |
] ifFalse:[
|
|
97 |
(mgr
|
|
98 |
checkin:realFileName
|
|
99 |
text:fileContents
|
|
100 |
directory:realDirectory
|
|
101 |
module:module
|
|
102 |
logMessage:'automatically generated by browser'
|
|
103 |
force:false)
|
|
104 |
ifFalse:[
|
|
105 |
Transcript showCR:'checkin of ' , realFileName , ' failed'.
|
|
106 |
anyFailure := true.
|
|
107 |
].
|
|
108 |
].
|
|
109 |
].
|
|
110 |
].
|
|
111 |
|
|
112 |
defClass instAndClassMethodsDo:[:m | m package:defClass package].
|
|
113 |
|
|
114 |
self
|
|
115 |
checkinClasses:(Array with:defClass)
|
|
116 |
withInfo:'automatic checkIn'
|
|
117 |
withCheck:false.
|
|
118 |
|
|
119 |
|
|
120 |
self activityNotification:nil.
|
|
121 |
|
|
122 |
anyFailure ifTrue:[
|
|
123 |
self warn:'Checkin failed - see Transcript.'.
|
|
124 |
self activityNotification:'Checkin of build-support files failed - see Transcript.'.
|
|
125 |
] ifFalse:[
|
|
126 |
self activityNotification:'Build-support files checked into the repository.'.
|
|
127 |
].
|
|
128 |
|
|
129 |
"Created: / 09-08-2006 / 18:59:42 / fm"
|
|
130 |
"Modified: / 12-10-2011 / 11:36:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
131 |
"Modified: / 25-07-2012 / 14:27:30 / cg"
|
|
132 |
"Modified (format): / 25-07-2012 / 22:25:48 / cg"
|
|
133 |
!
|
|
134 |
|
|
135 |
checkinClass:aClass
|
|
136 |
"check a class into the source repository.
|
|
137 |
Asks interactively for a log-message."
|
|
138 |
|
|
139 |
^ self checkinClass:aClass withInfo:nil
|
|
140 |
!
|
|
141 |
|
|
142 |
checkinClass:aClass withInfo:aLogInfoOrNil
|
|
143 |
"check a class into the source repository.
|
|
144 |
If the argument, aLogInfoOrNil isNil, ask interactively for a log-message."
|
|
145 |
|
|
146 |
^ self checkinClass:aClass withInfo:aLogInfoOrNil withCheck:true
|
|
147 |
!
|
|
148 |
|
|
149 |
checkinClass:aClass withInfo:aLogInfoOrNil withCheck:doCheckClass
|
|
150 |
"check a class into the source repository.
|
|
151 |
If the argument, aLogInfoOrNil isNil, ask interactively for log-message.
|
|
152 |
If doCheckClass is true, the class is checked for send of halts etc."
|
|
153 |
|
|
154 |
^ self
|
|
155 |
checkinClass:aClass
|
|
156 |
withInfo:aLogInfoOrNil
|
|
157 |
withCheck:doCheckClass
|
|
158 |
usingManager:(self sourceCodeManagerFor:aClass)
|
|
159 |
|
|
160 |
"Modified: / 21-12-2011 / 18:19:55 / cg"
|
|
161 |
!
|
|
162 |
|
|
163 |
checkinClass:aClass withInfo:aLogInfoOrNil withCheck:doCheckClass usingManager:managerOrNil
|
|
164 |
"check a class into the source repository.
|
|
165 |
If the argument, aLogInfoOrNil isNil, ask interactively for log-message.
|
|
166 |
If doCheckClass is true, the class is checked for send of halts etc."
|
|
167 |
|
2946
|
168 |
|logMessage checkinInfo mgr pri|
|
2848
|
169 |
|
|
170 |
aClass isLoaded ifFalse:[
|
|
171 |
self information:(resources string:'Cannot checkin unloaded classes (%1)' with:aClass name).
|
|
172 |
^ false.
|
|
173 |
].
|
|
174 |
|
|
175 |
mgr := managerOrNil.
|
|
176 |
mgr isNil ifTrue:[
|
|
177 |
mgr := self sourceCodeManagerFor:aClass.
|
|
178 |
mgr isNil ifTrue:[
|
|
179 |
^ false
|
|
180 |
]
|
|
181 |
].
|
|
182 |
|
|
183 |
self ensureCorrectVersionMethodsInClass:aClass usingManager:mgr.
|
|
184 |
mgr supportsCheckinLogMessages ifTrue:[
|
|
185 |
(self
|
|
186 |
getLogMessageForClassCheckinTakingDefaultsFromPreviousLogInfo:aLogInfoOrNil
|
|
187 |
forClass:aClass
|
|
188 |
valuesInto:[:logMessageRet :checkinInfoRet |
|
|
189 |
logMessage := logMessageRet.
|
|
190 |
checkinInfo := checkinInfoRet.
|
|
191 |
]
|
|
192 |
) ifFalse:[^ false].
|
|
193 |
].
|
|
194 |
|
|
195 |
(self classIsNotYetInRepository:aClass withManager:mgr) ifTrue:[
|
|
196 |
(self createSourceContainerForClass:aClass usingManager:mgr) ifFalse:[
|
|
197 |
"/ self warn:'did not create a container for ''' , aClass name , ''''.
|
|
198 |
^ false
|
|
199 |
].
|
|
200 |
^ true.
|
|
201 |
].
|
|
202 |
|
|
203 |
self activityNotification:(resources string:'checking in %1' with:aClass name).
|
|
204 |
pri := Processor activePriority.
|
|
205 |
Processor activeProcess withPriority:pri-1 to:pri
|
|
206 |
do:[
|
|
207 |
|revision aborted freshCreated|
|
|
208 |
|
|
209 |
freshCreated := false.
|
|
210 |
revision := aClass revision.
|
|
211 |
revision isNil ifTrue:[
|
|
212 |
mgr isContainerBased ifTrue:[
|
|
213 |
"/ mhmh - check if it has a container.
|
|
214 |
(mgr checkForExistingContainerForClass:aClass) ifFalse:[
|
|
215 |
(self createSourceContainerForClass:aClass usingManager:mgr) ifFalse:[
|
|
216 |
self warn:'Did not create/change repository container for ''' , aClass name allBold , ''''.
|
|
217 |
^ false.
|
|
218 |
].
|
|
219 |
freshCreated := true.
|
|
220 |
]
|
|
221 |
]
|
|
222 |
].
|
|
223 |
|
|
224 |
doCheckClass value ifTrue:[
|
|
225 |
"/ check if the class contains halts, error-sends etc.
|
|
226 |
(self checkAndWarnAboutBadMessagesInClass:aClass checkAgainHolder:doCheckClass) ifFalse:[
|
|
227 |
^ false
|
|
228 |
].
|
|
229 |
].
|
|
230 |
|
|
231 |
freshCreated ifFalse:[
|
|
232 |
aborted := false.
|
|
233 |
AbortOperationRequest handle:[:ex |
|
|
234 |
aborted := true.
|
|
235 |
ex return.
|
|
236 |
] do:[
|
|
237 |
|checkinState cause|
|
|
238 |
checkinState := false.
|
|
239 |
cause := ''.
|
|
240 |
[
|
|
241 |
checkinState := mgr checkinClass:aClass logMessage:logMessage
|
|
242 |
] on:SourceCodeManagerError do:[:ex|
|
|
243 |
cause := ex description.
|
|
244 |
ex proceed.
|
|
245 |
].
|
|
246 |
|
|
247 |
checkinState ifFalse:[
|
|
248 |
Transcript showCR:'checkin of ''' , aClass name , ''' failed - ', cause.
|
|
249 |
self warn:(resources stringWithCRs:'Checkin of "%1" failed\\' with:aClass name allBold),cause.
|
|
250 |
^ false.
|
|
251 |
].
|
|
252 |
checkinInfo notNil ifTrue:[
|
|
253 |
checkinInfo isStable ifTrue:[
|
|
254 |
"set stable tag for class that has been checked in"
|
|
255 |
self tagClass:aClass as:#stable.
|
|
256 |
].
|
|
257 |
checkinInfo tagIt ifTrue:[
|
|
258 |
"set an additional tag for class that has been checked in"
|
|
259 |
self tagClass:aClass as:(checkinInfo tag).
|
|
260 |
].
|
|
261 |
].
|
|
262 |
].
|
|
263 |
aborted ifTrue:[
|
|
264 |
Transcript showCR:'Checkin of ''' , aClass name , ''' aborted'.
|
|
265 |
|
|
266 |
AbortAllOperationWantedQuery query ifTrue:[
|
|
267 |
(Dialog
|
|
268 |
confirm:(resources stringWithCRs:'Checkin of "%1" aborted.\\Cancel all ?' with:aClass name)
|
|
269 |
default:false)
|
|
270 |
ifTrue:[
|
|
271 |
AbortAllOperationRequest raise.
|
|
272 |
]
|
|
273 |
].
|
|
274 |
^ false.
|
|
275 |
].
|
|
276 |
].
|
|
277 |
].
|
|
278 |
^ true
|
|
279 |
|
|
280 |
"Created: / 21-12-2011 / 18:19:14 / cg"
|
|
281 |
!
|
|
282 |
|
|
283 |
checkinClasses:aCollectionOfClass
|
|
284 |
"check a collection of classes into the source repository.
|
|
285 |
Asks interactively for log-message."
|
|
286 |
|
|
287 |
^ self checkinClasses:aCollectionOfClass withInfo:nil
|
|
288 |
!
|
|
289 |
|
|
290 |
checkinClasses:aCollectionOfClasses withInfo:aLogInfoOrNil
|
|
291 |
"check a bunch of classes into the source repository.
|
|
292 |
If the argument, aLogInfoOrNil isNil, ask interactively for log-message."
|
|
293 |
|
|
294 |
^ self
|
|
295 |
checkinClasses:aCollectionOfClasses
|
|
296 |
withInfo:aLogInfoOrNil
|
|
297 |
withCheck:(UserPreferences current at:#checkClassesWhenCheckingIn ifAbsent:true)
|
|
298 |
!
|
|
299 |
|
|
300 |
checkinClasses:aCollectionOfClasses withInfo:aLogInfoOrStringNil withCheck:doCheckClasses
|
|
301 |
"check a bunch of classes into the source repository.
|
|
302 |
If the argument, aLogInfoOrStringNil isNil, ask interactively for log-message."
|
|
303 |
|
|
304 |
self checkinClasses:aCollectionOfClasses withInfo:aLogInfoOrStringNil withCheck:doCheckClasses usingManager:nil
|
|
305 |
|
|
306 |
"Modified: / 21-12-2011 / 18:24:47 / cg"
|
|
307 |
!
|
|
308 |
|
|
309 |
checkinClasses:aCollectionOfClasses withInfo:aLogInfoOrStringNil withCheck:doCheckClasses usingManager:aManagerOrNil
|
|
310 |
"check a bunch of classes into the source repository.
|
|
311 |
If the argument, aLogInfoOrStringNil isNil, ask interactively for log-message."
|
|
312 |
|
2946
|
313 |
|classes allClasses checkinInfoOrString yesOrNoToAll unchangedClasses|
|
2848
|
314 |
|
|
315 |
"/ ignore private classes
|
|
316 |
classes := aCollectionOfClasses select:[:aClass | aClass owningClass isNil].
|
|
317 |
classes isEmpty ifTrue:[
|
|
318 |
self information:'Only private classes given - nothing checked in.'.
|
|
319 |
^ self
|
|
320 |
].
|
|
321 |
classes := classes select:[:aClass | aClass isLoaded].
|
|
322 |
classes isEmpty ifTrue:[
|
|
323 |
self information:'Only unloaded classes given - nothing checked in.'.
|
|
324 |
^ self
|
|
325 |
].
|
|
326 |
|
|
327 |
classes size == 1 ifTrue:[
|
|
328 |
^ self checkinClass:classes first withInfo:aLogInfoOrStringNil withCheck:doCheckClasses usingManager:aManagerOrNil.
|
|
329 |
].
|
|
330 |
|
|
331 |
"ask once, for all classes"
|
|
332 |
aLogInfoOrStringNil isNil ifTrue:[
|
|
333 |
checkinInfoOrString := self
|
|
334 |
getCheckinInfoFor:(resources string:'%1 classes to checkin' with:aCollectionOfClasses size)
|
|
335 |
initialAnswer:nil
|
|
336 |
withQuickOption:true.
|
|
337 |
checkinInfoOrString isNil ifTrue:[^ self].
|
|
338 |
] ifFalse:[
|
|
339 |
checkinInfoOrString := aLogInfoOrStringNil.
|
|
340 |
].
|
|
341 |
|
|
342 |
allClasses := classes.
|
|
343 |
checkinInfoOrString quickCheckIn ifTrue:[
|
|
344 |
classes := classes select:[:aClass | aClass hasUnsavedChanges].
|
|
345 |
classes isEmpty ifTrue:[ Dialog information:'no changes to checkin (quickCheckIn)' ]
|
|
346 |
].
|
|
347 |
|
|
348 |
"abortAll is handled, and also asked for here!!"
|
|
349 |
AbortAllOperationRequest handleAndAnswerQueryIn:[
|
|
350 |
classes notEmpty ifTrue:[
|
|
351 |
self yesToAllNotification handle:[:ex |
|
|
352 |
yesOrNoToAll := ex parameter.
|
|
353 |
ex proceed
|
|
354 |
] do:[
|
|
355 |
self yesToAllQuery handle:[:ex |
|
|
356 |
ex proceedWith:yesOrNoToAll
|
|
357 |
] do:[
|
|
358 |
classes do:[:aClass |
|
|
359 |
self activityNotification:(resources string:'checking in %1' with:aClass name).
|
|
360 |
"/ ca does not want boxes to pop up all over ...
|
|
361 |
UserInformation handle:[:ex |
|
|
362 |
Transcript showCR:ex description.
|
|
363 |
ex proceed.
|
|
364 |
] do:[
|
|
365 |
AbortOperationRequest catch:[
|
|
366 |
self
|
|
367 |
checkinClass:aClass
|
|
368 |
withInfo:checkinInfoOrString
|
|
369 |
withCheck:doCheckClasses
|
|
370 |
usingManager:aManagerOrNil
|
|
371 |
]
|
|
372 |
].
|
|
373 |
].
|
|
374 |
]
|
|
375 |
].
|
|
376 |
].
|
|
377 |
|
|
378 |
(checkinInfoOrString isStable or:[checkinInfoOrString tagIt])
|
|
379 |
ifTrue:[
|
|
380 |
"/mhmh - but tag should be set on all (even unchanged ones)
|
|
381 |
"/ the other onces have already been tagged
|
|
382 |
unchangedClasses := allClasses select:[:eachClass | (classes includes:eachClass) not].
|
|
383 |
|
|
384 |
"mhmh - could still have to tag them"
|
|
385 |
checkinInfoOrString isStable ifTrue:[
|
|
386 |
unchangedClasses do:[:eachClass |
|
|
387 |
self tagClass:eachClass as:#stable.
|
|
388 |
].
|
|
389 |
].
|
|
390 |
checkinInfoOrString tagIt ifTrue:[
|
|
391 |
unchangedClasses do:[:eachClass |
|
|
392 |
self tagClass:eachClass as:(checkinInfoOrString tag).
|
|
393 |
].
|
|
394 |
].
|
|
395 |
].
|
|
396 |
].
|
|
397 |
|
|
398 |
"Created: / 21-12-2011 / 18:24:25 / cg"
|
|
399 |
!
|
|
400 |
|
|
401 |
checkinExtensionMethods:aCollectionOfMethods forPackage:aPackageID withInfo:aLogInfoOrStringOrNil
|
|
402 |
"checkin a projects extensions into the source repository.
|
|
403 |
If the argument, aLogInfoOrStringOrNil isNil, ask interactively for log-message."
|
|
404 |
|
2946
|
405 |
|logMessage checkinInfo mgr pri module directory containerFileName methodSource|
|
2848
|
406 |
|
|
407 |
"/ the following is wrong - must ask the projectDefinition !!
|
|
408 |
aPackageID asPackageId projectDefinitionClass notNil ifTrue:[
|
|
409 |
mgr := self sourceCodeManagerFor:aPackageID asPackageId projectDefinitionClass.
|
|
410 |
] ifFalse:[
|
|
411 |
mgr := self sourceCodeManagerFor:aCollectionOfMethods first mclass.
|
|
412 |
].
|
|
413 |
mgr isNil ifTrue:[ ^ false ].
|
|
414 |
|
|
415 |
module := aPackageID asPackageId module.
|
|
416 |
directory := aPackageID asPackageId directory.
|
|
417 |
containerFileName := self nameOfExtensionsContainer.
|
|
418 |
|
|
419 |
aLogInfoOrStringOrNil isNil ifTrue:[
|
|
420 |
checkinInfo := self getCheckinInfoFor:containerFileName allBold initialAnswer:nil.
|
|
421 |
checkinInfo isNil ifTrue:[^ false].
|
|
422 |
logMessage := checkinInfo logMessage.
|
|
423 |
] ifFalse:[
|
|
424 |
aLogInfoOrStringOrNil isString ifTrue:[
|
|
425 |
logMessage := aLogInfoOrStringOrNil
|
|
426 |
] ifFalse:[
|
|
427 |
checkinInfo := aLogInfoOrStringOrNil.
|
|
428 |
logMessage := checkinInfo logMessage.
|
|
429 |
].
|
|
430 |
].
|
|
431 |
|
|
432 |
(mgr checkForExistingContainer:containerFileName inModule:module directory:directory) ifFalse:[
|
|
433 |
(self checkForExistingModule:module usingManager:mgr allowCreate:true) ifFalse:[^ false].
|
|
434 |
LastModule := module.
|
|
435 |
|
|
436 |
(self checkForExistingModule:module directory:directory usingManager:mgr allowCreate:true) ifFalse:[^ false].
|
|
437 |
LastPackage := directory.
|
|
438 |
|
|
439 |
(self checkForExistingModule:module directory:directory container:containerFileName usingManager:mgr allowCreate:true) ifFalse:[^ false].
|
|
440 |
].
|
|
441 |
|
|
442 |
self activityNotification:(resources string:'Checking in %1' with:containerFileName).
|
|
443 |
pri := Processor activePriority.
|
|
444 |
Processor activeProcess
|
|
445 |
withPriority:pri-1 to:pri
|
|
446 |
do:[
|
|
447 |
methodSource := self sourceCodeForExtensions:aCollectionOfMethods package:aPackageID forManager:mgr.
|
|
448 |
|
|
449 |
UserInformation handle:[:ex |
|
|
450 |
Transcript showCR:ex description.
|
|
451 |
ex proceed.
|
|
452 |
] do:[
|
|
453 |
Transcript showCR:('checking in ',containerFileName,' ...').
|
|
454 |
(mgr
|
|
455 |
checkin:containerFileName
|
|
456 |
text:methodSource
|
|
457 |
directory:directory
|
|
458 |
module:module
|
|
459 |
logMessage:logMessage
|
|
460 |
force:false)
|
|
461 |
ifFalse:[
|
|
462 |
Transcript showCR:'Checkin of ''' , containerFileName , ''' failed'.
|
|
463 |
self warn:'Checkin of ''' , containerFileName allBold , ''' failed'.
|
|
464 |
^ false.
|
|
465 |
].
|
|
466 |
checkinInfo notNil ifTrue:[
|
|
467 |
|path|
|
|
468 |
|
|
469 |
path := (module, '/', directory, '/', containerFileName).
|
|
470 |
checkinInfo isStable ifTrue:[
|
|
471 |
"set stable tag for class that has been checked in"
|
|
472 |
self tagPath:path as:#stable usingManager:mgr.
|
|
473 |
].
|
|
474 |
checkinInfo tagIt ifTrue:[
|
|
475 |
"set an additional tag for class that has been checked in"
|
|
476 |
self tagPath:path as:(checkinInfo tag) usingManager:mgr.
|
|
477 |
].
|
|
478 |
].
|
|
479 |
mgr postCheckInExtensionsForPackage:aPackageID
|
|
480 |
].
|
|
481 |
].
|
|
482 |
^ true
|
|
483 |
|
|
484 |
"Modified: / 25-07-2012 / 18:38:40 / cg"
|
|
485 |
!
|
|
486 |
|
|
487 |
checkinPackage:packageToCheckIn classes:doClasses extensions:doExtensions buildSupport:doBuild askForMethodsInOtherPackages:askForMethodsInOtherPackages
|
|
488 |
|mgr classes classesToCheckIn methodsToCheckIn
|
|
489 |
methodsInOtherPackages looseMethods otherPackages
|
|
490 |
msg classesInChangeSet checkinInfo originalCheckinInfo classesToTag|
|
|
491 |
|
|
492 |
mgr := self sourceCodeManagerFor: packageToCheckIn.
|
|
493 |
classes := Smalltalk allClasses.
|
|
494 |
|
|
495 |
classesToCheckIn := IdentitySet new.
|
|
496 |
methodsToCheckIn := IdentitySet new.
|
|
497 |
methodsInOtherPackages := IdentitySet new.
|
|
498 |
looseMethods := IdentitySet new.
|
|
499 |
|
|
500 |
"/ classes ...
|
|
501 |
classes do:[:aClass | |owner classPackage|
|
|
502 |
(owner := aClass owningClass) notNil ifTrue:[
|
|
503 |
classPackage := aClass topOwningClass package
|
|
504 |
] ifFalse:[
|
|
505 |
classPackage := aClass package
|
|
506 |
].
|
|
507 |
(classPackage = packageToCheckIn) ifTrue:[
|
|
508 |
classesToCheckIn add:aClass.
|
|
509 |
].
|
|
510 |
].
|
|
511 |
|
|
512 |
"/ cg: O(n^2) algorithm
|
|
513 |
"/ classesInChangeSet := classesToCheckIn select:[:cls | cls hasUnsavedChanges].
|
|
514 |
"/ replaced by: O(n) algorithm
|
2906
|
515 |
classesInChangeSet := ChangeSet current selectClassesForWhichIncludesChangeForClassOrMetaclassOrPrivateClassFrom:classesToCheckIn.
|
2848
|
516 |
|
|
517 |
"/ individual methods ...
|
|
518 |
classes do:[:aClass |
|
|
519 |
aClass isMeta ifFalse:[
|
|
520 |
"/ ... whose class is not in the chechIn-set
|
|
521 |
(classesToCheckIn includes:aClass) ifFalse:[
|
|
522 |
aClass instAndClassSelectorsAndMethodsDo:[:sel :mthd |
|
|
523 |
"/ methods in this project ...
|
|
524 |
(mthd package = packageToCheckIn) ifTrue:[
|
|
525 |
methodsToCheckIn add:mthd
|
|
526 |
]
|
|
527 |
]
|
|
528 |
].
|
|
529 |
].
|
|
530 |
].
|
|
531 |
|
|
532 |
doExtensions ifTrue:[
|
|
533 |
methodsToCheckIn notEmpty ifTrue:[
|
|
534 |
doClasses ifTrue:[
|
|
535 |
msg := '%1 classes (%4 changed) '.
|
|
536 |
] ifFalse:[
|
|
537 |
msg := ''.
|
|
538 |
].
|
|
539 |
doExtensions ifTrue:[
|
|
540 |
doClasses ifTrue:[
|
|
541 |
msg := msg , 'and '.
|
|
542 |
].
|
|
543 |
msg := msg , '%2 extensions '.
|
|
544 |
].
|
|
545 |
msg := msg , 'of project "%3"'.
|
|
546 |
|
|
547 |
checkinInfo := self
|
|
548 |
getCheckinInfoFor:(msg
|
|
549 |
bindWith:classesToCheckIn size
|
|
550 |
with:methodsToCheckIn size
|
|
551 |
with:packageToCheckIn allBold
|
|
552 |
with:classesInChangeSet size)
|
|
553 |
initialAnswer:nil
|
|
554 |
withQuickOption:(classesToCheckIn size > 0).
|
|
555 |
checkinInfo isNil ifTrue:[
|
|
556 |
^ self.
|
|
557 |
].
|
|
558 |
(self
|
|
559 |
checkinExtensionMethods:methodsToCheckIn
|
|
560 |
forPackage:packageToCheckIn
|
|
561 |
withInfo:checkinInfo)
|
|
562 |
ifFalse:[
|
|
563 |
Dialog warn:(resources string:'Could not check in extensions for project %1' with:packageToCheckIn).
|
|
564 |
^ self.
|
|
565 |
]
|
|
566 |
] ifFalse:[
|
|
567 |
"/ there may have been extension-methods previously - if so, remove them
|
|
568 |
(mgr
|
|
569 |
checkForExistingContainer:'extensions.st' inPackage:packageToCheckIn)
|
|
570 |
ifTrue:[
|
|
571 |
"/ self halt.
|
|
572 |
(self
|
|
573 |
checkinExtensionMethods:#()
|
|
574 |
forPackage:packageToCheckIn
|
|
575 |
withInfo:'No extensions any more')
|
|
576 |
ifFalse:[
|
|
577 |
Dialog warn:(resources string:'Could not check in extensions for project %1' with:packageToCheckIn).
|
|
578 |
^ self.
|
|
579 |
]
|
|
580 |
]
|
|
581 |
].
|
|
582 |
].
|
|
583 |
|
|
584 |
checkinInfo isNil ifTrue:[
|
|
585 |
checkinInfo := self
|
|
586 |
getCheckinInfoFor:('%1 classes (%4 changed) and %2 extensions for project "%3"'
|
|
587 |
bindWith:classesToCheckIn size
|
|
588 |
with:methodsToCheckIn size
|
|
589 |
with:packageToCheckIn allBold
|
|
590 |
with:classesInChangeSet size)
|
|
591 |
initialAnswer:nil
|
|
592 |
withQuickOption:(classesToCheckIn size > 0).
|
|
593 |
checkinInfo isNil ifTrue:[
|
|
594 |
^ self.
|
|
595 |
].
|
|
596 |
].
|
|
597 |
|
|
598 |
checkinInfo quickCheckIn ifTrue:[
|
|
599 |
(checkinInfo isStable or:[checkinInfo tagIt]) ifTrue:[
|
|
600 |
classesToTag := classesToCheckIn.
|
|
601 |
originalCheckinInfo := checkinInfo.
|
|
602 |
checkinInfo := checkinInfo copy.
|
|
603 |
checkinInfo isStable:false.
|
|
604 |
checkinInfo tag:nil.
|
|
605 |
].
|
|
606 |
classesToCheckIn := classesInChangeSet.
|
|
607 |
].
|
|
608 |
|
|
609 |
"/ check if any of the classes contains methods for other packages ...
|
|
610 |
classesToCheckIn do:[:eachClass |
|
|
611 |
eachClass instAndClassMethodsDo:[:eachMethod |
|
|
612 |
|mPgk|
|
|
613 |
|
|
614 |
mPgk := eachMethod package.
|
|
615 |
(mPgk = packageToCheckIn) ifFalse:[
|
|
616 |
mPgk == PackageId noProjectID ifTrue:[
|
|
617 |
looseMethods add:eachMethod
|
|
618 |
] ifFalse:[
|
|
619 |
methodsInOtherPackages add:eachMethod
|
|
620 |
]
|
|
621 |
]
|
|
622 |
].
|
|
623 |
].
|
|
624 |
|
|
625 |
askForMethodsInOtherPackages ifTrue:[
|
|
626 |
methodsInOtherPackages notEmpty ifTrue:[
|
|
627 |
otherPackages := Set new.
|
|
628 |
methodsInOtherPackages do:[:eachMethod | otherPackages add:eachMethod package].
|
|
629 |
|
|
630 |
methodsInOtherPackages size == 1 ifTrue:[
|
|
631 |
msg := 'The ''%4'' method in ''%5'' is contained in the ''%2'' package.'.
|
|
632 |
msg := msg , '\\This method will remain in its package.'.
|
|
633 |
] ifFalse:[
|
|
634 |
otherPackages size == 1 ifTrue:[
|
|
635 |
msg := 'The %1 methods from the %2 package will remain in its package.'
|
|
636 |
] ifFalse:[
|
|
637 |
msg := 'The %1 methods from %3 other packages will remain in their packages.'
|
|
638 |
].
|
|
639 |
msg := msg , '\\Hint: if these are meant to belong to this package,'.
|
|
640 |
msg := msg , '\move them first, then repeat the checkin operation.'.
|
|
641 |
].
|
|
642 |
msg := msg withCRs.
|
|
643 |
msg := msg bindWith:methodsInOtherPackages size
|
|
644 |
with:otherPackages first allBold
|
|
645 |
with:otherPackages size
|
|
646 |
with:methodsInOtherPackages first selector allBold
|
|
647 |
with:methodsInOtherPackages first mclass name allBold.
|
|
648 |
(Dialog confirm:msg noLabel:(resources string:'Cancel')) ifFalse:[^ self].
|
|
649 |
].
|
|
650 |
].
|
|
651 |
|
|
652 |
doClasses ifTrue:[
|
|
653 |
classesToCheckIn notEmpty ifTrue:[
|
|
654 |
looseMethods notEmpty ifTrue:[
|
|
655 |
looseMethods size == 1 ifTrue:[
|
|
656 |
msg := 'The ''%2'' method in ''%3'' is unassigned (loose).'.
|
|
657 |
msg := msg , '\\If you proceed, this method will be moved to the ''%4'' package'.
|
|
658 |
msg := msg , '\\Hint: if this is meant to be an extension of another package,'.
|
|
659 |
msg := msg , '\cancel and move it to the appropriate package first.'.
|
|
660 |
] ifFalse:[
|
|
661 |
msg := 'There are %1 unassigned (loose) methods in classes from this project.'.
|
|
662 |
msg := msg , '\\If you proceed, those will be moved to the ''%4'' package ?'.
|
|
663 |
msg := msg , '\\Hint: if these are meant to be extensions of another package,'.
|
|
664 |
msg := msg , '\cancel and move them to the appropriate package first.'.
|
|
665 |
].
|
|
666 |
doClasses ifTrue:[
|
|
667 |
msg := msg , '\\If you answer with "No" here, you will be asked for each class individually.'.
|
|
668 |
].
|
|
669 |
msg := msg withCRs.
|
|
670 |
msg := msg bindWith:looseMethods size
|
|
671 |
with:(looseMethods isEmpty ifTrue:[''] ifFalse:[looseMethods first selector allBold])
|
|
672 |
with:(looseMethods isEmpty ifTrue:[''] ifFalse:[looseMethods first mclass name allBold])
|
|
673 |
with:packageToCheckIn allBold.
|
|
674 |
(Dialog confirm:msg noLabel:(resources string:'Cancel')) ifFalse:[^ self].
|
|
675 |
|
|
676 |
looseMethods do:[:mthd |
|
|
677 |
mthd package:packageToCheckIn
|
|
678 |
].
|
|
679 |
].
|
|
680 |
self checkinClasses:classesToCheckIn withInfo:checkinInfo.
|
|
681 |
].
|
|
682 |
|
|
683 |
originalCheckinInfo notNil ifTrue:[
|
|
684 |
originalCheckinInfo isStable ifTrue:[
|
|
685 |
classesToTag do:[:eachClass |
|
|
686 |
self tagClass:eachClass as:#stable
|
|
687 |
].
|
|
688 |
].
|
|
689 |
originalCheckinInfo tagIt ifTrue:[
|
|
690 |
classesToTag do:[:eachClass |
|
|
691 |
self tagClass:eachClass as:(originalCheckinInfo tag)
|
|
692 |
].
|
|
693 |
].
|
|
694 |
].
|
|
695 |
].
|
|
696 |
|
|
697 |
doBuild ifTrue:[
|
|
698 |
self checkinBuildSupportFilesForPackage:packageToCheckIn
|
|
699 |
].
|
|
700 |
|
|
701 |
"Created: / 13-10-2011 / 11:15:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2906
|
702 |
"Modified: / 04-09-2012 / 14:05:36 / cg"
|
2848
|
703 |
! !
|
|
704 |
|
|
705 |
!SourceCodeManagerUtilitiesForContainerBasedManagers class methodsFor:'documentation'!
|
|
706 |
|
|
707 |
version
|
2946
|
708 |
^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilitiesForContainerBasedManagers.st,v 1.3 2012-10-30 14:34:22 cg Exp $'
|
2848
|
709 |
!
|
|
710 |
|
|
711 |
version_CVS
|
2946
|
712 |
^ '$Header: /cvs/stx/stx/libbasic3/SourceCodeManagerUtilitiesForContainerBasedManagers.st,v 1.3 2012-10-30 14:34:22 cg Exp $'
|
2848
|
713 |
! !
|