13833
|
1 |
"
|
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
|
12 |
"{ Package: 'stx:libtool' }"
|
|
13 |
|
|
14 |
"{ NameSpace: Tools }"
|
|
15 |
|
|
16 |
DiffCodeView2 subclass:#Diff3CodeView2
|
|
17 |
instanceVariableNames:''
|
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Interface-CodeView'
|
|
21 |
!
|
|
22 |
|
|
23 |
Object subclass:#Diff3Data
|
|
24 |
instanceVariableNames:'text1 list1 text2 list2 text3 list3 inserted1 inserted2 inserted3
|
|
25 |
deleted changed'
|
|
26 |
classVariableNames:''
|
|
27 |
poolDictionaries:''
|
|
28 |
privateIn:Diff3CodeView2
|
|
29 |
!
|
|
30 |
|
|
31 |
!Diff3CodeView2 class methodsFor:'documentation'!
|
|
32 |
|
|
33 |
copyright
|
|
34 |
"
|
|
35 |
COPYRIGHT (c) 2006 by eXept Software AG
|
|
36 |
All Rights Reserved
|
|
37 |
|
|
38 |
This software is furnished under a license and may be used
|
|
39 |
only in accordance with the terms of that license and with the
|
|
40 |
inclusion of the above copyright notice. This software may not
|
|
41 |
be provided or otherwise made available to, or used by, any
|
|
42 |
other person. No title to or ownership of the software is
|
|
43 |
hereby transferred.
|
|
44 |
"
|
|
45 |
! !
|
|
46 |
|
|
47 |
!Diff3CodeView2 class methodsFor:'defaults'!
|
|
48 |
|
|
49 |
numberOfViews
|
|
50 |
"return the number of the synced subViews.
|
|
51 |
Usually redefined in subclasses"
|
|
52 |
|
|
53 |
^ 3
|
|
54 |
|
|
55 |
"Created: / 16-03-2012 / 12:56:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
56 |
! !
|
|
57 |
|
|
58 |
!Diff3CodeView2 methodsFor:'accessing'!
|
|
59 |
|
|
60 |
computeDiffDataForText1:t1 text2:t2 text3: t3
|
|
61 |
|
|
62 |
^Diff3Data new
|
|
63 |
computeDiffDataForText1:t1 text2:t2 text3: t3;
|
|
64 |
yourself
|
|
65 |
|
|
66 |
"Created: / 16-03-2012 / 20:49:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
67 |
!
|
|
68 |
|
|
69 |
text1:t1 text2:t2 text3: t3
|
|
70 |
|data|
|
|
71 |
|
|
72 |
data := self computeDiffDataForText1:t1 text2:t2 text3: t3.
|
|
73 |
|
|
74 |
(textViews at:1)
|
|
75 |
list:(data list1);
|
|
76 |
deletedLines:#();
|
|
77 |
changedLines:(data changed);
|
|
78 |
insertedLines:(data inserted1);
|
|
79 |
originDiffText:t1;
|
|
80 |
emptyLines:#().
|
|
81 |
|
|
82 |
(textViews at:2)
|
|
83 |
list:(data list2);
|
|
84 |
deletedLines:#();
|
|
85 |
changedLines:(data changed);
|
|
86 |
insertedLines:(data inserted2);
|
|
87 |
originDiffText:t2;
|
|
88 |
emptyLines:#().
|
|
89 |
|
|
90 |
(textViews at:3)
|
|
91 |
list:(data list3);
|
|
92 |
deletedLines:#();
|
|
93 |
changedLines:(data changed);
|
|
94 |
insertedLines:(data inserted3);
|
|
95 |
originDiffText:t3;
|
|
96 |
emptyLines:#().
|
|
97 |
|
|
98 |
"Modified: / 22-06-2010 / 21:36:35 / Jakub <zelenja7@fel.cvut.cz>"
|
|
99 |
"Created: / 16-03-2012 / 12:58:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
100 |
! !
|
|
101 |
|
|
102 |
!Diff3CodeView2::Diff3Data methodsFor:'accessing'!
|
|
103 |
|
|
104 |
changed
|
|
105 |
|
|
106 |
^changed copy
|
|
107 |
|
|
108 |
"Modified: / 02-05-2010 / 19:31:18 / Jakub <zelenja7@fel.cvut.cz>"
|
|
109 |
"Modified: / 16-07-2010 / 09:35:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
110 |
!
|
|
111 |
|
|
112 |
changed:something
|
|
113 |
changed := something.
|
|
114 |
!
|
|
115 |
|
|
116 |
deleted
|
|
117 |
^ deleted
|
|
118 |
!
|
|
119 |
|
|
120 |
deleted:something
|
|
121 |
deleted := something.
|
|
122 |
!
|
|
123 |
|
|
124 |
inserted1
|
|
125 |
^ inserted1
|
|
126 |
!
|
|
127 |
|
|
128 |
inserted2
|
|
129 |
^ inserted2
|
|
130 |
!
|
|
131 |
|
|
132 |
inserted3
|
|
133 |
^ inserted3
|
|
134 |
!
|
|
135 |
|
|
136 |
list1
|
|
137 |
^ list1
|
|
138 |
!
|
|
139 |
|
|
140 |
list1:something
|
|
141 |
list1 := something.
|
|
142 |
!
|
|
143 |
|
|
144 |
list2
|
|
145 |
^ list2
|
|
146 |
!
|
|
147 |
|
|
148 |
list2:something
|
|
149 |
list2 := something.
|
|
150 |
!
|
|
151 |
|
|
152 |
list3
|
|
153 |
^ list3
|
|
154 |
!
|
|
155 |
|
|
156 |
list3:something
|
|
157 |
list3 := something.
|
|
158 |
!
|
|
159 |
|
|
160 |
text1
|
|
161 |
^ text1
|
|
162 |
!
|
|
163 |
|
|
164 |
text1:something
|
|
165 |
text1 := something.
|
|
166 |
!
|
|
167 |
|
|
168 |
text2
|
|
169 |
^ text2
|
|
170 |
!
|
|
171 |
|
|
172 |
text2:something
|
|
173 |
text2 := something.
|
|
174 |
!
|
|
175 |
|
|
176 |
text3
|
|
177 |
^ text3
|
|
178 |
!
|
|
179 |
|
|
180 |
text3:something
|
|
181 |
text3 := something.
|
|
182 |
! !
|
|
183 |
|
|
184 |
!Diff3CodeView2::Diff3Data methodsFor:'computing'!
|
|
185 |
|
|
186 |
addLines: total from: src to: dst chunk: chunk
|
|
187 |
|
|
188 |
^chunk isSequenceable ifTrue:[
|
|
189 |
dst addAll: chunk.
|
|
190 |
(total - chunk size) timesRepeat: [
|
|
191 |
dst add: nil.
|
|
192 |
]
|
|
193 |
] ifFalse:[
|
|
194 |
self addLines: total from: src to: dst offset: chunk offset length: chunk length.
|
|
195 |
]
|
|
196 |
|
|
197 |
"Created: / 09-04-2012 / 11:54:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
198 |
!
|
|
199 |
|
|
200 |
addLines: total from: src to: dst offset: offset length: len
|
|
201 |
| start stop |
|
|
202 |
|
|
203 |
start := offset max:1.
|
|
204 |
stop := (offset + (len max:0) - 1).
|
|
205 |
|
|
206 |
|
|
207 |
start to: (stop min: src size) do:[:i|
|
|
208 |
(src size >= i) ifTrue:[
|
|
209 |
dst add: (src at: i).
|
|
210 |
] ifFalse:[
|
|
211 |
src add: nil.
|
|
212 |
]
|
|
213 |
].
|
|
214 |
|
|
215 |
|
|
216 |
(total - ((stop min: src size) - start + 1)) timesRepeat: [ dst add: nil ].
|
|
217 |
|
|
218 |
"Created: / 16-03-2012 / 22:20:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
219 |
!
|
|
220 |
|
|
221 |
computeDiffDataForText1:t1 text2:t2 text3: t3
|
|
222 |
| t1c t2c t3c diff3chunks lnr |
|
|
223 |
|
|
224 |
list1 := StringCollection new.
|
|
225 |
list2 := StringCollection new.
|
|
226 |
list3 := StringCollection new.
|
|
227 |
changed := OrderedCollection new.
|
|
228 |
inserted1 := OrderedCollection new.
|
|
229 |
inserted2 := OrderedCollection new.
|
|
230 |
inserted3 := OrderedCollection new.
|
|
231 |
|
|
232 |
"/ t1 isNil ifTrue:[ ^self ].
|
|
233 |
"/ t2 isNil ifTrue:[ ^self ].
|
|
234 |
"/ t3 isNil ifTrue:[ ^self ].
|
|
235 |
|
|
236 |
|
|
237 |
t1c := (text1 := t1 ? #()) asStringCollection.
|
|
238 |
t2c := (text2 := t2 ? #()) asStringCollection.
|
|
239 |
t3c := (text3 := t3 ? #()) asStringCollection.
|
|
240 |
|
|
241 |
|
|
242 |
diff3chunks := Diff3 new
|
|
243 |
file0: t1c; "/Base version
|
|
244 |
file1: t2c; "/A
|
|
245 |
file2: t3c; "/B
|
|
246 |
diffIndices.
|
|
247 |
lnr := 1.
|
|
248 |
diff3chunks do:[:chunk|
|
|
249 |
| len |
|
|
250 |
|
|
251 |
len := chunk length.
|
|
252 |
chunk isConflict ifTrue:[
|
|
253 |
self addLines: len from: t1c to: list1 chunk: chunk original.
|
|
254 |
self addLines: len from: t2c to: list2 chunk: chunk left.
|
|
255 |
self addLines: len from: t3c to: list3 chunk: chunk right.
|
|
256 |
chunk isInsertionInOriginal ifTrue:[
|
|
257 |
lnr to:(lnr + len -1) do:[:i|inserted1 add: i].
|
|
258 |
] ifFalse:[chunk isInsertionInLeft ifTrue:[
|
|
259 |
lnr to:(lnr + len -1) do:[:i|inserted2 add: i].
|
|
260 |
] ifFalse:[chunk isInsertionInRight ifTrue:[
|
|
261 |
lnr to:(lnr + len -1) do:[:i|inserted3 add: i].
|
|
262 |
] ifFalse:[
|
|
263 |
lnr to:(lnr + len -1) do:[:i|changed add: i].
|
|
264 |
]]]
|
|
265 |
].
|
|
266 |
chunk isChunk ifTrue:[
|
|
267 |
chunk side == #original ifTrue:[
|
|
268 |
self addLines: len from: t1c to: list1 offset: chunk offset length: len.
|
|
269 |
self addLines: len from: t1c to: list2 offset: chunk offset length: len.
|
|
270 |
self addLines: len from: t1c to: list3 offset: chunk offset length: len.
|
|
271 |
].
|
|
272 |
chunk side == #left ifTrue:[
|
|
273 |
self breakPoint: #jv info: 'Should no longer happen'.
|
|
274 |
self addLines: len from: t1c to: list1 offset: chunk offset length: 0"len".
|
|
275 |
self addLines: len from: t2c to: list2 offset: chunk offset length: len.
|
|
276 |
self addLines: len from: t3c to: list3 offset: chunk offset length: 0"len".
|
|
277 |
lnr to:(lnr + len - 1) do:[:i| "changed"inserted2 add:i ].
|
|
278 |
].
|
|
279 |
chunk side == #right ifTrue:[
|
|
280 |
self breakPoint: #jv info: 'Should no longer happen'.
|
|
281 |
self addLines: len from: t1c to: list1 offset: chunk offset length: 0"len".
|
|
282 |
self addLines: len from: t2c to: list2 offset: chunk offset length: 0"len".
|
|
283 |
self addLines: len from: t3c to: list3 offset: chunk offset length: len.
|
|
284 |
lnr to:(lnr + len - 1) do:[:i|"changed"inserted3 add: i].
|
|
285 |
]
|
|
286 |
].
|
|
287 |
lnr := lnr + len.
|
|
288 |
].
|
|
289 |
|
|
290 |
"Created: / 16-03-2012 / 22:07:51 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
291 |
!
|
|
292 |
|
|
293 |
old_computeDiffDataForText1:t1 text2:t2 text3: t3
|
|
294 |
| t1c t2c t3c diff3chunks lnr |
|
|
295 |
|
|
296 |
list1 := StringCollection new.
|
|
297 |
list2 := StringCollection new.
|
|
298 |
list3 := StringCollection new.
|
|
299 |
changed := OrderedCollection new.
|
|
300 |
inserted1 := OrderedCollection new.
|
|
301 |
inserted2 := OrderedCollection new.
|
|
302 |
inserted3 := OrderedCollection new.
|
|
303 |
|
|
304 |
t1 isNil ifTrue:[ ^self ].
|
|
305 |
t2 isNil ifTrue:[ ^self ].
|
|
306 |
t3 isNil ifTrue:[ ^self ].
|
|
307 |
|
|
308 |
|
|
309 |
t1c := (text1 := t1) asStringCollection.
|
|
310 |
t2c := (text2 := t2) asStringCollection.
|
|
311 |
t3c := (text3 := t3) asStringCollection.
|
|
312 |
|
|
313 |
|
|
314 |
diff3chunks := Diff3 new
|
|
315 |
file0: t1c; "/Base version
|
|
316 |
file1: t2c; "/A
|
|
317 |
file2: t3c; "/B
|
|
318 |
mergeIndices.
|
|
319 |
lnr := 1.
|
|
320 |
diff3chunks do:[:chunk|
|
|
321 |
| len |
|
|
322 |
|
|
323 |
len := chunk length.
|
|
324 |
chunk isConflict ifTrue:[
|
|
325 |
self addLines: len from: t1c to: list1 offset: chunk original offset length: chunk original length.
|
|
326 |
self addLines: len from: t2c to: list2 offset: chunk left offset length: chunk left length.
|
|
327 |
self addLines: len from: t3c to: list3 offset: chunk right offset length: chunk right length.
|
|
328 |
"/ chunk isInsertionInOriginal ifTrue:[
|
|
329 |
"/ lnr to:(lnr + len -1) do:[:i|inserted1 add: i].
|
|
330 |
"/ ] ifFalse:[chunk isInsertionInLeft ifTrue:[
|
|
331 |
"/ lnr to:(lnr + len -1) do:[:i|inserted2 add: i].
|
|
332 |
"/ ] ifFalse:[chunk isInsertionInRight ifTrue:[
|
|
333 |
"/ lnr to:(lnr + len -1) do:[:i|inserted3 add: i].
|
|
334 |
"/ ] ifFalse:[
|
|
335 |
lnr to:(lnr + len -1) do:[:i|changed add: i].
|
|
336 |
"/ ]]]
|
|
337 |
].
|
|
338 |
chunk isChunk ifTrue:[
|
|
339 |
chunk side == #original ifTrue:[
|
|
340 |
self addLines: len from: t1c to: list1 offset: chunk offset length: len.
|
|
341 |
self addLines: len from: t1c to: list2 offset: chunk offset length: len.
|
|
342 |
self addLines: len from: t1c to: list3 offset: chunk offset length: len.
|
|
343 |
].
|
|
344 |
chunk side == #left ifTrue:[
|
|
345 |
self addLines: len from: t1c to: list1 offset: chunk offset length: 0"len".
|
|
346 |
self addLines: len from: t2c to: list2 offset: chunk offset length: len.
|
|
347 |
self addLines: len from: t3c to: list3 offset: chunk offset length: 0"len".
|
|
348 |
lnr to:(lnr + len - 1) do:[:i| "changed"inserted2 add:i ].
|
|
349 |
].
|
|
350 |
chunk side == #right ifTrue:[
|
|
351 |
self addLines: len from: t1c to: list1 offset: chunk offset length: 0"len".
|
|
352 |
self addLines: len from: t2c to: list2 offset: chunk offset length: 0"len".
|
|
353 |
self addLines: len from: t3c to: list3 offset: chunk offset length: len.
|
|
354 |
lnr to:(lnr + len - 1) do:[:i|"changed"inserted3 add: i].
|
|
355 |
]
|
|
356 |
].
|
|
357 |
lnr := lnr + len.
|
|
358 |
].
|
|
359 |
|
|
360 |
"Created: / 20-03-2012 / 17:42:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
361 |
! !
|
|
362 |
|
|
363 |
!Diff3CodeView2 class methodsFor:'documentation'!
|
|
364 |
|
|
365 |
version
|
|
366 |
^ '$Header: /cvs/stx/stx/libtool/Tools__Diff3CodeView2.st,v 1.1 2014-02-05 18:58:05 cg Exp $'
|
|
367 |
!
|
|
368 |
|
|
369 |
version_CVS
|
|
370 |
^ '$Header: /cvs/stx/stx/libtool/Tools__Diff3CodeView2.st,v 1.1 2014-02-05 18:58:05 cg Exp $'
|
|
371 |
! !
|
|
372 |
|