changeset 18466 | 326bcf80428f |
parent 18140 | 1e791dffc7c1 |
18465:65bedc821a46 | 18466:326bcf80428f |
---|---|
1 "{ Encoding: utf8 }" |
|
2 |
|
1 " |
3 " |
2 COPYRIGHT (c) 2009 by eXept Software AG |
4 COPYRIGHT (c) 2009 by eXept Software AG |
3 All Rights Reserved |
5 All Rights Reserved |
4 |
6 |
5 This software is furnished under a license and may be used |
7 This software is furnished under a license and may be used |
70 DiffCommandTemplate := aCommandTemplateString |
72 DiffCommandTemplate := aCommandTemplateString |
71 ! ! |
73 ! ! |
72 |
74 |
73 !DiffListUtility class methodsFor:'private'! |
75 !DiffListUtility class methodsFor:'private'! |
74 |
76 |
75 saveForDiff:text as:filename |
77 saveForDiff:text on:stream |
76 |stream| |
|
77 |
|
78 [ |
78 [ |
79 stream := filename writeStream. |
|
80 text do:[:line | |
79 text do:[:line | |
81 |lOut i| |
80 |lOut i| |
82 |
81 |
83 line notEmptyOrNil ifTrue:[ |
82 line notEmptyOrNil ifTrue:[ |
84 lOut := line. |
83 lOut := line. |
131 6 : '> line2' |
130 6 : '> line2' |
132 7 : '4d4' |
131 7 : '4d4' |
133 8 : '< line4' |
132 8 : '< line4' |
134 " |
133 " |
135 |
134 |
136 |tmpFile1 tmpFile2 stream line |
135 |stream line |
137 diffList diffTemplate diffCmd| |
136 diffList diffTemplate diffCmd tmpStream1 tmpStream2| |
138 |
137 |
139 diffTemplate := self diffCommand. |
138 diffTemplate := self diffCommand. |
140 diffTemplate isEmptyOrNil ifTrue:[ |
139 diffTemplate isEmptyOrNil ifTrue:[ |
141 "/ self warn:'no diff command available'. |
140 "/ self warn:'no diff command available'. |
142 ^ nil |
141 ^ nil |
149 |
148 |
150 " |
149 " |
151 save them texts in two temporary files ... |
150 save them texts in two temporary files ... |
152 " |
151 " |
153 [ |
152 [ |
154 self saveForDiff:text1 as:(tmpFile1 := Filename newTemporary). |
153 self saveForDiff:text1 on:(tmpStream1 := FileStream newTemporary). |
155 self saveForDiff:text2 as:(tmpFile2 := Filename newTemporary). |
154 self saveForDiff:text2 on:(tmpStream2 := FileStream newTemporary). |
155 tmpStream1 close. |
|
156 tmpStream2 close. |
|
156 |
157 |
157 " |
158 " |
158 start diff on it ... |
159 start diff on it ... |
159 " |
160 " |
160 diffCmd := diffTemplate |
161 diffCmd := diffTemplate |
161 bindWith:tmpFile1 asString |
162 bindWith:tmpStream1 pathName |
162 with:tmpFile2 asString. |
163 with:tmpStream2 pathName. |
163 |
164 |
164 stream := PipeStream readingFrom:diffCmd. |
165 stream := PipeStream readingFrom:diffCmd. |
165 stream isNil ifTrue:[ |
166 stream isNil ifTrue:[ |
166 "this code is not reached in win32. |
167 "this code is not reached in win32. |
167 PipeStream starts a cmd.exe, which is always successful |
168 PipeStream starts a cmd.exe, which is always successful |
168 at the first place and fails later" |
169 at the first place and fails later" |
169 stream := PipeStream readingFrom:('support' asFilename / diffCmd). |
170 stream := PipeStream readingFrom:('support' asFilename constructString:diffCmd). |
170 stream isNil ifTrue:[ |
171 stream isNil ifTrue:[ |
171 self error:'cannot execute diff' mayProceed:true. |
172 self error:'cannot execute diff' mayProceed:true. |
172 ^ nil. |
173 ^ nil. |
173 ] |
174 ] |
174 ]. |
175 ]. |
185 line := stream nextLine. |
186 line := stream nextLine. |
186 line notNil ifTrue:[diffList add:line] |
187 line notNil ifTrue:[diffList add:line] |
187 ]. |
188 ]. |
188 stream close. |
189 stream close. |
189 ] ensure:[ |
190 ] ensure:[ |
190 tmpFile1 notNil ifTrue:[ tmpFile1 remove ]. |
191 tmpStream1 notNil ifTrue:[ tmpStream1 fileName remove ]. |
191 tmpFile2 notNil ifTrue:[ tmpFile2 remove ]. |
192 tmpStream2 notNil ifTrue:[ tmpStream2 fileName remove ]. |
192 ]. |
193 ]. |
193 ^ diffList |
194 ^ diffList |
194 |
195 |
195 " |
196 " |
196 self |
197 self |