ChangesBrowser.st
changeset 1566 7a4ef80fb49b
parent 1496 978b3c3565c9
child 1594 834765de8cb5
--- a/ChangesBrowser.st	Tue Apr 21 02:37:47 1998 +0200
+++ b/ChangesBrowser.st	Tue Apr 21 18:51:53 1998 +0200
@@ -1941,10 +1941,10 @@
     |inStream outStream tempfile stamp f|
 
     editingClassSource ifTrue:[
-	(self confirm:'You are editing a classes sourceFile (not a changeFile) !!\\Are you certain, you want to overwrite it ?' withCRs)
-	ifFalse:[
-	    ^ false
-	]
+        (self confirm:'You are editing a classes sourceFile (not a changeFile) !!\\Are you certain, you want to overwrite it ?' withCRs)
+        ifFalse:[
+            ^ false
+        ]
     ].
 
     tempfile := Filename newTemporaryIn:nil.
@@ -1952,70 +1952,84 @@
 
     outStream := tempfile writeStream.
     outStream isNil ifTrue:[
-	self warn:'cannot create temporary file in current directory.'.
-	^ false
+        self warn:'cannot create temporary file in current directory.'.
+        ^ false
     ].
 
     inStream := FileStream readonlyFileNamed:changeFileName.
     inStream isNil ifTrue:[^ false].
 
     self withCursor:(Cursor write) do:[
-	|excla sawExcla done chunk
-	 nChanges "{Class:SmallInteger}" |
-
-	Stream writeErrorSignal handle:[:ex |
-	    self warn:('could not update the changes file.\\' , ex errorString) withCRs.
-	    ^ false
-	] do:[
-
-	    excla := inStream class chunkSeparator.
-	    nChanges := self numberOfChanges.
-
-	    1 to:nChanges do:[:index |
-		inStream position:(changePositions at:index).
-		sawExcla := inStream peekFor:excla.
-		chunk := inStream nextChunk.
-		(stamp := changeTimeStamps at:index) notNil ifTrue:[
-		    outStream nextPutAll:'''---- timestamp ' , stamp , ' ----'''.
-		    outStream nextPut:excla; cr.
-		].
-
-		sawExcla ifTrue:[
-		    outStream nextPut:excla.
-		    outStream nextChunkPut:chunk.
-		    outStream cr.
-		    "
-		     a method-definition chunk - skip followups
-		    "
-		    done := false.
-		    [done] whileFalse:[
-			chunk := inStream nextChunk.
-			chunk isNil ifTrue:[
-			    done := true
-			] ifFalse:[
-			    outStream nextChunkPut:chunk.
-			    outStream cr.
-			    done := chunk isEmpty
-			]
-		    ].
-		] ifFalse:[
-		    outStream nextChunkPut:chunk.
-		    outStream cr
-		]
-	    ].
-	    outStream close.
-	    inStream close.
-	].
-
-	f := changeFileName asFilename.
-	f renameTo:(f withSuffix:'bak').
-	tempfile renameTo:changeFileName.
-	anyChanges := false
+        |excla sawExcla done first chunk
+         nChanges "{Class:SmallInteger}" |
+
+        Stream writeErrorSignal handle:[:ex |
+            self warn:('could not update the changes file.\\' , ex errorString) withCRs.
+            tempfile exists ifTrue:[tempfile remove].
+            ^ false
+        ] do:[
+
+            excla := inStream class chunkSeparator.
+            nChanges := self numberOfChanges.
+
+            1 to:nChanges do:[:index |
+                inStream position:(changePositions at:index).
+                sawExcla := inStream peekFor:excla.
+                chunk := inStream nextChunk.
+
+                (chunk notNil
+                and:[(chunk startsWith:'''---- snap') not]) ifTrue:[
+                    (stamp := changeTimeStamps at:index) notNil ifTrue:[
+                        outStream nextPutAll:'''---- timestamp ' , stamp , ' ----'''.
+                        outStream nextPut:excla; cr.
+                    ].
+                ].
+
+                sawExcla ifTrue:[
+                    outStream nextPut:excla.
+                    outStream nextChunkPut:chunk.
+                    outStream cr; cr.
+                    "
+                     a method-definition chunk - output followups
+                    "
+                    done := false.
+                    first := true.
+                    [done] whileFalse:[
+                        chunk := inStream nextChunk.
+                        chunk isNil ifTrue:[
+                            outStream cr; cr.
+                            done := true
+                        ] ifFalse:[
+                            chunk isEmpty ifTrue:[
+                                outStream space; nextChunkPut:chunk; cr; cr.
+                                done := true.
+                            ] ifFalse:[
+                                first ifFalse:[
+                                    outStream cr; cr.
+                                ].
+                                outStream nextChunkPut:chunk.
+                            ].
+                        ].
+                        first := false.
+                    ].
+                ] ifFalse:[
+                    outStream nextChunkPut:chunk.
+                    outStream cr
+                ]
+            ].
+            outStream close.
+            inStream close.
+        ].
+
+        f := changeFileName asFilename.
+        f renameTo:(f withSuffix:'bak').
+        tempfile renameTo:changeFileName.
+        anyChanges := false
     ].
     ^ true
 
-    "Modified: 2.12.1996 / 22:29:15 / stefan"
-    "Modified: 31.7.1997 / 18:27:14 / cg"
+    "Modified: / 2.12.1996 / 22:29:15 / stefan"
+    "Modified: / 21.4.1998 / 17:50:11 / cg"
 ! !
 
 !ChangesBrowser methodsFor:'termination'!
@@ -2684,5 +2698,5 @@
 !ChangesBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.130 1998-02-26 18:11:03 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.131 1998-04-21 16:51:53 cg Exp $'
 ! !