SWT Related point

Bob Arning arning at charm.net
Mon Apr 30 18:51:00 UTC 2001


On Mon, 30 Apr 2001 10:54:38 +0200 Stephane Ducasse <ducasse at iam.unibe.ch> wrote:
>mechanism that would automatically list
>all the new/removed methods in comparison to SqC images. This
>would be really interesting/necessary

Stephane,

Here is something along those lines that I have use in the past.

--in the first image--
1. File in the change set.
2. Evaluate (Smalltalk writeChangeSummary) and wait for it to complete

--in the second image--
3. File in the change set
4. Make sure that the file 'ST80.summary2' from the first image is in the default directlry for this image.
5. Evaluate (Smalltalk compareChangeSummary)

When this completes, a workspace will open listing the classes and methods that are present in one image, but not the other or are different between the two images. Note: this is written to compare images of the same major version, i.e. it assumes that methods in the .sources file are the same and doesn't bother checking them. If you are comparing from 2.9 to 3.0, e.g., change the "cm fileIndex > 1" to "cm fileIndex > 0" in two places.

Cheers,
Bob

'From Squeak3.1alpha [latest update: #''Squeak3.1alpha'' of 5 February 2001 update 3953] on 30 April 2001 at 2:36:22 pm'!

!ClassDescription methodsFor: 'fileIn/Out' stamp: 'RAA 4/30/2001 14:31'!
compareSummaryOfChangesIn: aDictionary to: aStream

	| d cm crc otherMethods first printer |

	first _ true.
	printer _ [ :msg |
		first ifTrue: [
			aStream
				cr;
				nextPutAll: '=======================
D======'; cr;
				nextPutAll: self printString; cr;
				nextPutAll: '=======================
D======'; cr.
		].
		first _ false.
		aStream nextPutAll: msg; cr.
	].
	otherMethods _ aDictionary 
		at: self printString
		ifAbsent: [
			printer value: self printString,' not in other images'.
			^self
		].
	d _ self methodDict.
	d keys asSortedCollection do: [:sel | 
		cm _ d at: sel.
		cm fileIndex > 1 ifTrue: [
			(otherMethods includesKey: sel asString) ifTrue: [
				crc _ (cm getSourceFor: sel in: self) string crc16 printString.
				crc = (otherMethods at: sel asString) ifFalse: [
					printer value: sel,' different in two images'.
				].
				otherMethods removeKey: sel asString.
			] ifFalse: [
				printer value: sel,' not in other image'.
			].
		].
	].
	otherMethods keys asSortedCollection do: [ :k |
		printer value: k,' in other image, but not in changes'.
	].
	aDictionary removeKey: self printString.

! !

!ClassDescription methodsFor: 'fileIn/Out' stamp: 'RAA 12/8/2000 19:15'!
writeSummaryOfChangesTo: newFile 

	| src d cm |
	newFile 
		nextPut: $1;
		nextPutAll: self printString; cr.
	d _ self methodDict.
	d keys asSortedCollection do: [:sel | 
		cm _ d at: sel.
		cm fileIndex > 1 ifTrue: [
			src _ cm getSourceFor: sel in: self.
			newFile 
				nextPut: $2;
				nextPutAll: sel asString;
				tab;
				nextPutAll: src string crc16 printString;
				cr.
		].
	].
! !


!SystemDictionary methodsFor: 'housekeeping' stamp: 'RAA 4/30/2001 14:31'!
compareChangeSummary		"Smalltalk compareChangeSummary"

	| f classCount otherClasses className methods methodName crc endOfClass answer |

	answer _ WriteStream on: String new.
	otherClasses _ Dictionary new.
	f _ FileStream fileNamed: 'ST80.summary2'.
	[f atEnd] whileFalse: [
		f next = $1 ifFalse: [self halt].
		className _ f upTo: Character cr.
		otherClasses at: className put: (methods _ Dictionary new).
		endOfClass _ false.
		[f atEnd | endOfClass] whileFalse: [
			f next = $2 ifTrue: [
				methodName _ f upTo: Character tab.
				crc _ f upTo: Character cr.
				methods at: methodName put: crc.
			] ifFalse: [
				f skip: -1.
				endOfClass _ true.
			].
		].
	].
	f close.
	'Comparing Changes File...'
		displayProgressAt: Sensor cursorPoint
		from: 0 to: Smalltalk classNames size
		during: [:bar |
			classCount _ 0.
			Smalltalk allClassesDo: [ :class |
				bar value: (classCount _ classCount + 1).
				class compareSummaryOfChangesIn: otherClasses to: answer.
				class class compareSummaryOfChangesIn: otherClasses to: answer.
			]
		].
	otherClasses keys asSortedCollection do: [ :k |
		answer
			cr;
			nextPutAll: '=======================
D======'; cr;
			nextPutAll: k,' is not in this image'; cr;
			nextPutAll: '=======================
D======'; cr.
	].
	StringHolder new
		contents: answer contents;
		openLabel: 'differences'.

! !

!SystemDictionary methodsFor: 'housekeeping' stamp: 'RAA 4/30/2001 14:28'!
writeChangeSummary		"Smalltalk writeChangeSummary"

	| f classCount |

	FileDirectory default deleteFileNamed: 'ST80.summary2' ifAbsent: [].
	f _ FileStream fileNamed: 'ST80.summary2'.
	'Summarizing Changes File...'
		displayProgressAt: Sensor cursorPoint
		from: 0 to: Smalltalk classNames size
		during: [:bar |
			classCount _ 0.
			Smalltalk allClassesDo: [ :class |
				bar value: (classCount _ classCount + 1).
				class writeSummaryOfChangesTo: f.
				class class writeSummaryOfChangesTo: f
			].
		].
	f close.
! !





More information about the Squeak-dev mailing list