[squeak-dev] The Trunk: System-ar.310.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Apr 7 03:11:59 UTC 2010


Andreas Raab uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-ar.310.mcz

==================== Summary ====================

Name: System-ar.310
Author: ar
Time: 6 April 2010, 8:10:38.334 pm
UUID: 8dc797cc-ccf7-6944-8c8b-0fa6ddf76511
Ancestors: System-cmm.309

Position the sources file to the end instead of writing a timestamp at the beginning (overwriting the license header).

=============== Diff against System-cmm.309 ===============

Item was changed:
  ----- Method: SmalltalkImage>>appendChangesTo: (in category 'housekeeping') -----
  appendChangesTo: sourcesName
  
  	"Condense changes to the end of the given sources file.
  	If the file is the same as Smalltalk sourcesName, then just append
  	the changes. If the file is different, then copy the sources file and
  	append the changes afterwards."
  
  	"Smalltalk appendChangesTo: 'test123.sources'"
  
  	"To verify correctness of the operation run the following code:
  	[	| sourceMap |
  		sourceMap := Dictionary new.
  
  		(CompiledMethod allInstances select:[:cm| cm isInstalled]) do:[:cm|
  			sourceMap at: cm methodReference put: 
  				(cm getSourceFor: cm selector in: cm methodClass)].
  		Smalltalk allClassesAndTraitsDo:[:aClass|
  			sourceMap at: aClass put: aClass comment].
  
  		Smalltalk appendChangesTo: 'verify.sources'.
  
  		(CompiledMethod allInstances select:[:cm| cm isInstalled]) do:[:cm|
  			self assert: (sourceMap at: cm methodReference) =
  				(cm getSourceFor: cm selector in: cm methodClass)].
  		Smalltalk allClassesAndTraitsDo:[:aClass|
  			self assert: (sourceMap at: aClass) = aClass comment].
  	]"
  
  	| fullName sourcesFile |
  	fullName := FileDirectory default fullNameFor: sourcesName.
  	(fullName endsWith: '.sources') ifFalse:[self error: 'New name must end with .sources'].
  	fullName = Smalltalk sourcesName ifFalse:[
  		"Copy sources file; change file name accordingly"
  		FileStream forceNewFileNamed: fullName do:[:newFile| | bufSize |
  			bufSize := 16r10000.
  			sourcesFile := (SourceFiles at: 1) readOnlyCopy.
  			sourcesFile position: 0.
  			'Copying sources...' displayProgressAt: Sensor cursorPoint 
  				from: 0 to: sourcesFile size during:[:bar|
  					[sourcesFile atEnd] whileFalse:[
  						bar value: sourcesFile position.
  						newFile nextPutAll: (sourcesFile next: bufSize)]].
  			newFile position = sourcesFile size ifFalse:[self error: 'File copy failed'].
  		].
  		self setMacFileInfoOn: fullName.
  		"Change to the new sources file and reopen"
  		self closeSourceFiles.
  		SourceFileVersionString := (FileDirectory localNameFor: fullName) 
  			allButLast: '.sources' size.
  		self openSourceFiles.
  	].
  
  	"We've copied the old to the new sources file; reopen the sources file read/write"
  	sourcesFile := SourceFiles at: 1.
  	sourcesFile close; open: sourcesFile fullName forWrite: true. "should be openReadWrite"
+ 	sourcesFile setToEnd; timeStamp. "remember when we did this"
- 	sourcesFile timeStamp. "remember when we did this"
  
  	"Copy method sources from changes to sources"
  	CompiledMethod allInstances do:[:method|
  		(method isInstalled and:[method fileIndex = 2]) ifTrue:[
  			| class selector category preamble changeList index chgRec string source |
  			class := method methodClass.
  			selector := method selector.
  			source := class sourceCodeAt: selector.
  			category := class organization categoryOfElement: selector.
  			preamble := class name, ' methodsFor: ', category asString printString,
  							' stamp: ', method timeStamp printString.
  
  			"Find the last version in the sources file; link up the prior: version"
  			changeList := ChangeSet scanVersionsOf: method 
  				class: class meta: class isMeta category: category  selector: selector.
  			index := changeList findLast:[:any| any fileIndex = 1].
  			index > 0 ifTrue:[
  				chgRec := changeList at: index.
  				preamble := preamble, ' prior: ', (SourceFiles 
  					sourcePointerFromFileIndex: chgRec fileIndex 
  					andPosition: chgRec position) printString].
  
  			"append to sources file"
  			sourcesFile setToEnd; cr; nextPut: $!!; nextChunkPut: preamble; cr.
  			string := RemoteString newString: source onFileNumber: 1 toFile: sourcesFile.
  			sourcesFile nextChunkPut: ' '.
  			method setSourcePosition: string position inFile: 1
  		].
  	] displayingProgress: 'Moving changes...'.
  
  	"Copy class comments from changes to sources"
  	self  allClassesAndTraitsDo: [:classOrTrait | 
  		classOrTrait moveClassCommentTo: sourcesFile fileIndex: 1.
  	].
  
  	"We've moved everything; reopen the source files"
  	self closeSourceFiles; openSourceFiles.
  
  	"Finally, run condenseChanges -- they *should* be empty 
  	but it's better to be safe than sorry"
  	self condenseChanges.
  !




More information about the Squeak-dev mailing list