ChangesBrowser.st
changeset 4632 c16dc83e3972
parent 4599 9a95e5ae08ad
child 4699 393443e15c9b
equal deleted inserted replaced
4631:3a23b0fd09e2 4632:c16dc83e3972
   686 ! !
   686 ! !
   687 
   687 
   688 !ChangesBrowser class methodsFor:'utilities'!
   688 !ChangesBrowser class methodsFor:'utilities'!
   689 
   689 
   690 isXMLFile:aFilename
   690 isXMLFile:aFilename
   691     |stream|
   691     |stream first|
   692 
   692 
   693     stream := aFilename asFilename readStream.
   693     stream := aFilename asFilename readStreamOrNil.
   694     stream isNil ifTrue:[^ false].
   694     stream isNil ifTrue:[^ false].
   695 
   695 
   696     stream skipSeparators.
   696     stream skipSeparators.
   697     stream peek == $< ifTrue:[
   697     first := stream peek.
   698         "/ assume, its an xml file
       
   699         stream close.
       
   700         ^ true
       
   701     ].
       
   702     stream close.
   698     stream close.
   703     ^ false
   699     ^ first == $<
   704 ! !
   700 ! !
   705 
   701 
   706 !ChangesBrowser methodsFor:'aspects'!
   702 !ChangesBrowser methodsFor:'aspects'!
   707 
   703 
   708 applyInOriginalNameSpace
   704 applyInOriginalNameSpace
  2184     "answer a stream for change"
  2180     "answer a stream for change"
  2185  
  2181  
  2186     |aStream|
  2182     |aStream|
  2187 
  2183 
  2188     (changeNr between:1 and:changePositions size) ifFalse:[^ nil].
  2184     (changeNr between:1 and:changePositions size) ifFalse:[^ nil].
  2189     aStream := FileStream readonlyFileNamed:changeFileName.
  2185     aStream := changeFileName asFilename readStreamOrNil.
  2190     aStream isNil ifTrue:[^ nil].
  2186     aStream isNil ifTrue:[^ nil].
  2191     aStream position1Based:(changePositions at:changeNr).
  2187     aStream position1Based:(changePositions at:changeNr).
  2192     ^ aStream
  2188     ^ aStream
  2193 ! !
  2189 ! !
  2194 
  2190 
  2274     (self class isXMLFile:changeFileName) ifTrue:[
  2270     (self class isXMLFile:changeFileName) ifTrue:[
  2275         ^ self class readXMLChangesFromFile:changeFileName inBackground:inBackground
  2271         ^ self class readXMLChangesFromFile:changeFileName inBackground:inBackground
  2276     ].
  2272     ].
  2277 
  2273 
  2278     f := changeFileName asFilename.
  2274     f := changeFileName asFilename.
  2279     aStream :=  f readStream.
  2275     aStream :=  f readStreamOrNil.
  2280     aStream isNil ifTrue:[^ nil].
  2276     aStream isNil ifTrue:[^ nil].
  2281 
  2277 
  2282     i := f info.
  2278     i := f info.
  2283     changeFileSize := i fileSize.
  2279     changeFileSize := i fileSize.
  2284     changeFileTimestamp := i modificationTime.
  2280     changeFileTimestamp := i modificationTime.
  2822         ]
  2818         ]
  2823     ].
  2819     ].
  2824 
  2820 
  2825     tempfile := Filename newTemporaryIn:nil.
  2821     tempfile := Filename newTemporaryIn:nil.
  2826     tempfile exists ifTrue:[tempfile remove].
  2822     tempfile exists ifTrue:[tempfile remove].
  2827 
  2823     [
  2828     outStream := tempfile writeStream.
  2824         outStream := tempfile writeStream.
  2829     outStream isNil ifTrue:[
  2825         inStream := changeFileName asFilename readStreamOrNil.
  2830         self warn:'cannot create temporary file in current directory.'.
  2826     ] on:FileStream openErrorSignal do:[:ex|
       
  2827         self warn:'cannot create temp file in current directory.'.
  2831         ^ false
  2828         ^ false
  2832     ].
  2829     ].
  2833 
       
  2834     inStream := FileStream readonlyFileNamed:changeFileName.
       
  2835     inStream isNil ifTrue:[^ false].
       
  2836 
  2830 
  2837     self withCursor:(Cursor write) do:[
  2831     self withCursor:(Cursor write) do:[
  2838         |excla sawExcla done first chunk
  2832         |excla sawExcla done first chunk
  2839          nChanges "{Class:SmallInteger}" |
  2833          nChanges "{Class:SmallInteger}" |
  2840 
  2834 
  2841         Stream writeErrorSignal handle:[:ex |
  2835         Stream writeErrorSignal handle:[:ex |
  2842             self warn:('could not update the changes file.\\' , ex description) withCRs.
  2836             self warn:('could not update the changes file.\\' , ex description) withCRs.
  2843             tempfile exists ifTrue:[tempfile remove].
  2837             tempfile exists ifTrue:[tempfile remove].
  2844             ^ false
  2838             ^ false
  2845         ] do:[
  2839         ] do:[
  2846 
       
  2847             excla := inStream class chunkSeparator.
  2840             excla := inStream class chunkSeparator.
  2848             nChanges := self numberOfChanges.
  2841             nChanges := self numberOfChanges.
  2849 
  2842 
  2850             1 to:nChanges do:[:index |
  2843             1 to:nChanges do:[:index |
  2851                 inStream position1Based:(changePositions at:index).
  2844                 inStream position1Based:(changePositions at:index).
  2932     ].
  2925     ].
  2933     chunk withoutSeparators isEmpty ifTrue:[
  2926     chunk withoutSeparators isEmpty ifTrue:[
  2934         self error:'empty chunk - should not happen'.
  2927         self error:'empty chunk - should not happen'.
  2935     ].
  2928     ].
  2936 
  2929 
  2937     outStream := FileStream oldFileNamed:fileName.
  2930     [
  2938     outStream isNil ifTrue:[
  2931         outStream := fileName asFilename readWriteStream.
  2939         outStream isNil ifTrue:[
  2932     ] on:FileStream openErrorSignal do:[:ex|
  2940             outStream := FileStream newFileNamed:fileName.
  2933         self warn:'cannot update file ''%1''' with:fileName.
  2941             outStream isNil ifTrue:[
  2934         ^ false
  2942                 self warn:'cannot update file ''%1''' with:fileName.
       
  2943                 ^ false
       
  2944             ]
       
  2945         ]
       
  2946     ].
  2935     ].
  2947 
  2936 
  2948     outStream setToEnd.
  2937     outStream setToEnd.
  2949 
  2938 
  2950     sawExcla ifTrue:[
  2939     sawExcla ifTrue:[
  3462      otherwise, only changes for that class are compressed."
  3451      otherwise, only changes for that class are compressed."
  3463 
  3452 
  3464     |lbl aStream searchIndex anyMore deleteSet index  
  3453     |lbl aStream searchIndex anyMore deleteSet index  
  3465      str snapshotProto snapshotPrefix snapshotNameIndex fileName|
  3454      str snapshotProto snapshotPrefix snapshotNameIndex fileName|
  3466 
  3455 
  3467     aStream := FileStream readonlyFileNamed:changeFileName.
  3456     aStream := changeFileName asFilename readStreamOrNil.
  3468     aStream isNil ifTrue:[^ self].
  3457     aStream isNil ifTrue:[^ self].
  3469 
  3458 
  3470     aClassNameOrNil isNil ifTrue:[
  3459     aClassNameOrNil isNil ifTrue:[
  3471         selectorToCompressOrNil isNil ifTrue:[
  3460         selectorToCompressOrNil isNil ifTrue:[
  3472             lbl := 'compressing...'.
  3461             lbl := 'compressing...'.
  5464 ! !
  5453 ! !
  5465 
  5454 
  5466 !ChangesBrowser class methodsFor:'documentation'!
  5455 !ChangesBrowser class methodsFor:'documentation'!
  5467 
  5456 
  5468 version
  5457 version
  5469     ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.288 2003-02-25 11:48:10 cg Exp $'
  5458     ^ '$Header: /cvs/stx/stx/libtool/ChangesBrowser.st,v 1.289 2003-03-02 18:27:53 stefan Exp $'
  5470 ! !
  5459 ! !