'From etoys2.2 of 1 October 2007 [latest update: #1766] on 8 November 2007 at 3:00:35 pm'! "Change Set: AllowReadonlyChanges-yo Date: 8 November 2007 Author: Yoshiki Ohshima For the view source feature, this change set supports readonly .changes file more gracefully."! !ClassDescription methodsFor: 'fileIn/Out' stamp: 'yo 11/8/2007 11:31'! classComment: aString stamp: aStamp "Store the comment, aString or Text or RemoteString, associated with the class we are organizing. Empty string gets stored only if had a non-empty one before." | ptr header file oldCommentRemoteStr | (aString isKindOf: RemoteString) ifTrue: [SystemChangeNotifier uniqueInstance classCommented: self. ^ self organization classComment: aString stamp: aStamp]. oldCommentRemoteStr _ self organization commentRemoteStr. (aString size = 0) & (oldCommentRemoteStr == nil) ifTrue: [^ self organization classComment: nil]. "never had a class comment, no need to write empty string out" ptr _ oldCommentRemoteStr ifNil: [0] ifNotNil: [oldCommentRemoteStr sourcePointer]. (SourceFiles notNil and: [(file _ SourceFiles at: 2) notNil and: [file isReadOnly not]]) ifTrue: [ [file setToEnd; cr; nextPut: $!!. "directly" "Should be saying (file command: 'H3') for HTML, but ignoring it here" header _ String streamContents: [:strm | strm nextPutAll: self name; nextPutAll: ' commentStamp: '. aStamp storeOn: strm. strm nextPutAll: ' prior: '; nextPutAll: ptr printString]. file nextChunkPut: header]]. self organization classComment: (RemoteString newString: aString onFileNumber: 2) stamp: aStamp. SystemChangeNotifier uniqueInstance classCommented: self. ! ! !CompiledMethod methodsFor: 'source code management' stamp: 'yo 11/8/2007 11:15'! putSource: sourceStr fromParseNode: methodNode inFile: fileIndex withPreamble: preambleBlock "Store the source code for the receiver on an external file. If no sources are available, i.e., SourceFile is nil, then store temp names for decompilation at the end of the method. If the fileIndex is 1, print on *.sources; if it is 2, print on *.changes, in each case, storing a 4-byte source code pointer at the method end." | file remoteString st80str | (SourceFiles == nil or: [(file _ SourceFiles at: fileIndex) == nil or: [file isReadOnly]]) ifTrue: [^ self become: (self copyWithTempNames: methodNode tempNames)]. SmalltalkImage current assureStartupStampLogged. file setToEnd. preambleBlock value: file. "Write the preamble" (methodNode isKindOf: DialectMethodNode) ifTrue: ["This source was parsed from an alternate syntax. We must convert to ST80 before logging it." st80str _ (DialectStream dialect: #ST80 contents: [:strm | methodNode printOn: strm]) asString. remoteString _ RemoteString newString: st80str onFileNumber: fileIndex toFile: file] ifFalse: [remoteString _ RemoteString newString: sourceStr onFileNumber: fileIndex toFile: file]. file nextChunkPut: ' '. InMidstOfFileinNotification signal ifFalse: [file flush]. self checkOKToAdd: sourceStr size at: remoteString position. self setSourcePosition: remoteString position inFile: fileIndex! ! !FileDirectory class methodsFor: 'system start up' stamp: 'yo 11/8/2007 14:37'! openSources: sourcesName andChanges: changesName forImage: imageName "Open the changes and sources files and install them in SourceFiles. Inform the user of problems regarding write permissions or CR/CRLF mixups." "Note: SourcesName and imageName are full paths; changesName is a local name." | sources changes msg wmsg | msg _ 'Squeak cannot locate &fileRef. Please check that the file is named properly and is in the same directory as this image. Further explanation can found in the startup window, ''How Squeak Finds Source Code''.'. wmsg _ 'Squeak cannot write to &fileRef. Please check that you have write permission for this file. You won''t be able to save this image correctly until you fix this.'. sources _ self openSources: sourcesName forImage: imageName. changes _ self openChanges: changesName forImage: imageName. ((sources == nil or: [sources atEnd]) and: [Preferences valueOfFlag: #warnIfNoSourcesFile]) ifTrue: [SmalltalkImage current platformName = 'Mac OS' ifTrue: [msg _ msg , ' Make sure the sources file is not an Alias.']. self inform: (msg copyReplaceAll: '&fileRef' with: 'the sources file named ' , sourcesName)]. (changes == nil and: [Preferences valueOfFlag: #warnIfNoChangesFile]) ifTrue: [self inform: (msg copyReplaceAll: '&fileRef' with: 'the changes file named ' , changesName)]. ((Preferences valueOfFlag: #warnIfNoChangesFile) and: [changes notNil]) ifTrue: [changes isReadOnly ifTrue: [Preferences warnIfChangesFileReadOnly ifTrue: [ self inform: (wmsg copyReplaceAll: '&fileRef' with: 'the changes file named ' , changesName)]]. ((changes next: 200) includesSubString: String crlf) ifTrue: [self inform: 'The changes file named ' , changesName , ' has been injured by an unpacking utility. Crs were changed to CrLfs. Please set the preferences in your decompressing program to "do not convert text files" and unpack the system again.']]. SourceFiles _ Array with: sources with: changes! ! !ReleaseBuilderSqueakland methodsFor: 'utilities' stamp: 'yo 11/8/2007 14:36'! finalCleanupForOLPC "ReleaseBuilderSqueakland new finalCleanupForOLPC" Smalltalk condenseChanges. Preferences disable: #warnIfNoChangesFile. Preferences disable: #warnIfChangesFileReadOnly. Preferences disable: #warnIfNoSourcesFile. Smalltalk zapAllOtherProjects. super finalCleanup. ! ! !ReleaseBuilderSqueakland methodsFor: 'olpc' stamp: 'yo 11/7/2007 16:50'! cleanupForOLPC "Perform various image cleanups in preparation for making a Squeak gamma release candidate image." "ReleaseBuilderSqueakland new cleanupForOLPC" self initialCleanup; finalStripping; installReleaseSpecificsForOLPC; finalCleanupForOLPC. Preferences cambridge. Display isVirtualScreen ifTrue: [ OLPCVirtualScreen unInstall ]. Display newDepth: 16. Project current displayDepth: 16. PartsBin rebuildIconsWithProgress. ! ! !RemoteString methodsFor: 'private' stamp: 'yo 11/8/2007 14:02'! string: aString onFileNumber: fileNumber "Store this as my string if source files exist." | theFile | (SourceFiles at: fileNumber) == nil ifFalse: [theFile _ SourceFiles at: fileNumber. theFile isReadOnly ifTrue: [^ nil]. theFile setToEnd; cr. self string: aString onFileNumber: fileNumber toFile: theFile]! ! !SmalltalkImage methodsFor: 'sources, change log' stamp: 'yo 11/8/2007 14:59'! logChange: aStringOrText "Write the argument, aString, onto the changes file." | aString changesFile | (SourceFiles isNil or: [(SourceFiles at: 2) == nil]) ifTrue: [^ self]. (changesFile _ SourceFiles at: 2). changesFile isReadOnly ifTrue:[^self]. self assureStartupStampLogged. aString := aStringOrText asString. (aString findFirst: [:char | char isSeparator not]) = 0 ifTrue: [^ self]. "null doits confuse replay" changesFile setToEnd; cr; cr. changesFile nextChunkPut: aString. "If want style changes in DoIt, use nextChunkPutWithStyle:, and allow Texts to get here" self forceChangesToDisk.! ! "Postscript: " Preferences addBooleanPreference: #warnIfChangesFileReadOnly categories: #('general') default: true balloonHelp: 'if true, you will be warned, whenever the changes file is read only'. !