838 |
838 |
839 currentNameSpace := Smalltalk. |
839 currentNameSpace := Smalltalk. |
840 currentPackage := Class packageQuerySignal query. |
840 currentPackage := Class packageQuerySignal query. |
841 |
841 |
842 (reader := aReader) isNil ifTrue:[ |
842 (reader := aReader) isNil ifTrue:[ |
843 reader := ChangeFileReader new. |
843 reader := ChangeFileReader new. |
844 ]. |
844 ]. |
845 |
845 |
846 aStream isEncodedStream ifTrue:[ |
846 aStream isEncodedStream ifTrue:[ |
847 encodedStream := aStream |
847 encodedStream := aStream |
848 ] ifFalse:[ |
848 ] ifFalse:[ |
849 aStream isPositionable ifTrue:[ |
849 aStream isPositionable ifTrue:[ |
850 encodedStream := EncodedStream decodedStreamFor: aStream |
850 encodedStream := EncodedStream decodedStreamFor: aStream |
851 ] ifFalse:[ |
851 ] ifFalse:[ |
852 encodedStream := EncodedStream stream: aStream encoder: CharacterEncoder nullEncoderInstance |
852 encodedStream := EncodedStream stream: aStream encoder: CharacterEncoder nullEncoderInstance |
853 ]. |
853 ]. |
854 ]. |
854 ]. |
855 reportProgress := encodedStream stream isPositionable |
855 reportProgress := encodedStream stream isPositionable |
856 and:[ ProgressNotification notNil |
856 and:[ ProgressNotification notNil |
857 and:[ ProgressNotification isHandled ]]. |
857 and:[ ProgressNotification isHandled ]]. |
858 reportProgress ifTrue:[ |
858 reportProgress ifTrue:[ |
859 size := encodedStream stream size. |
859 size := encodedStream stream size. |
860 ]. |
860 ]. |
861 |
861 |
862 reader changeSet:aChangeSet. |
862 reader changeSet:aChangeSet. |
863 reader changeAction:aBlock. |
863 reader changeAction:aBlock. |
864 reader inputStream:encodedStream. |
864 reader inputStream:encodedStream. |
865 |
865 |
866 [encodedStream atEnd] whileFalse:[ |
866 [encodedStream atEnd] whileFalse:[ |
867 encodedStream skipSeparators. |
867 encodedStream skipSeparators. |
868 lineNumber := encodedStream lineNumber. |
868 lineNumber := encodedStream lineNumber. |
869 |
869 |
870 |
870 |
871 reportProgress ifTrue:[ |
871 reportProgress ifTrue:[ |
872 pos := encodedStream position + 1. |
872 pos := encodedStream position + 1. |
873 ProgressNotification notify: nil progress:(100 / size) * pos. |
873 ProgressNotification notify: nil progress:(100 / size) * pos. |
874 ]. |
874 ]. |
875 |
875 |
876 chunk := encodedStream nextChunk. |
876 chunk := encodedStream nextChunk. |
877 |
877 |
878 (chunk notEmptyOrNil) ifTrue:[ |
878 (chunk notEmptyOrNil) ifTrue:[ |
879 Class nameSpaceQuerySignal handle:[:ex| ex proceedWith:currentNameSpace] do:[ |
879 Class nameSpaceQuerySignal handle:[:ex| ex proceedWith:currentNameSpace] do:[ |
880 Class packageQuerySignal handle:[:ex| ex proceedWith:currentPackage] do:[ |
880 Class packageQuerySignal handle:[:ex| ex proceedWith:currentPackage] do:[ |
881 |parser tree ns pkg| |
881 |parser tree ns pkg| |
882 |
882 |
883 parser := Parser for:chunk. |
883 parser := Parser for:chunk. |
884 "/ parser parseForCode. |
884 "/ parser parseForCode. |
885 Parser parseErrorSignal handle:[:ex | |
885 Parser parseErrorSignal handle:[:ex | |
886 Transcript showCR:'ChangeSet: error while reading: ',ex description. |
886 Transcript showCR:'ChangeSet: error while reading: ',ex description. |
887 tree := #Error. |
887 tree := #Error. |
888 ] do:[ |
888 ] do:[ |
889 tree := parser |
889 tree := parser |
890 parseExpressionWithSelf:nil |
890 parseExpressionWithSelf:nil |
891 notifying:nil |
891 notifying:nil |
892 ignoreErrors:true |
892 ignoreErrors:true |
893 ignoreWarnings:true |
893 ignoreWarnings:true |
894 inNameSpace:currentNameSpace. |
894 inNameSpace:currentNameSpace. |
895 ]. |
895 ]. |
896 tree ~~ #Error ifTrue:[ |
896 tree ~~ #Error ifTrue:[ |
897 tree isNil ifTrue:[ |
897 tree isNil ifTrue:[ |
898 "/ Hmm....it could be package-definition chunk in extensions container... |
898 "/ Hmm....it could be package-definition chunk in extensions container... |
899 "/ if there is any package directive in there, extract it. |
899 "/ if there is any package directive in there, extract it. |
900 ((pkg := parser currentPackage) notNil |
900 ((pkg := parser currentPackage) notNil |
901 and:[pkg ~~ currentPackage]) ifTrue:[ |
901 and:[pkg ~~ currentPackage]) ifTrue:[ |
902 currentPackage := pkg |
902 currentPackage := pkg |
903 ] ifFalse:[ |
903 ] ifFalse:[ |
904 "/ if there is any nameSpace directive in there, extract it. |
904 "/ if there is any nameSpace directive in there, extract it. |
905 ((ns := parser currentNameSpace) notNil |
905 ((ns := parser currentNameSpace) notNil |
906 and:[ns ~~ currentNameSpace]) ifTrue:[ |
906 and:[ns ~~ currentNameSpace]) ifTrue:[ |
907 currentNameSpace := ns |
907 currentNameSpace := ns |
908 ] ifFalse:[ |
908 ] ifFalse:[ |
909 change := DoItChange new. |
909 change := DoItChange new. |
910 change source:chunk. |
910 change source:chunk. |
911 aBlock valueWithOptionalArgument:change and:lineNumber and:pos. |
911 aBlock valueWithOptionalArgument:change and:lineNumber and:pos. |
912 ]. |
912 ]. |
913 ]. |
913 ]. |
914 ] ifFalse:[ |
914 ] ifFalse:[ |
915 "/ if there is any nameSpace directive in there, extract it. |
915 "/ if there is any nameSpace directive in there, extract it. |
916 ((ns := parser currentNameSpace) notNil |
916 ((ns := parser currentNameSpace) notNil |
917 and:[ns ~~ currentNameSpace]) ifTrue:[ |
917 and:[ns ~~ currentNameSpace]) ifTrue:[ |
918 currentNameSpace := ns |
918 currentNameSpace := ns |
919 ]. |
919 ]. |
920 "/ if there is any package directive in there, extract it. |
920 "/ if there is any package directive in there, extract it. |
921 ((pkg := parser currentPackage) notNil |
921 ((pkg := parser currentPackage) notNil |
922 and:[pkg ~~ currentPackage]) ifTrue:[ |
922 and:[pkg ~~ currentPackage]) ifTrue:[ |
923 currentPackage := pkg |
923 currentPackage := pkg |
924 ]. |
924 ]. |
925 "/ |
925 "/ |
926 "/ what type of chunk is this ... |
926 "/ what type of chunk is this ... |
927 "/ |
927 "/ |
928 tree isConstant ifTrue:[ |
928 tree isConstant ifTrue:[ |
929 (s := tree evaluate) isString ifTrue:[ |
929 (s := tree evaluate) isString ifTrue:[ |
930 (s startsWith:'---- ') ifTrue:[ |
930 (s startsWith:'---- ') ifTrue:[ |
931 reader inputStream: s readStream. |
931 reader inputStream: s readStream. |
932 reader processInfo: s. |
932 reader processInfo: s. |
933 reader inputStream: encodedStream. |
933 reader inputStream: encodedStream. |
934 ]. |
934 ]. |
935 ] ifFalse:[ |
935 ] ifFalse:[ |
936 self error:'unexpected change-chunk' mayProceed:true |
936 self error:'unexpected change-chunk' mayProceed:true |
937 ] |
937 ] |
938 ] ifFalse:[ |
938 ] ifFalse:[ |
939 tree isMessage ifTrue:[ |
939 tree isMessage ifTrue:[ |
940 (reader |
940 (reader |
941 changesFromParseTree:tree |
941 changesFromParseTree:tree |
942 lineNumber:lineNumber |
942 lineNumber:lineNumber |
943 position:pos |
943 position:pos |
944 chunk: chunk |
944 chunk: chunk |
945 ) ifFalse:[ |
945 ) ifFalse:[ |
946 change := DoItChange new. |
946 change := DoItChange new. |
947 change source:chunk. |
947 change source:chunk. |
948 aBlock valueWithOptionalArgument:change and:lineNumber and:pos. |
948 aBlock valueWithOptionalArgument:change and:lineNumber and:pos. |
949 ] |
949 ] |
950 ] ifFalse:[ |
950 ] ifFalse:[ |
951 InvalidChangeChunkError |
951 InvalidChangeChunkError |
952 raiseRequestErrorString:('unexpected change-chunk i nor around line %1' bindWith:lineNumber) |
952 raiseRequestErrorString:('unexpected change-chunk in or around line %1' bindWith:lineNumber) |
953 ] |
953 ] |
954 ] |
954 ] |
955 ] |
955 ] |
956 ] |
956 ] |
957 ] |
957 ] |
958 ] |
958 ] |
959 ] |
959 ] |
960 ]. |
960 ]. |
961 |
961 |
962 " |
962 " |
963 ChangeSet fromStream:('changes' asFilename readStream) |
963 ChangeSet fromStream:('changes' asFilename readStream) |
964 ChangeSet fromStream:('patches' asFilename readStream) |
964 ChangeSet fromStream:('patches' asFilename readStream) |