0
|
1 |
"
|
4
|
2 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
45
|
3 |
All Rights Reserved
|
0
|
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 |
|
45
|
13 |
'From Smalltalk/X, Version:2.10.3 on 26-sep-1994 at 1:19:22 pm'!
|
|
14 |
|
0
|
15 |
StandardSystemView subclass:#ChangesBrowser
|
45
|
16 |
instanceVariableNames:'changeListView codeView changeFileName changeChunks
|
|
17 |
changePositions changeClassNames changeHeaderLines anyChanges
|
|
18 |
changeNrShown changeNrProcessed fileBox skipSignal'
|
|
19 |
classVariableNames:''
|
|
20 |
poolDictionaries:''
|
|
21 |
category:'Interface-Browsers'
|
0
|
22 |
!
|
|
23 |
|
|
24 |
ChangesBrowser comment:'
|
4
|
25 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
45
|
26 |
All Rights Reserved
|
0
|
27 |
|
50
|
28 |
$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.18 1994-11-01 13:18:24 claus Exp $
|
29
|
29 |
'!
|
|
30 |
|
|
31 |
!ChangesBrowser class methodsFor:'documentation'!
|
|
32 |
|
|
33 |
copyright
|
|
34 |
"
|
|
35 |
COPYRIGHT (c) 1990 by Claus Gittinger
|
45
|
36 |
All Rights Reserved
|
0
|
37 |
|
29
|
38 |
This software is furnished under a license and may be used
|
|
39 |
only in accordance with the terms of that license and with the
|
|
40 |
inclusion of the above copyright notice. This software may not
|
|
41 |
be provided or otherwise made available to, or used by, any
|
|
42 |
other person. No title to or ownership of the software is
|
|
43 |
hereby transferred.
|
|
44 |
"
|
|
45 |
!
|
|
46 |
|
|
47 |
version
|
|
48 |
"
|
50
|
49 |
$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.18 1994-11-01 13:18:24 claus Exp $
|
31
|
50 |
"
|
29
|
51 |
!
|
|
52 |
|
|
53 |
documentation
|
|
54 |
"
|
|
55 |
this implements a browser for the changes-file.
|
|
56 |
See the extra document 'doc/misc/cbrowser.doc' for how to use this browser.
|
|
57 |
|
|
58 |
written jan 90 by claus
|
|
59 |
"
|
|
60 |
! !
|
0
|
61 |
|
45
|
62 |
!ChangesBrowser class methodsFor:'instance creation'!
|
|
63 |
|
|
64 |
new
|
|
65 |
"create a new changes browser"
|
|
66 |
|
|
67 |
^ super label:'Changes Browser'
|
|
68 |
icon:(Form fromFile:'CBrowser.xbm' resolution:100)
|
|
69 |
!
|
|
70 |
|
|
71 |
openOn:aFileName
|
|
72 |
"create c changes browser on a change file"
|
|
73 |
|
49
|
74 |
^ ((self new label:'Changes Browser: ', aFileName) changeFileName:aFileName) open
|
45
|
75 |
! !
|
|
76 |
|
0
|
77 |
!ChangesBrowser class methodsFor:'behavior'!
|
|
78 |
|
|
79 |
autoSelectNext
|
|
80 |
"returning true here, makes a Delete operation automatically
|
|
81 |
select the next change"
|
|
82 |
|
|
83 |
^ true
|
|
84 |
! !
|
|
85 |
|
45
|
86 |
!ChangesBrowser methodsFor:'initialize / release'!
|
|
87 |
|
|
88 |
initializeMiddleButtonMenu
|
|
89 |
|labels|
|
|
90 |
|
|
91 |
labels := resources array:#(
|
|
92 |
'apply change'
|
|
93 |
'apply changes to end'
|
|
94 |
'apply all changes'
|
|
95 |
'-'
|
|
96 |
'delete'
|
|
97 |
'delete to end'
|
|
98 |
'delete changes for this class to end'
|
|
99 |
'delete all changes for this class'
|
|
100 |
'-'
|
|
101 |
'update'
|
|
102 |
'compress'
|
|
103 |
'compare with current version'
|
|
104 |
'browse class'
|
|
105 |
'-'
|
|
106 |
'make change a patch'
|
|
107 |
"/ 'update sourcefile from change'
|
|
108 |
"/ '-'
|
|
109 |
'save change in file ...'
|
|
110 |
'save changes to end in file ...'
|
|
111 |
'save changes for this class to end in file ...'
|
|
112 |
'save all changes for this class in file ...'
|
|
113 |
'-'
|
|
114 |
'writeback changeFile').
|
0
|
115 |
|
45
|
116 |
changeListView
|
|
117 |
middleButtonMenu:(PopUpMenu
|
|
118 |
labels:labels
|
|
119 |
selectors:#(
|
|
120 |
doApply
|
|
121 |
doApplyRest
|
|
122 |
doApplyAll
|
|
123 |
nil
|
|
124 |
doDelete
|
|
125 |
doDeleteRest
|
|
126 |
doDeleteClassRest
|
|
127 |
doDeleteClassAll
|
|
128 |
nil
|
|
129 |
doUpdate
|
|
130 |
doCompress
|
|
131 |
doCompare
|
|
132 |
doBrowse
|
|
133 |
nil
|
|
134 |
doMakePatch
|
|
135 |
"/ doMakePermanent
|
|
136 |
"/ nil
|
|
137 |
doSave
|
|
138 |
doSaveRest
|
|
139 |
doSaveClassRest
|
|
140 |
doSaveClassAll
|
|
141 |
nil
|
|
142 |
doWriteBack)
|
|
143 |
receiver:self
|
|
144 |
for:changeListView)
|
0
|
145 |
!
|
|
146 |
|
|
147 |
initialize
|
|
148 |
|frame v|
|
|
149 |
|
|
150 |
super initialize.
|
|
151 |
|
|
152 |
changeFileName := 'changes'.
|
|
153 |
|
|
154 |
frame := VariableVerticalPanel origin:(0.0 @ 0.0)
|
45
|
155 |
corner:(1.0 @ 1.0)
|
|
156 |
borderWidth:0
|
|
157 |
in:self.
|
0
|
158 |
|
|
159 |
v := ScrollableView for:SelectionInListView in:frame.
|
|
160 |
v origin:(0.0 @ 0.0) corner:(1.0 @ 0.3).
|
|
161 |
changeListView := v scrolledView.
|
|
162 |
|
28
|
163 |
v := HVScrollableView for:CodeView miniScrollerH:true miniScrollerV:false in:frame.
|
0
|
164 |
v origin:(0.0 @ 0.3) corner:(1.0 @ 1.0).
|
|
165 |
codeView := v scrolledView.
|
33
|
166 |
codeView readOnly.
|
0
|
167 |
|
|
168 |
anyChanges := false.
|
28
|
169 |
ObjectMemory addDependent:self. "to get shutdown-update"
|
0
|
170 |
!
|
|
171 |
|
|
172 |
realize
|
|
173 |
super realize.
|
37
|
174 |
self readChangesFileInBackground:true.
|
28
|
175 |
self setChangeList.
|
15
|
176 |
changeListView action:[:lineNr | self changeSelection:lineNr].
|
|
177 |
self disableMenuEntries.
|
0
|
178 |
!
|
|
179 |
|
28
|
180 |
update:what
|
|
181 |
|box|
|
27
|
182 |
|
|
183 |
(what == #aboutToExit) ifTrue:[
|
45
|
184 |
"
|
|
185 |
smalltalk is about to shut down -
|
|
186 |
- if change list was modified, ask user and save if requested.
|
|
187 |
"
|
|
188 |
anyChanges ifTrue:[
|
|
189 |
shown ifFalse:[
|
|
190 |
self unrealize.
|
|
191 |
self realize
|
|
192 |
].
|
|
193 |
self raise.
|
28
|
194 |
|
45
|
195 |
box := YesNoBox new.
|
|
196 |
box title:(resources at:'ChangesBrowser:\changefile has not been updated from the modified changelist.\\Update before exiting ?') withCRs.
|
|
197 |
box noText:(resources at:'don''t update').
|
|
198 |
box okText:(resources at:'update').
|
|
199 |
box yesAction:[self writeBackChanges]
|
|
200 |
noAction:[].
|
|
201 |
box showAtPointer
|
|
202 |
].
|
|
203 |
^ self
|
27
|
204 |
].
|
|
205 |
super update:what
|
0
|
206 |
! !
|
|
207 |
|
28
|
208 |
!ChangesBrowser methodsFor:'termination'!
|
|
209 |
|
45
|
210 |
terminate
|
|
211 |
"window manager wants us to go away"
|
|
212 |
|
|
213 |
|box|
|
|
214 |
|
|
215 |
anyChanges ifTrue:[
|
|
216 |
box := OptionBox title:'' numberOfOptions:3.
|
|
217 |
box title:(resources at:'close ChangesBrowser.\\changefile has not been updated from the modified changelist.\\Update before closing ?') withCRs.
|
|
218 |
box buttonTitles:(resources array:#('abort' 'don''t update' 'update')).
|
|
219 |
box actions:(Array with:[^ self]
|
|
220 |
with:[self destroy]
|
|
221 |
with:[self writeBackChanges. self destroy]
|
|
222 |
).
|
|
223 |
box showAtPointer.
|
|
224 |
] ifFalse:[
|
|
225 |
self destroy
|
|
226 |
]
|
|
227 |
!
|
|
228 |
|
28
|
229 |
destroy
|
|
230 |
"destroy the receiver; make certain, that boxes are destroyed too"
|
|
231 |
|
|
232 |
ObjectMemory removeDependent:self.
|
|
233 |
fileBox notNil ifTrue:[fileBox destroy. fileBox := nil].
|
|
234 |
super destroy
|
|
235 |
!
|
|
236 |
|
|
237 |
saveAndTerminate
|
|
238 |
"update the changes file and quit.
|
|
239 |
Dont depend on this being sent, not all window managers
|
|
240 |
send it; instead, they simply destroy the view."
|
|
241 |
|
|
242 |
anyChanges ifTrue:[
|
45
|
243 |
self writeBackChanges.
|
28
|
244 |
].
|
|
245 |
self destroy
|
|
246 |
! !
|
|
247 |
|
0
|
248 |
!ChangesBrowser methodsFor:'private'!
|
|
249 |
|
|
250 |
streamForChange:changeNr
|
|
251 |
"answer a stream for change"
|
|
252 |
|
|
253 |
|aStream|
|
|
254 |
|
|
255 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
256 |
aStream isNil ifTrue:[^ nil].
|
|
257 |
aStream position:(changePositions at:changeNr).
|
|
258 |
^ aStream
|
|
259 |
!
|
|
260 |
|
45
|
261 |
enableMenuEntries
|
|
262 |
"enable all entries refering to a selected change"
|
|
263 |
|
|
264 |
#(doApply doApplyRest doDelete doDeleteRest doDeleteClassRest
|
|
265 |
doDeleteClassAll doCompare doMakePatch doSaveChangeInFile doMakePermanent
|
|
266 |
doSave doSaveRest doSaveClassAll doSaveClassRest doBrowse)
|
|
267 |
do:[:sel |
|
|
268 |
changeListView middleButtonMenu enable:sel
|
|
269 |
].
|
|
270 |
!
|
|
271 |
|
|
272 |
unselect
|
|
273 |
"common unselect"
|
|
274 |
|
|
275 |
changeListView deselect.
|
|
276 |
self disableMenuEntries
|
|
277 |
!
|
|
278 |
|
|
279 |
disableMenuEntries
|
|
280 |
"enable all entries refering to a selected change"
|
|
281 |
|
|
282 |
#(doApply doApplyRest doDelete doDeleteRest doDeleteClassRest
|
|
283 |
doDeleteClassAll doCompare doMakePatch doSaveChangeInFile doMakePermanent
|
|
284 |
doSave doSaveRest doSaveClassAll doSaveClassRest doBrowse)
|
|
285 |
do:[:sel |
|
|
286 |
changeListView middleButtonMenu disable:sel
|
|
287 |
].
|
|
288 |
!
|
|
289 |
|
0
|
290 |
clearCodeView
|
15
|
291 |
self unselect "changeListView deselect".
|
0
|
292 |
codeView contents:nil.
|
|
293 |
changeNrShown := nil
|
|
294 |
!
|
|
295 |
|
|
296 |
autoSelect:changeNr
|
|
297 |
self class autoSelectNext ifTrue:[
|
49
|
298 |
(changeNr <= changePositions size) ifTrue:[
|
45
|
299 |
self clearCodeView.
|
|
300 |
changeListView selection:changeNr.
|
|
301 |
self changeSelection:changeNr.
|
|
302 |
^ self
|
|
303 |
]
|
0
|
304 |
].
|
|
305 |
self clearCodeView
|
|
306 |
!
|
|
307 |
|
45
|
308 |
autoSelectOrEnd:changeNr
|
49
|
309 |
|last|
|
|
310 |
|
|
311 |
last := changePositions size.
|
|
312 |
changeNr < last ifTrue:[
|
45
|
313 |
self autoSelect:changeNr
|
|
314 |
] ifFalse:[
|
|
315 |
self clearCodeView.
|
49
|
316 |
changeListView selection:last .
|
|
317 |
self changeSelection:last .
|
0
|
318 |
]
|
|
319 |
!
|
|
320 |
|
50
|
321 |
contractClass:className selector:selector to:maxLen
|
|
322 |
|s l|
|
|
323 |
|
|
324 |
s := className , ' ', selector.
|
|
325 |
s size > maxLen ifTrue:[
|
|
326 |
l := maxLen - 1 - selector size max:20.
|
|
327 |
s := (className contractTo:l) , ' ' , selector.
|
|
328 |
|
|
329 |
s size > maxLen ifTrue:[
|
|
330 |
l := maxLen - 1 - className size max:20.
|
|
331 |
s := className , ' ', (selector contractTo:l).
|
|
332 |
|
|
333 |
s size > maxLen ifTrue:[
|
|
334 |
s := (className contractTo:(maxLen // 2 - 1)) , ' ' , (selector contractTo:maxLen // 2)
|
|
335 |
]
|
|
336 |
]
|
|
337 |
].
|
|
338 |
^ s
|
|
339 |
!
|
|
340 |
|
37
|
341 |
readChangesFileInBackground:inBackground
|
|
342 |
"read the changes file, create a list of header-lines (changeChunks)
|
|
343 |
and a list of chunk-positions (changePositions)"
|
|
344 |
|
49
|
345 |
|aStream index chunkText headerLine done sawExcla chunkPos excla
|
50
|
346 |
myProcess myPriority p sel cls text first category tabSpec entry
|
|
347 |
maxLen|
|
|
348 |
|
|
349 |
maxLen := 60.
|
0
|
350 |
|
|
351 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
352 |
aStream isNil ifTrue:[^ nil].
|
|
353 |
|
|
354 |
self withCursor:(Cursor read) do:[
|
49
|
355 |
tabSpec := TabulatorSpecification new.
|
|
356 |
tabSpec unit:#inch.
|
50
|
357 |
tabSpec positions:#(0 4.5 5.5 ).
|
49
|
358 |
" cls>>sel type info "
|
|
359 |
tabSpec align: #(#left #left #left).
|
|
360 |
|
45
|
361 |
"
|
|
362 |
this is a time consuming operation (especially, if reading an
|
|
363 |
NFS-mounted directory; therefore lower my priority ...
|
|
364 |
"
|
|
365 |
inBackground ifTrue:[
|
|
366 |
myProcess := Processor activeProcess.
|
|
367 |
myPriority := myProcess priority.
|
|
368 |
myProcess priority:(Processor userBackgroundPriority).
|
|
369 |
].
|
|
370 |
[
|
50
|
371 |
|entry changeString changeType line s l|
|
|
372 |
|
45
|
373 |
changeChunks := OrderedCollection new.
|
|
374 |
changeHeaderLines := OrderedCollection new.
|
|
375 |
changePositions := OrderedCollection new.
|
|
376 |
excla := aStream class chunkSeparator.
|
0
|
377 |
|
45
|
378 |
[aStream atEnd] whileFalse:[
|
|
379 |
"
|
|
380 |
get a chunk (separated by excla)
|
|
381 |
"
|
|
382 |
aStream skipSeparators.
|
|
383 |
chunkPos := aStream position.
|
|
384 |
sawExcla := aStream peekFor:excla.
|
|
385 |
chunkText := aStream nextChunk.
|
|
386 |
chunkText notNil ifTrue:[
|
|
387 |
"
|
|
388 |
only first line is saved in changeChunks ...
|
|
389 |
"
|
|
390 |
index := chunkText indexOf:(Character cr).
|
|
391 |
(index ~~ 0) ifTrue:[
|
|
392 |
chunkText := chunkText copyTo:(index - 1).
|
|
393 |
|
|
394 |
"take care for comment changes - must still be a
|
|
395 |
valid expression for classNameOfChange: to work"
|
|
396 |
|
|
397 |
(chunkText endsWith:'comment:''') ifTrue:[
|
|
398 |
chunkText := chunkText , '...'''
|
|
399 |
]
|
29
|
400 |
|
45
|
401 |
].
|
|
402 |
|
|
403 |
changeChunks add:chunkText.
|
|
404 |
changePositions add:chunkPos.
|
50
|
405 |
headerLine := nil.
|
29
|
406 |
|
45
|
407 |
sawExcla ifFalse:[
|
|
408 |
(chunkText startsWith:'''---- snap') ifFalse:[
|
49
|
409 |
headerLine := chunkText , ' (doIt)'.
|
50
|
410 |
|
|
411 |
entry := MultiColListEntry new.
|
|
412 |
|
|
413 |
changeType := '(doIt)'.
|
|
414 |
changeString := (chunkText contractTo:maxLen).
|
|
415 |
p := Parser parseExpression:chunkText.
|
|
416 |
(p notNil and:[p ~~ #Error]) ifTrue:[
|
|
417 |
sel := p selector.
|
|
418 |
(sel == #removeSelector:) ifTrue:[
|
|
419 |
p receiver isUnaryMessage ifTrue:[
|
|
420 |
cls := p receiver receiver name.
|
|
421 |
cls := cls , 'class'
|
|
422 |
] ifFalse:[
|
|
423 |
cls := p receiver name
|
|
424 |
].
|
|
425 |
sel := (p args at:1) evaluate.
|
|
426 |
changeType := '(remove)'.
|
|
427 |
changeString := self contractClass:cls selector:sel to:maxLen.
|
|
428 |
]
|
|
429 |
].
|
45
|
430 |
] ifTrue:[
|
|
431 |
headerLine := chunkText
|
|
432 |
].
|
|
433 |
] ifTrue:[
|
|
434 |
"
|
|
435 |
method definitions actually consist of
|
|
436 |
two (or more) chunks; skip next chunk(s)
|
|
437 |
up to an empty one.
|
|
438 |
The system only writes one chunk,
|
|
439 |
and we cannot handle more in this ChangesBrowser ....
|
|
440 |
"
|
|
441 |
cls := nil.
|
|
442 |
p := Parser parseExpression:chunkText.
|
37
|
443 |
|
45
|
444 |
(p notNil and:[p ~~ #Error]) ifTrue:[
|
|
445 |
sel := p selector.
|
|
446 |
(sel == #methodsFor:) ifTrue:[
|
|
447 |
p receiver isUnaryMessage ifTrue:[
|
|
448 |
cls := p receiver receiver name.
|
|
449 |
cls := cls , 'class'
|
|
450 |
] ifFalse:[
|
|
451 |
cls := p receiver name
|
|
452 |
].
|
50
|
453 |
category := (p args at:1) evaluate.
|
|
454 |
].
|
45
|
455 |
].
|
|
456 |
done := false.
|
|
457 |
first := true.
|
|
458 |
[done] whileFalse:[
|
|
459 |
text := aStream nextChunk.
|
|
460 |
text isNil ifTrue:[
|
|
461 |
done := true
|
|
462 |
] ifFalse:[
|
|
463 |
done := text isEmpty
|
|
464 |
].
|
|
465 |
done ifFalse:[
|
|
466 |
first ifFalse:[
|
|
467 |
Transcript showCr:'only one method per ''methodsFor:'' handled'.
|
|
468 |
] ifTrue:[
|
|
469 |
first := false.
|
|
470 |
"
|
|
471 |
try to find the selector
|
|
472 |
"
|
|
473 |
sel := nil.
|
|
474 |
cls notNil ifTrue:[
|
|
475 |
p := Parser
|
|
476 |
parseMethodSpecification:text
|
|
477 |
in:nil
|
|
478 |
ignoreErrors:true
|
|
479 |
ignoreWarnings:true.
|
|
480 |
(p notNil and:[p ~~ #Error]) ifTrue:[
|
|
481 |
sel := p selector.
|
|
482 |
]
|
|
483 |
].
|
50
|
484 |
|
|
485 |
entry := MultiColListEntry new.
|
|
486 |
sel isNil ifTrue:[
|
|
487 |
changeString := (chunkText contractTo:maxLen).
|
|
488 |
changeType := '(change)'.
|
|
489 |
] ifFalse:[
|
|
490 |
changeString := self contractClass:cls selector:sel to:maxLen.
|
|
491 |
changeType := '(method in: ''' , category , ''')'.
|
|
492 |
].
|
45
|
493 |
sel isNil ifTrue:[
|
49
|
494 |
headerLine := chunkText , ' (change)'.
|
45
|
495 |
] ifFalse:[
|
49
|
496 |
headerLine := cls , ' ' , sel , ' ' , '(change category: ''' , category , ''')'.
|
45
|
497 |
]
|
|
498 |
]
|
|
499 |
]
|
|
500 |
]
|
49
|
501 |
].
|
|
502 |
entry notNil ifTrue:[
|
50
|
503 |
entry tabulatorSpecification:tabSpec.
|
|
504 |
entry colAt:1 put:changeString.
|
|
505 |
entry colAt:2 put:changeType.
|
49
|
506 |
changeHeaderLines add:entry
|
|
507 |
] ifFalse:[
|
|
508 |
headerLine notNil ifTrue:[
|
|
509 |
changeHeaderLines add:headerLine
|
|
510 |
]
|
45
|
511 |
]
|
|
512 |
]
|
|
513 |
].
|
|
514 |
changeClassNames := OrderedCollection new grow:(changeChunks size).
|
|
515 |
aStream close.
|
|
516 |
anyChanges := false
|
|
517 |
] valueNowOrOnUnwindDo:[
|
|
518 |
inBackground ifTrue:[myProcess priority:myPriority].
|
|
519 |
].
|
|
520 |
]
|
|
521 |
!
|
37
|
522 |
|
45
|
523 |
queryCloseText
|
|
524 |
"made this a method for easy redefinition in subclasses"
|
|
525 |
|
|
526 |
^ 'Quit without updating changeFile ?'
|
|
527 |
!
|
|
528 |
|
|
529 |
applyChange:changeNr
|
|
530 |
"fileIn a change"
|
|
531 |
|
|
532 |
|aStream upd sig nm cls|
|
|
533 |
|
|
534 |
aStream := self streamForChange:changeNr.
|
|
535 |
aStream isNil ifTrue:[^ self].
|
|
536 |
|
|
537 |
nm := self classNameOfChange:changeNr.
|
|
538 |
nm notNil ifTrue:[
|
|
539 |
cls := Smalltalk at:(nm asSymbol) ifAbsent:[].
|
|
540 |
cls notNil ifTrue:[
|
|
541 |
cls isLoaded ifFalse:[
|
|
542 |
cls autoload
|
|
543 |
]
|
|
544 |
]
|
|
545 |
].
|
|
546 |
|
|
547 |
upd := Class updateChanges:false.
|
|
548 |
|
|
549 |
changeNrProcessed := changeNr.
|
|
550 |
[
|
|
551 |
(skipSignal notNil) ifTrue:[
|
|
552 |
sig := skipSignal
|
|
553 |
] ifFalse:[
|
|
554 |
sig := Object abortSignal
|
|
555 |
].
|
|
556 |
sig catch:[
|
|
557 |
aStream fileInNextChunkNotifying:self
|
|
558 |
].
|
|
559 |
changeNrProcessed := nil.
|
|
560 |
] valueNowOrOnUnwindDo:[
|
|
561 |
Class updateChanges:upd.
|
|
562 |
aStream close
|
|
563 |
].
|
|
564 |
!
|
|
565 |
|
|
566 |
changeFileName:aFileName
|
|
567 |
changeFileName := aFileName
|
|
568 |
!
|
|
569 |
|
|
570 |
setChangeList
|
|
571 |
"extract type-information from changes and stuff into top selection
|
|
572 |
view"
|
|
573 |
|
49
|
574 |
"/ changeListView list:changeHeaderLines "changeChunks".
|
|
575 |
changeListView setList:changeHeaderLines expandTabs:false.
|
45
|
576 |
self disableMenuEntries
|
0
|
577 |
!
|
|
578 |
|
|
579 |
silentDeleteChange:changeNr
|
|
580 |
"delete a change do not update changeListView"
|
|
581 |
|
|
582 |
anyChanges := true.
|
|
583 |
changeChunks removeIndex:changeNr.
|
|
584 |
changePositions removeIndex:changeNr.
|
37
|
585 |
changeClassNames removeIndex:changeNr.
|
|
586 |
changeHeaderLines removeIndex:changeNr
|
0
|
587 |
!
|
|
588 |
|
45
|
589 |
writeBackChanges
|
|
590 |
"write back the changes file"
|
|
591 |
|
|
592 |
|inStream outStream chunk sawExcla excla done dir|
|
|
593 |
|
|
594 |
outStream := FileStream newFileNamed:'n_changes'.
|
|
595 |
outStream isNil ifTrue:[
|
|
596 |
self warn:'cannot create temporary file'.
|
|
597 |
^ self
|
|
598 |
].
|
|
599 |
|
|
600 |
inStream := FileStream readonlyFileNamed:changeFileName.
|
|
601 |
inStream isNil ifTrue:[^ nil].
|
|
602 |
|
|
603 |
self withCursor:(Cursor write) do:[
|
|
604 |
excla := inStream class chunkSeparator.
|
49
|
605 |
1 to:(changePositions size) do:[:index |
|
45
|
606 |
inStream position:(changePositions at:index).
|
|
607 |
sawExcla := inStream peekFor:excla.
|
|
608 |
chunk := inStream nextChunk.
|
|
609 |
|
|
610 |
sawExcla ifTrue:[
|
|
611 |
outStream nextPut:excla.
|
|
612 |
outStream nextChunkPut:chunk.
|
|
613 |
outStream cr.
|
|
614 |
"a method-definition chunk - skip followups"
|
|
615 |
done := false.
|
|
616 |
[done] whileFalse:[
|
|
617 |
chunk := inStream nextChunk.
|
|
618 |
chunk isNil ifTrue:[
|
|
619 |
done := true
|
|
620 |
] ifFalse:[
|
|
621 |
outStream nextChunkPut:chunk.
|
|
622 |
outStream cr.
|
|
623 |
done := chunk isEmpty
|
|
624 |
]
|
|
625 |
].
|
|
626 |
] ifFalse:[
|
|
627 |
outStream nextChunkPut:chunk.
|
|
628 |
outStream cr
|
|
629 |
]
|
|
630 |
].
|
|
631 |
outStream close.
|
|
632 |
inStream close.
|
|
633 |
dir := FileDirectory currentDirectory.
|
|
634 |
"/ dir removeFile:changeFileName.
|
|
635 |
dir renameFile:'changes' newName:'changes.bak'.
|
|
636 |
dir renameFile:'n_changes' newName:changeFileName.
|
|
637 |
anyChanges := false
|
|
638 |
]
|
|
639 |
!
|
0
|
640 |
|
|
641 |
deleteChange:changeNr
|
|
642 |
"delete a change"
|
|
643 |
|
|
644 |
changeListView deselect.
|
|
645 |
self silentDeleteChange:changeNr.
|
45
|
646 |
self setChangeList "/changeListView setContents:changeChunks
|
|
647 |
|
|
648 |
!
|
|
649 |
|
|
650 |
classNameOfChange:changeNr
|
|
651 |
"return the classname of a change (for xxx class - changes xxx is returned)
|
|
652 |
- since parsing ascii methods is slow, keep result cached in
|
|
653 |
changeClassNames for the next query"
|
|
654 |
|
|
655 |
|chunk aParseTree recTree sel name arg1Tree|
|
|
656 |
|
|
657 |
changeNr notNil ifTrue:[
|
|
658 |
"
|
|
659 |
first look, if not already known
|
|
660 |
"
|
|
661 |
name := changeClassNames at:changeNr.
|
|
662 |
name notNil ifTrue:[^ name].
|
|
663 |
|
|
664 |
"
|
|
665 |
get the chunk
|
|
666 |
"
|
|
667 |
chunk := changeChunks at:changeNr.
|
|
668 |
chunk notNil ifTrue:[
|
|
669 |
"
|
|
670 |
use parser to construct a parseTree
|
|
671 |
"
|
|
672 |
aParseTree := Parser parseExpression:chunk.
|
|
673 |
(aParseTree notNil and:[aParseTree isMessage]) ifTrue:[
|
|
674 |
"
|
|
675 |
ask parser for selector
|
|
676 |
"
|
|
677 |
sel := aParseTree selector.
|
|
678 |
"
|
|
679 |
is it a method-change, methodRemove or comment-change ?
|
|
680 |
"
|
|
681 |
(#(methodsFor: privateMethodsFor: publicMethodsFor:
|
|
682 |
removeSelector: comment:) includes:sel) ifTrue:[
|
|
683 |
"
|
|
684 |
yes, the className is the receiver
|
|
685 |
"
|
|
686 |
recTree := aParseTree receiver.
|
|
687 |
(recTree notNil and:[recTree ~~ #Error]) ifTrue:[
|
|
688 |
recTree isUnaryMessage ifTrue:[
|
|
689 |
(recTree selector ~~ #class) ifTrue:[^ nil].
|
|
690 |
"id class methodsFor:..."
|
|
691 |
recTree := recTree receiver
|
|
692 |
].
|
|
693 |
recTree isPrimary ifTrue:[
|
|
694 |
name := recTree name.
|
|
695 |
changeClassNames at:changeNr put:name.
|
|
696 |
^ name
|
|
697 |
]
|
|
698 |
]
|
|
699 |
] ifFalse:[
|
|
700 |
"
|
|
701 |
is it a change in a class-description ?
|
|
702 |
"
|
|
703 |
('subclass:*' match:sel) ifTrue:[
|
|
704 |
arg1Tree := aParseTree arg1.
|
|
705 |
(arg1Tree notNil and:[arg1Tree isConstant]) ifTrue:[
|
|
706 |
name := arg1Tree value asString.
|
|
707 |
changeClassNames at:changeNr put:name.
|
|
708 |
^ name
|
|
709 |
]
|
|
710 |
]
|
|
711 |
]
|
|
712 |
]
|
|
713 |
]
|
|
714 |
].
|
|
715 |
^ nil
|
0
|
716 |
!
|
|
717 |
|
|
718 |
deleteChangesFrom:start to:stop
|
|
719 |
"delete a range of changes"
|
|
720 |
|
|
721 |
changeListView deselect.
|
|
722 |
stop to:start by:-1 do:[:changeNr |
|
45
|
723 |
self silentDeleteChange:changeNr
|
0
|
724 |
].
|
45
|
725 |
self setChangeList "/changeListView setContents:changeChunks
|
0
|
726 |
|
|
727 |
!
|
|
728 |
|
45
|
729 |
readChangesFile
|
|
730 |
"read the changes file, create a list of header-lines (changeChunks)
|
|
731 |
and a list of chunk-positions (changePositions)"
|
22
|
732 |
|
45
|
733 |
^ self readChangesFileInBackground:false
|
0
|
734 |
!
|
|
735 |
|
|
736 |
compareChange:changeNr
|
|
737 |
"compare a change with current version"
|
|
738 |
|
|
739 |
|aStream chunk sawExcla parseTree thisClass cat oldSource newSource
|
29
|
740 |
parser sel oldMethod outcome showDiff d|
|
0
|
741 |
|
|
742 |
aStream := self streamForChange:changeNr.
|
|
743 |
aStream isNil ifTrue:[^ self].
|
28
|
744 |
|
0
|
745 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
746 |
chunk := aStream nextChunk.
|
|
747 |
sawExcla ifFalse:[
|
45
|
748 |
outcome := 'not comparable ...'
|
0
|
749 |
] ifTrue:[
|
45
|
750 |
parseTree := Parser parseExpression:chunk.
|
|
751 |
(parseTree notNil and:[parseTree isMessage]) ifTrue:[
|
|
752 |
(parseTree selector == #methodsFor:) ifTrue:[
|
|
753 |
thisClass := (parseTree receiver evaluate).
|
|
754 |
thisClass isBehavior ifTrue:[
|
|
755 |
showDiff := false.
|
|
756 |
cat := parseTree arg1 evaluate.
|
|
757 |
newSource := aStream nextChunk.
|
|
758 |
parser := Parser parseMethod:newSource in:thisClass.
|
|
759 |
(parser notNil and:[parser ~~ #Error]) ifTrue:[
|
|
760 |
sel := parser selector.
|
|
761 |
oldMethod := thisClass compiledMethodAt:sel.
|
|
762 |
oldMethod notNil ifTrue:[
|
|
763 |
(oldMethod category = cat) ifFalse:[
|
|
764 |
Transcript showCr:'category changed.'.
|
|
765 |
].
|
|
766 |
oldSource := oldMethod source.
|
|
767 |
(oldSource = newSource) ifTrue:[
|
|
768 |
outcome := 'same source'
|
|
769 |
] ifFalse:[
|
|
770 |
outcome := 'source changed.'.
|
|
771 |
showDiff := true
|
|
772 |
]
|
|
773 |
] ifFalse:[
|
|
774 |
outcome := 'method does not exist.'
|
|
775 |
]
|
|
776 |
] ifFalse:[
|
|
777 |
outcome := 'change unparsable.'
|
|
778 |
].
|
|
779 |
(showDiff and:[oldSource notNil and:[newSource notNil]]) ifTrue:[
|
|
780 |
d := DiffTextView openOn:oldSource and:newSource.
|
|
781 |
d label:'differences (current left; change right)'.
|
|
782 |
]
|
|
783 |
] ifFalse:[
|
|
784 |
outcome := 'class does not exist.'
|
|
785 |
]
|
|
786 |
] ifFalse:[
|
|
787 |
outcome := 'not comparable.'
|
|
788 |
]
|
|
789 |
] ifFalse:[
|
|
790 |
outcome := 'not comparable.'
|
|
791 |
]
|
0
|
792 |
].
|
28
|
793 |
Transcript showCr:outcome.
|
|
794 |
aStream close.
|
0
|
795 |
!
|
|
796 |
|
28
|
797 |
appendChange:changeNr toFile:fileName
|
37
|
798 |
"append change to a file. return true if ok."
|
0
|
799 |
|
37
|
800 |
|aStream outStream chunk sawExcla separator|
|
0
|
801 |
|
28
|
802 |
outStream := FileStream oldFileNamed:fileName.
|
0
|
803 |
outStream isNil ifTrue:[
|
45
|
804 |
outStream isNil ifTrue:[
|
|
805 |
outStream := FileStream newFileNamed:fileName.
|
|
806 |
outStream isNil ifTrue:[
|
|
807 |
self warn:'cannot update file ''%1''' with:fileName.
|
|
808 |
^ false
|
|
809 |
]
|
|
810 |
]
|
0
|
811 |
].
|
37
|
812 |
|
0
|
813 |
outStream setToEnd.
|
28
|
814 |
|
0
|
815 |
aStream := self streamForChange:changeNr.
|
37
|
816 |
aStream isNil ifTrue:[
|
45
|
817 |
self warn:'oops cannot read change'.
|
|
818 |
^ false
|
37
|
819 |
].
|
|
820 |
|
|
821 |
separator := aStream class chunkSeparator.
|
|
822 |
sawExcla := aStream peekFor:separator.
|
0
|
823 |
sawExcla ifTrue:[
|
45
|
824 |
outStream nextPut:separator
|
0
|
825 |
].
|
|
826 |
chunk := aStream nextChunk.
|
|
827 |
outStream nextChunkPut:chunk.
|
|
828 |
outStream cr.
|
|
829 |
sawExcla ifTrue:[
|
45
|
830 |
chunk := aStream nextChunk.
|
|
831 |
outStream nextChunkPut:chunk.
|
|
832 |
outStream space
|
0
|
833 |
].
|
|
834 |
sawExcla ifTrue:[
|
45
|
835 |
outStream nextPut:separator
|
0
|
836 |
].
|
|
837 |
outStream cr.
|
|
838 |
aStream close.
|
37
|
839 |
outStream close.
|
|
840 |
^ true
|
0
|
841 |
!
|
|
842 |
|
28
|
843 |
makeChangeAPatch:changeNr
|
|
844 |
"append change to patchfile"
|
|
845 |
|
|
846 |
self appendChange:changeNr toFile:'patches'
|
|
847 |
!
|
|
848 |
|
0
|
849 |
makeChangePermanent:changeNr
|
28
|
850 |
"rewrite the source file where change changeNr lies"
|
0
|
851 |
|
|
852 |
self notify:'this is not yet implemented'
|
|
853 |
!
|
|
854 |
|
45
|
855 |
silentDeleteChangesFor:aClassName from:start to:stop
|
|
856 |
"delete changes for a given class in a range"
|
|
857 |
|
|
858 |
|thisClassName index|
|
0
|
859 |
|
45
|
860 |
index := stop.
|
|
861 |
[index >= start] whileTrue:[
|
|
862 |
thisClassName := self classNameOfChange:index.
|
|
863 |
thisClassName = aClassName ifTrue:[
|
|
864 |
self silentDeleteChange:index
|
|
865 |
].
|
|
866 |
index := index - 1
|
|
867 |
]
|
0
|
868 |
|
|
869 |
! !
|
|
870 |
|
|
871 |
!ChangesBrowser methodsFor:'user interaction'!
|
|
872 |
|
|
873 |
changeSelection:lineNr
|
|
874 |
"show a change in the codeView"
|
|
875 |
|
|
876 |
|aStream sawExcla chunk|
|
|
877 |
|
|
878 |
aStream := self streamForChange:lineNr.
|
|
879 |
aStream isNil ifTrue:[^ self].
|
|
880 |
sawExcla := aStream peekFor:(aStream class chunkSeparator).
|
|
881 |
chunk := aStream nextChunk.
|
|
882 |
sawExcla ifTrue:[
|
45
|
883 |
chunk := aStream nextChunk
|
0
|
884 |
].
|
|
885 |
aStream close.
|
|
886 |
codeView contents:chunk.
|
13
|
887 |
codeView acceptAction:[:theCode | self doApply "noChangesAllowed"].
|
15
|
888 |
changeNrShown := lineNr.
|
|
889 |
self enableMenuEntries
|
0
|
890 |
!
|
|
891 |
|
45
|
892 |
noChangesAllowed
|
|
893 |
"show a warning that changes cannot be changed"
|
|
894 |
|
|
895 |
self warn:'changes are not allowed to be changed'
|
|
896 |
!
|
|
897 |
|
37
|
898 |
doSaveClass
|
|
899 |
"user wants changes for some class from current to end to be appended to a file"
|
|
900 |
|
|
901 |
self doSaveClassFrom:1
|
|
902 |
!
|
|
903 |
|
|
904 |
doSaveClassAll
|
|
905 |
"user wants changes for some class from current to end to be appended to a file"
|
|
906 |
|
|
907 |
self doSaveClassFrom:1
|
|
908 |
!
|
|
909 |
|
45
|
910 |
doApply
|
|
911 |
"user wants a change to be applied"
|
|
912 |
|
|
913 |
|changeNr|
|
|
914 |
|
|
915 |
changeNr := changeListView selection.
|
|
916 |
changeNr notNil ifTrue:[
|
|
917 |
self withCursor:(Cursor execute) do:[
|
|
918 |
skipSignal := nil.
|
|
919 |
self applyChange:changeNr.
|
|
920 |
self autoSelect:(changeNr + 1)
|
|
921 |
]
|
|
922 |
]
|
|
923 |
!
|
|
924 |
|
37
|
925 |
doSaveClassRest
|
|
926 |
"user wants changes for some class from current to end to be appended to a file"
|
28
|
927 |
|
|
928 |
|changeNr|
|
|
929 |
|
|
930 |
changeNr := changeListView selection.
|
|
931 |
changeNr notNil ifTrue:[
|
45
|
932 |
self doSaveClassFrom:changeNr
|
37
|
933 |
]
|
|
934 |
!
|
|
935 |
|
|
936 |
saveClass:aClassName from:startNr
|
|
937 |
"user wants changes from current to end to be appended to a file"
|
|
938 |
|
|
939 |
|changeNr classNameToSave fileBox|
|
|
940 |
|
|
941 |
changeNr := changeListView selection.
|
|
942 |
changeNr notNil ifTrue:[
|
45
|
943 |
fileBox := FileSelectionBox new.
|
|
944 |
fileBox title:'append change to:'.
|
|
945 |
fileBox okText:'append'.
|
|
946 |
fileBox abortText:'cancel'.
|
|
947 |
fileBox action:[:fileName |
|
|
948 |
|thisClassName|
|
|
949 |
self withCursor:(Cursor write) do:[
|
49
|
950 |
startNr to:(changePositions size) do:[:changeNr |
|
45
|
951 |
thisClassName := self classNameOfChange:changeNr.
|
|
952 |
thisClassName = aClassName ifTrue:[
|
|
953 |
changeListView selection:changeNr.
|
|
954 |
(self appendChange:changeNr toFile:fileName) ifFalse:[
|
|
955 |
^ self
|
|
956 |
]
|
|
957 |
]
|
|
958 |
]
|
|
959 |
]
|
|
960 |
].
|
37
|
961 |
|
45
|
962 |
fileBox pattern:'*.chg'.
|
|
963 |
fileBox showAtPointer
|
|
964 |
]
|
|
965 |
!
|
|
966 |
|
|
967 |
doBrowse
|
|
968 |
"user wants a browser on the class of a change"
|
|
969 |
|
|
970 |
|changeNr className cls|
|
|
971 |
|
|
972 |
changeNr := changeListView selection.
|
|
973 |
changeNr notNil ifTrue:[
|
|
974 |
className := self classNameOfChange:changeNr.
|
|
975 |
className notNil ifTrue:[
|
|
976 |
(cls := Smalltalk classNamed:className) notNil ifTrue:[
|
|
977 |
SystemBrowser browseClass:cls
|
|
978 |
]
|
|
979 |
]
|
37
|
980 |
]
|
|
981 |
!
|
|
982 |
|
|
983 |
doSaveClassFrom:startNr
|
|
984 |
"user wants changes from current to end to be appended to a file"
|
|
985 |
|
|
986 |
|changeNr classNameToSave|
|
|
987 |
|
|
988 |
changeNr := changeListView selection.
|
|
989 |
changeNr notNil ifTrue:[
|
45
|
990 |
classNameToSave := self classNameOfChange:changeNr.
|
|
991 |
classNameToSave notNil ifTrue:[
|
|
992 |
self saveClass:classNameToSave from:startNr
|
|
993 |
]
|
37
|
994 |
]
|
|
995 |
!
|
|
996 |
|
|
997 |
doSaveRest
|
|
998 |
"user wants changes from current to end to be appended to a file"
|
|
999 |
|
|
1000 |
|changeNr fileBox|
|
|
1001 |
|
|
1002 |
changeNr := changeListView selection.
|
|
1003 |
changeNr notNil ifTrue:[
|
45
|
1004 |
fileBox := FileSelectionBox new.
|
|
1005 |
fileBox title:'append change to:'.
|
|
1006 |
fileBox okText:'append'.
|
|
1007 |
fileBox abortText:'cancel'.
|
|
1008 |
fileBox action:[:fileName |
|
|
1009 |
self withCursor:(Cursor write) do:[
|
49
|
1010 |
changeNr to:(changePositions size) do:[:changeNr |
|
45
|
1011 |
changeListView selection:changeNr.
|
|
1012 |
(self appendChange:changeNr toFile:fileName) ifFalse:[
|
|
1013 |
^ self
|
|
1014 |
]
|
|
1015 |
]
|
|
1016 |
]
|
|
1017 |
].
|
37
|
1018 |
|
45
|
1019 |
fileBox pattern:'*.chg'.
|
|
1020 |
fileBox showAtPointer
|
37
|
1021 |
]
|
|
1022 |
!
|
|
1023 |
|
|
1024 |
doSave
|
|
1025 |
"user wants a change to be appended to a file"
|
|
1026 |
|
|
1027 |
|changeNr fileBox|
|
|
1028 |
|
|
1029 |
changeNr := changeListView selection.
|
|
1030 |
changeNr notNil ifTrue:[
|
45
|
1031 |
fileBox := FileSelectionBox new.
|
|
1032 |
fileBox title:'append change to:'.
|
|
1033 |
fileBox okText:'append'.
|
|
1034 |
fileBox abortText:'cancel'.
|
|
1035 |
fileBox action:[:fileName |
|
|
1036 |
self withCursor:(Cursor write) do:[
|
|
1037 |
self appendChange:changeNr toFile:fileName.
|
|
1038 |
].
|
|
1039 |
self autoSelect:(changeNr + 1)
|
|
1040 |
].
|
28
|
1041 |
|
45
|
1042 |
fileBox pattern:'*.chg'.
|
|
1043 |
fileBox showAtPointer
|
28
|
1044 |
]
|
|
1045 |
!
|
|
1046 |
|
0
|
1047 |
doMakePermanent
|
|
1048 |
"user wants a change to be made permanent
|
|
1049 |
- rewrite the source file where this change has to go"
|
|
1050 |
|
|
1051 |
|changeNr yesNoBox|
|
|
1052 |
|
28
|
1053 |
yesNoBox := YesNoBox new.
|
1
|
1054 |
yesNoBox title:(resources at:'Warning: this operation cannot be undone').
|
28
|
1055 |
yesNoBox okText:(resources at:'continue').
|
1
|
1056 |
yesNoBox noText:(resources at:'abort').
|
0
|
1057 |
yesNoBox okAction:[
|
45
|
1058 |
changeNr := changeListView selection.
|
|
1059 |
changeNr notNil ifTrue:[
|
|
1060 |
self makeChangePermanent:changeNr.
|
|
1061 |
self autoSelect:(changeNr + 1)
|
|
1062 |
]
|
|
1063 |
].
|
0
|
1064 |
yesNoBox showAtPointer
|
|
1065 |
!
|
|
1066 |
|
|
1067 |
doMakePatch
|
|
1068 |
"user wants a change to be made a patch
|
|
1069 |
- copy it over to the patches file"
|
|
1070 |
|
|
1071 |
|changeNr|
|
|
1072 |
|
|
1073 |
changeNr := changeListView selection.
|
|
1074 |
changeNr notNil ifTrue:[
|
45
|
1075 |
self makeChangeAPatch:changeNr.
|
|
1076 |
self autoSelect:(changeNr + 1)
|
0
|
1077 |
]
|
|
1078 |
!
|
|
1079 |
|
|
1080 |
doDelete
|
|
1081 |
"delete currently selected change"
|
|
1082 |
|
|
1083 |
|changeNr|
|
|
1084 |
|
|
1085 |
changeNr := changeListView selection.
|
|
1086 |
changeNr notNil ifTrue:[
|
45
|
1087 |
self deleteChange:changeNr.
|
|
1088 |
self autoSelectOrEnd:changeNr
|
|
1089 |
]
|
|
1090 |
!
|
|
1091 |
|
|
1092 |
doApplyRest
|
|
1093 |
"user wants all changes from changeNr to be applied"
|
|
1094 |
|
|
1095 |
|changeNr|
|
|
1096 |
|
|
1097 |
changeNr := changeListView selection.
|
|
1098 |
changeNr notNil ifTrue:[
|
|
1099 |
self withCursor:(Cursor execute) do:[
|
|
1100 |
self clearCodeView.
|
|
1101 |
skipSignal isNil ifTrue:[skipSignal := Signal new].
|
|
1102 |
"/ Object abortSignal catch:[
|
|
1103 |
changeNr to:(changePositions size) do:[:changeNr |
|
|
1104 |
changeListView selection:changeNr.
|
|
1105 |
self applyChange:changeNr
|
|
1106 |
"/ ]
|
|
1107 |
].
|
|
1108 |
"/ skipSignal := nil
|
|
1109 |
]
|
|
1110 |
]
|
|
1111 |
!
|
|
1112 |
|
|
1113 |
doApplyAll
|
|
1114 |
"user wants all changes to be applied"
|
|
1115 |
|
|
1116 |
self withCursor:(Cursor execute) do:[
|
|
1117 |
self clearCodeView.
|
|
1118 |
skipSignal isNil ifTrue:[skipSignal := Signal new].
|
|
1119 |
"/ Object abortSignal catch:[
|
|
1120 |
1 to:(changePositions size) do:[:changeNr |
|
|
1121 |
changeListView selection:changeNr.
|
|
1122 |
self applyChange:changeNr
|
|
1123 |
"/ ]
|
|
1124 |
].
|
|
1125 |
"/ skipSignal := nil
|
0
|
1126 |
]
|
|
1127 |
!
|
|
1128 |
|
|
1129 |
doDeleteClassRest
|
|
1130 |
"delete rest of changes with same class as currently selected change"
|
|
1131 |
|
|
1132 |
|changeNr classNameToDelete|
|
|
1133 |
|
|
1134 |
changeNr := changeListView selection.
|
|
1135 |
changeNr notNil ifTrue:[
|
45
|
1136 |
self withCursor:(Cursor execute) do:[
|
|
1137 |
classNameToDelete := self classNameOfChange:changeNr.
|
|
1138 |
classNameToDelete notNil ifTrue:[
|
|
1139 |
changeListView selection:nil.
|
|
1140 |
self silentDeleteChangesFor:classNameToDelete
|
|
1141 |
from:changeNr
|
49
|
1142 |
to:(changePositions size).
|
|
1143 |
self setChangeList. "/changeListView setContents:changeChunks.
|
|
1144 |
self autoSelectOrEnd:changeNr
|
|
1145 |
]
|
|
1146 |
]
|
|
1147 |
]
|
|
1148 |
!
|
|
1149 |
|
|
1150 |
doDeleteRest
|
|
1151 |
"delete all changes from current to the end"
|
|
1152 |
|
|
1153 |
|changeNr|
|
|
1154 |
|
|
1155 |
changeNr := changeListView selection.
|
|
1156 |
changeNr notNil ifTrue:[
|
|
1157 |
self deleteChangesFrom:changeNr to:(changePositions size).
|
|
1158 |
self clearCodeView.
|
|
1159 |
self autoSelectOrEnd:changeNr-1
|
|
1160 |
]
|
|
1161 |
!
|
|
1162 |
|
|
1163 |
doDeleteClassAll
|
|
1164 |
"delete all changes with same class as currently selected change"
|
|
1165 |
|
|
1166 |
|changeNr classNameToDelete|
|
|
1167 |
|
|
1168 |
changeNr := changeListView selection.
|
|
1169 |
changeNr notNil ifTrue:[
|
|
1170 |
self withCursor:(Cursor execute) do:[
|
|
1171 |
classNameToDelete := self classNameOfChange:changeNr.
|
|
1172 |
classNameToDelete notNil ifTrue:[
|
|
1173 |
changeListView selection:nil.
|
|
1174 |
self silentDeleteChangesFor:classNameToDelete
|
|
1175 |
from:1
|
|
1176 |
to:(changePositions size).
|
45
|
1177 |
self setChangeList. "/changeListView setContents:changeChunks.
|
|
1178 |
self autoSelectOrEnd:changeNr
|
|
1179 |
]
|
|
1180 |
]
|
|
1181 |
]
|
|
1182 |
!
|
|
1183 |
|
|
1184 |
doWriteBack
|
|
1185 |
"write back the list onto the changes file"
|
|
1186 |
|
|
1187 |
anyChanges ifTrue:[
|
|
1188 |
self writeBackChanges.
|
|
1189 |
realized ifTrue:[
|
|
1190 |
self readChangesFileInBackground:false.
|
|
1191 |
realized ifTrue:[
|
|
1192 |
self setChangeList
|
|
1193 |
]
|
|
1194 |
]
|
0
|
1195 |
]
|
|
1196 |
!
|
|
1197 |
|
45
|
1198 |
doCompress
|
|
1199 |
"compress the change-set; this replaces multiple method-changes by the last
|
|
1200 |
(i.e. the most recent) change"
|
|
1201 |
|
|
1202 |
|classes types selectors thisClass thisSelector
|
|
1203 |
aStream chunk changeNr sawExcla aParseTree codeChunk codeParser
|
|
1204 |
searchIndex anyMore deleteSet index parseTreeChunk numChanges
|
|
1205 |
excla snapshotProto str snapshotPrefix snapshotNameIndex fileName|
|
|
1206 |
|
|
1207 |
aStream := FileStream readonlyFileNamed:changeFileName.
|
|
1208 |
aStream isNil ifTrue:[^ self].
|
|
1209 |
|
|
1210 |
"
|
|
1211 |
get a prototype snapshot record (to be independent of
|
|
1212 |
the actual format ..
|
|
1213 |
"
|
|
1214 |
str := WriteStream on:String new.
|
|
1215 |
Class addChangeRecordForSnapshot:'foo' to:str.
|
|
1216 |
snapshotProto := str contents.
|
|
1217 |
snapshotPrefix := snapshotProto copyTo:10.
|
|
1218 |
snapshotNameIndex := snapshotProto findString:'foo'.
|
|
1219 |
|
|
1220 |
self withCursor:(Cursor execute) do:[
|
|
1221 |
numChanges := changePositions size.
|
|
1222 |
classes := Array new:numChanges.
|
|
1223 |
selectors := Array new:numChanges.
|
|
1224 |
types := Array new:numChanges.
|
|
1225 |
|
|
1226 |
"starting at the end, get the change class and change selector;
|
|
1227 |
collect all in classes / selectors"
|
|
1228 |
|
|
1229 |
changeNr := numChanges.
|
|
1230 |
excla := aStream class chunkSeparator.
|
|
1231 |
|
|
1232 |
[changeNr >= 1] whileTrue:[
|
|
1233 |
aStream position:(changePositions at:changeNr).
|
|
1234 |
sawExcla := aStream peekFor:excla.
|
|
1235 |
chunk := aStream nextChunk.
|
|
1236 |
sawExcla ifTrue:[
|
|
1237 |
"optimize a bit if multiple methods for same category arrive"
|
|
1238 |
(chunk = parseTreeChunk) ifFalse:[
|
|
1239 |
aParseTree := Parser parseExpression:chunk.
|
|
1240 |
parseTreeChunk := chunk
|
|
1241 |
].
|
|
1242 |
(aParseTree notNil
|
|
1243 |
and:[(aParseTree ~~ #Error)
|
|
1244 |
and:[aParseTree isMessage]]) ifTrue:[
|
|
1245 |
(aParseTree selector == #methodsFor:) ifTrue:[
|
|
1246 |
thisClass := (aParseTree receiver evaluate).
|
|
1247 |
codeChunk := aStream nextChunk.
|
|
1248 |
codeParser := Parser
|
|
1249 |
parseMethodSpecification:codeChunk
|
|
1250 |
in:thisClass
|
|
1251 |
ignoreErrors:true
|
|
1252 |
ignoreWarnings:true.
|
|
1253 |
codeParser notNil ifTrue:[
|
|
1254 |
selectors at:changeNr put:(codeParser selector).
|
|
1255 |
classes at:changeNr put:thisClass.
|
|
1256 |
types at:changeNr put:#methodsFor
|
|
1257 |
]
|
|
1258 |
]
|
|
1259 |
]
|
|
1260 |
] ifFalse:[
|
|
1261 |
aParseTree := Parser parseExpression:chunk.
|
|
1262 |
parseTreeChunk := chunk.
|
|
1263 |
(aParseTree notNil
|
|
1264 |
and:[(aParseTree ~~ #Error)
|
|
1265 |
and:[aParseTree isMessage]]) ifTrue:[
|
|
1266 |
(aParseTree selector == #removeSelector:) ifTrue:[
|
|
1267 |
selectors at:changeNr put:(aParseTree arg1 value ).
|
|
1268 |
classes at:changeNr put:(aParseTree receiver evaluate).
|
|
1269 |
types at:changeNr put:#removeSelector
|
|
1270 |
]
|
|
1271 |
] ifFalse:[
|
|
1272 |
(chunk startsWith:snapshotPrefix) ifTrue:[
|
|
1273 |
str := chunk readStream position:snapshotNameIndex.
|
|
1274 |
fileName := str upTo:(Character space).
|
|
1275 |
"
|
|
1276 |
kludge to allow use of match-check below
|
|
1277 |
"
|
|
1278 |
selectors at:changeNr put:snapshotPrefix.
|
|
1279 |
classes at:changeNr put:fileName.
|
|
1280 |
]
|
|
1281 |
]
|
|
1282 |
].
|
|
1283 |
changeNr := changeNr - 1
|
|
1284 |
].
|
|
1285 |
aStream close.
|
|
1286 |
|
|
1287 |
"for all changes, look for another class/selector occurence later
|
|
1288 |
in the list and, if there is one, add change number to the delete set"
|
|
1289 |
|
|
1290 |
deleteSet := OrderedCollection new.
|
|
1291 |
changeNr := 1.
|
|
1292 |
[changeNr < changePositions size] whileTrue:[
|
|
1293 |
thisClass := classes at:changeNr.
|
|
1294 |
thisSelector := selectors at:changeNr.
|
|
1295 |
searchIndex := changeNr.
|
|
1296 |
anyMore := true.
|
|
1297 |
[anyMore] whileTrue:[
|
|
1298 |
searchIndex := classes indexOf:thisClass
|
|
1299 |
startingAt:(searchIndex + 1).
|
|
1300 |
(searchIndex ~~ 0) ifTrue:[
|
|
1301 |
((selectors at:searchIndex) == thisSelector) ifTrue:[
|
|
1302 |
thisClass notNil ifTrue:[
|
|
1303 |
deleteSet add:changeNr.
|
|
1304 |
anyMore := false
|
|
1305 |
]
|
|
1306 |
]
|
|
1307 |
] ifFalse:[
|
|
1308 |
anyMore := false
|
|
1309 |
]
|
|
1310 |
].
|
|
1311 |
changeNr := changeNr + 1
|
|
1312 |
].
|
|
1313 |
|
|
1314 |
"finally delete what has been found"
|
|
1315 |
|
|
1316 |
(deleteSet size > 0) ifTrue:[
|
|
1317 |
changeListView selection:nil.
|
|
1318 |
index := deleteSet size.
|
|
1319 |
[index > 0] whileTrue:[
|
|
1320 |
self silentDeleteChange:(deleteSet at:index).
|
|
1321 |
index := index - 1
|
|
1322 |
].
|
|
1323 |
self setChangeList.
|
49
|
1324 |
changeListView firstLineShown > changePositions size ifTrue:[
|
|
1325 |
changeListView makeLineVisible:changePositions size
|
45
|
1326 |
].
|
|
1327 |
self clearCodeView
|
|
1328 |
]
|
|
1329 |
]
|
|
1330 |
!
|
|
1331 |
|
|
1332 |
doUpdate
|
|
1333 |
"reread the changes-file"
|
|
1334 |
|
|
1335 |
self readChangesFileInBackground:true.
|
|
1336 |
realized ifTrue:[
|
|
1337 |
self setChangeList
|
0
|
1338 |
]
|
|
1339 |
!
|
|
1340 |
|
|
1341 |
doCompare
|
|
1342 |
"compare change with current system version
|
|
1343 |
- give a note in transcript"
|
|
1344 |
|
|
1345 |
|changeNr|
|
|
1346 |
|
|
1347 |
changeNr := changeListView selection.
|
|
1348 |
changeNr notNil ifTrue:[
|
45
|
1349 |
self withCursor:(Cursor execute) do:[
|
|
1350 |
self compareChange:changeNr
|
|
1351 |
]
|
0
|
1352 |
]
|
45
|
1353 |
! !
|
|
1354 |
|
|
1355 |
!ChangesBrowser methodsFor:'error handling'!
|
|
1356 |
|
|
1357 |
correctableError:aString position:relPos to:relEndPos
|
|
1358 |
"compiler notifys us of an error - this should really not happen since
|
|
1359 |
changes ought to be correct (did someone edit the changes file ??).
|
|
1360 |
Show the bad change in the codeView and let codeView hilight the error;
|
|
1361 |
no corrections allowed here therefore return false"
|
|
1362 |
|
|
1363 |
|action|
|
|
1364 |
|
|
1365 |
(changeNrProcessed ~~ changeNrShown) ifTrue:[
|
|
1366 |
self changeSelection:changeNrProcessed
|
|
1367 |
].
|
|
1368 |
(skipSignal notNil) ifTrue:[
|
|
1369 |
|
|
1370 |
codeView highlightingErrorPosition:relPos to:relEndPos do:[
|
|
1371 |
|box|
|
|
1372 |
|
|
1373 |
"
|
|
1374 |
start dialog - make certain cleanup is done
|
|
1375 |
"
|
|
1376 |
box := OptionBox title:aString numberOfOptions:3.
|
|
1377 |
box buttonTitles:#('abort' 'skip' 'continue').
|
|
1378 |
box actions:(Array with:[action := #abort]
|
|
1379 |
with:[action := #skip]
|
|
1380 |
with:[action := #continue]).
|
|
1381 |
box showAtPointer
|
|
1382 |
].
|
|
1383 |
|
|
1384 |
action == #abort ifTrue:[
|
|
1385 |
Object abortSignal raise.
|
|
1386 |
^ false
|
|
1387 |
].
|
|
1388 |
action == #skip ifTrue:[
|
|
1389 |
skipSignal raise.
|
|
1390 |
^ false
|
|
1391 |
].
|
|
1392 |
^ false
|
|
1393 |
].
|
|
1394 |
codeView error:aString position:relPos to:relEndPos.
|
|
1395 |
^ false
|
0
|
1396 |
!
|
|
1397 |
|
45
|
1398 |
error:aString position:relPos to:relEndPos
|
|
1399 |
"compiler notifys us of an error - this should really not happen since
|
|
1400 |
changes ought to be correct (did someone edit the changes file ??).
|
|
1401 |
Show the bad change in the codeView and let codeView hilight the error"
|
0
|
1402 |
|
45
|
1403 |
|action|
|
0
|
1404 |
|
45
|
1405 |
(changeNrProcessed ~~ changeNrShown) ifTrue:[
|
|
1406 |
self changeSelection:changeNrProcessed
|
|
1407 |
].
|
|
1408 |
(skipSignal notNil) ifTrue:[
|
0
|
1409 |
|
45
|
1410 |
codeView highlightingErrorPosition:relPos to:relEndPos do:[
|
|
1411 |
|box|
|
0
|
1412 |
|
45
|
1413 |
"
|
|
1414 |
start dialog - make certain cleanup is done
|
|
1415 |
"
|
|
1416 |
box := OptionBox title:aString numberOfOptions:3.
|
|
1417 |
box buttonTitles:#('abort' 'skip' 'continue').
|
|
1418 |
box actions:(Array with:[action := #abort]
|
|
1419 |
with:[action := #skip]
|
|
1420 |
with:[action := #continue]).
|
|
1421 |
box showAtPointer
|
|
1422 |
].
|
0
|
1423 |
|
45
|
1424 |
action == #abort ifTrue:[
|
|
1425 |
Object abortSignal raise.
|
|
1426 |
^ false
|
|
1427 |
].
|
|
1428 |
action == #skip ifTrue:[
|
|
1429 |
skipSignal raise.
|
|
1430 |
^ false
|
|
1431 |
].
|
|
1432 |
^ false
|
|
1433 |
].
|
|
1434 |
^ codeView error:aString position:relPos to:relEndPos
|
|
1435 |
!
|
0
|
1436 |
|
45
|
1437 |
warning:aString position:relPos to:relEndPos
|
|
1438 |
"compiler notifys us of a warning - ignore it"
|
0
|
1439 |
|
45
|
1440 |
^ self
|
|
1441 |
! !
|
0
|
1442 |
|