2408
|
1 |
"
|
|
2 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group,
|
|
3 |
Czech Technical University in Prague
|
|
4 |
Copyright (c) 2009-2010 eXept Software AG
|
|
5 |
|
|
6 |
Permission is hereby granted, free of charge, to any person
|
|
7 |
obtaining a copy of this software and associated documentation
|
|
8 |
files (the 'Software'), to deal in the Software without
|
|
9 |
restriction, including without limitation the rights to use,
|
|
10 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11 |
copies of the Software, and to permit persons to whom the
|
|
12 |
Software is furnished to do so, subject to the following
|
|
13 |
conditions:
|
|
14 |
|
|
15 |
The above copyright notice and this permission notice shall be
|
|
16 |
included in all copies or substantial portions of the Software.
|
|
17 |
|
|
18 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
19 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
20 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
21 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
22 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
23 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
24 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
25 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
26 |
"
|
|
27 |
"{ Package: 'stx:libbasic3' }"
|
|
28 |
|
4020
|
29 |
"{ NameSpace: Smalltalk }"
|
|
30 |
|
2408
|
31 |
ChangeSetDiffComponent subclass:#ChangeSetDiffSet
|
|
32 |
instanceVariableNames:'name versionALabel versionBLabel versionBaseLabel diffs'
|
|
33 |
classVariableNames:''
|
|
34 |
poolDictionaries:''
|
|
35 |
category:'System-Changes-Diff'
|
|
36 |
!
|
|
37 |
|
|
38 |
!ChangeSetDiffSet class methodsFor:'documentation'!
|
|
39 |
|
|
40 |
copyright
|
|
41 |
"
|
|
42 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group,
|
|
43 |
Czech Technical University in Prague
|
|
44 |
Copyright (c) 2009-2010 eXept Software AG
|
|
45 |
|
|
46 |
Permission is hereby granted, free of charge, to any person
|
|
47 |
obtaining a copy of this software and associated documentation
|
|
48 |
files (the 'Software'), to deal in the Software without
|
|
49 |
restriction, including without limitation the rights to use,
|
|
50 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
51 |
copies of the Software, and to permit persons to whom the
|
|
52 |
Software is furnished to do so, subject to the following
|
|
53 |
conditions:
|
|
54 |
|
|
55 |
The above copyright notice and this permission notice shall be
|
|
56 |
included in all copies or substantial portions of the Software.
|
|
57 |
|
|
58 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
59 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
60 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
61 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
62 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
63 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
64 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
65 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
66 |
|
|
67 |
"
|
|
68 |
! !
|
|
69 |
|
|
70 |
!ChangeSetDiffSet class methodsFor:'instance creation'!
|
|
71 |
|
|
72 |
new
|
|
73 |
^ self basicNew initialize.
|
|
74 |
! !
|
|
75 |
|
|
76 |
!ChangeSetDiffSet methodsFor:'accessing'!
|
|
77 |
|
3462
|
78 |
depth
|
|
79 |
| depth |
|
|
80 |
depth := 0.
|
|
81 |
diffs do:[:diff|
|
|
82 |
depth := depth max: diff depth
|
|
83 |
].
|
|
84 |
^depth + 1
|
|
85 |
|
|
86 |
"Created: / 15-01-2013 / 11:27:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
87 |
!
|
|
88 |
|
2408
|
89 |
diffs
|
|
90 |
^ diffs
|
|
91 |
!
|
|
92 |
|
|
93 |
flattened
|
|
94 |
|
|
95 |
| flattened s |
|
|
96 |
flattened := self copy.
|
|
97 |
s := (OrderedCollection new: diffs size) writeStream.
|
|
98 |
self flattenOn: s.
|
|
99 |
flattened setDiffs: s contents.
|
|
100 |
^flattened
|
|
101 |
|
|
102 |
"Created: / 05-12-2009 / 11:09:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
103 |
!
|
|
104 |
|
|
105 |
merged
|
|
106 |
|
|
107 |
^diffs allSatisfy:[:e|e merged]
|
|
108 |
|
|
109 |
"Created: / 24-11-2009 / 10:04:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
110 |
!
|
|
111 |
|
|
112 |
name
|
2427
|
113 |
|
|
114 |
^ '%1 (%2)' bindWith: (name ? '<unnamed>') with: diffs size
|
2408
|
115 |
|
|
116 |
"Modified: / 26-11-2009 / 16:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2427
|
117 |
"Modified: / 07-07-2011 / 14:15:12 / jv"
|
2408
|
118 |
!
|
|
119 |
|
|
120 |
name:aString
|
|
121 |
name := aString.
|
|
122 |
!
|
|
123 |
|
3462
|
124 |
nextEntryAfter: entry suchThat: predicate
|
|
125 |
| found |
|
|
126 |
|
|
127 |
entry isNil ifTrue:[
|
|
128 |
self do:[:each|(predicate value: each) ifTrue:[^each]].
|
|
129 |
^nil
|
|
130 |
].
|
|
131 |
|
|
132 |
found := false.
|
|
133 |
self do:[:each|
|
|
134 |
each == entry ifTrue:[
|
|
135 |
found := true
|
|
136 |
] ifFalse:[
|
|
137 |
(found and:[predicate value: each]) ifTrue:[ ^ each ]
|
|
138 |
].
|
|
139 |
].
|
|
140 |
^nil
|
|
141 |
|
|
142 |
"Created: / 17-01-2013 / 13:00:54 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
143 |
"Modified: / 17-01-2013 / 16:55:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
144 |
!
|
|
145 |
|
|
146 |
nextEntryBefore: entry suchThat: predicate
|
|
147 |
| last |
|
|
148 |
|
|
149 |
entry isNil ifTrue:[
|
|
150 |
^nil
|
|
151 |
].
|
|
152 |
|
|
153 |
self do:[:each|
|
|
154 |
each == entry ifTrue:[ ^ last ].
|
|
155 |
(predicate value: each) ifTrue:[last := each].
|
|
156 |
].
|
|
157 |
^nil
|
|
158 |
|
|
159 |
"Created: / 17-01-2013 / 16:57:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
160 |
!
|
|
161 |
|
2408
|
162 |
resolution
|
2627
|
163 |
| changeset |
|
2408
|
164 |
|
|
165 |
changeset := ChangeSet new.
|
2627
|
166 |
self do:[:diff|
|
|
167 |
diff versionMerged notNil ifTrue:[
|
|
168 |
changeset add: diff versionMerged
|
|
169 |
]
|
|
170 |
].
|
2408
|
171 |
^changeset
|
|
172 |
|
|
173 |
"Created: / 26-11-2009 / 08:44:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2627
|
174 |
"Modified: / 29-11-2011 / 11:25:02 / cg"
|
2408
|
175 |
!
|
|
176 |
|
|
177 |
versionALabel
|
2628
|
178 |
^ versionALabel ifNil:[parent ifNotNil:[parent versionALabel]]
|
2408
|
179 |
|
|
180 |
"Modified: / 21-11-2009 / 07:50:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2628
|
181 |
"Modified: / 29-11-2011 / 11:26:15 / cg"
|
2408
|
182 |
!
|
|
183 |
|
|
184 |
versionALabel:aString
|
|
185 |
versionALabel := aString.
|
|
186 |
!
|
|
187 |
|
|
188 |
versionBLabel
|
2628
|
189 |
^ versionBLabel ifNil:[parent ifNotNil:[parent versionBLabel]]
|
2408
|
190 |
|
|
191 |
"Modified: / 21-11-2009 / 07:51:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2628
|
192 |
"Modified: / 29-11-2011 / 11:26:19 / cg"
|
2408
|
193 |
!
|
|
194 |
|
|
195 |
versionBLabel:aString
|
|
196 |
versionBLabel := aString.
|
|
197 |
!
|
|
198 |
|
|
199 |
versionBaseLabel
|
2628
|
200 |
^ versionBaseLabel ifNil:[parent ifNotNil:[parent versionBaseLabel]]
|
2408
|
201 |
|
|
202 |
"Created: / 23-11-2009 / 22:54:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
203 |
"Modified: / 24-11-2009 / 09:21:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2628
|
204 |
"Modified (format): / 29-11-2011 / 11:26:37 / cg"
|
2408
|
205 |
!
|
|
206 |
|
|
207 |
versionBaseLabel:aString
|
|
208 |
versionBaseLabel := aString.
|
|
209 |
! !
|
|
210 |
|
|
211 |
!ChangeSetDiffSet methodsFor:'adding & removing'!
|
|
212 |
|
|
213 |
add: anObject
|
|
214 |
|
|
215 |
anObject parent: self.
|
|
216 |
^diffs add: anObject
|
|
217 |
|
|
218 |
"Created: / 09-11-2009 / 12:36:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
219 |
"Modified: / 10-11-2009 / 11:26:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
220 |
!
|
|
221 |
|
|
222 |
addAll: aCollection
|
|
223 |
|
|
224 |
aCollection do:[:e|self add:e]
|
|
225 |
|
|
226 |
"Created: / 10-11-2009 / 11:27:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
227 |
! !
|
|
228 |
|
|
229 |
!ChangeSetDiffSet methodsFor:'enumerating'!
|
|
230 |
|
|
231 |
collect: aBlock
|
|
232 |
|
|
233 |
^diffs collect: aBlock
|
|
234 |
|
|
235 |
"Created: / 10-11-2009 / 11:26:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
236 |
!
|
|
237 |
|
|
238 |
do: aBlock
|
|
239 |
|
|
240 |
^diffs do: [:each|each do:aBlock]
|
|
241 |
|
|
242 |
"Created: / 10-11-2009 / 11:26:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
243 |
"Modified: / 25-11-2009 / 10:30:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
244 |
! !
|
|
245 |
|
|
246 |
!ChangeSetDiffSet methodsFor:'initialization'!
|
|
247 |
|
|
248 |
initialize
|
|
249 |
"Invoked when a new instance is created."
|
|
250 |
|
|
251 |
"/ please change as required (and remove this comment)
|
|
252 |
"/ name := nil.
|
|
253 |
"/ versionALabel := nil.
|
|
254 |
"/ versionBLabel := nil.
|
|
255 |
diffs := OrderedCollection new:4.
|
|
256 |
|
|
257 |
"/ super initialize. -- commented since inherited method does nothing
|
|
258 |
|
|
259 |
"Modified: / 10-11-2009 / 11:25:55 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
260 |
!
|
|
261 |
|
|
262 |
setDiffs: aCollection
|
|
263 |
|
|
264 |
diffs := aCollection
|
|
265 |
|
|
266 |
"Created: / 05-12-2009 / 11:09:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
267 |
! !
|
|
268 |
|
|
269 |
!ChangeSetDiffSet methodsFor:'private'!
|
|
270 |
|
|
271 |
flattenOn: stream
|
|
272 |
|
|
273 |
diffs do:[:diff|diff flattenOn: stream]
|
|
274 |
|
|
275 |
"Created: / 05-12-2009 / 11:07:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
3462
|
276 |
!
|
|
277 |
|
|
278 |
sort:sortBlock
|
|
279 |
"superclass ChangeSetDiffComponent says that I am responsible to implement this method"
|
|
280 |
|
|
281 |
diffs sort: sortBlock.
|
|
282 |
diffs do:[:e|e sort: sortBlock].
|
|
283 |
|
|
284 |
"Modified: / 17-01-2013 / 14:18:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2408
|
285 |
! !
|
|
286 |
|
|
287 |
!ChangeSetDiffSet methodsFor:'testing'!
|
|
288 |
|
3462
|
289 |
isConflict
|
|
290 |
"Return true, if there is a conflict."
|
|
291 |
|
|
292 |
^ self diffs anySatisfy:[:e|e isConflict].
|
|
293 |
|
|
294 |
"Created: / 01-08-2012 / 17:10:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
295 |
!
|
|
296 |
|
2408
|
297 |
isDiffSet
|
|
298 |
^ true
|
|
299 |
!
|
|
300 |
|
|
301 |
isEmpty
|
|
302 |
|
|
303 |
^diffs isEmpty or:[diffs allSatisfy: [:diff|diff isEmpty]]
|
|
304 |
|
|
305 |
"Created: / 25-11-2009 / 20:37:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
306 |
"Modified: / 09-12-2009 / 17:43:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2879
|
307 |
!
|
|
308 |
|
3462
|
309 |
isForCopyrightMethod
|
|
310 |
"Returns true, if this is an entry for #copyright method"
|
|
311 |
|
|
312 |
^diffs allSatisfy:[:each|each isForCopyrightMethod]
|
|
313 |
|
|
314 |
"Created: / 01-08-2012 / 16:38:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
315 |
!
|
|
316 |
|
2879
|
317 |
isForVersionMethod
|
|
318 |
"Returns true, if this is an entry for version method"
|
|
319 |
|
|
320 |
^diffs allSatisfy:[:each|each isForVersionMethod]
|
|
321 |
|
|
322 |
"Created: / 18-04-2012 / 19:05:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
323 |
!
|
|
324 |
|
|
325 |
isMerged
|
|
326 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
327 |
|
|
328 |
^ self diffs allSatisfy:[:e|e isMerged].
|
|
329 |
|
|
330 |
"Created: / 19-03-2012 / 15:15:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
2408
|
331 |
! !
|
|
332 |
|
|
333 |
!ChangeSetDiffSet class methodsFor:'documentation'!
|
|
334 |
|
2628
|
335 |
version
|
4020
|
336 |
^ '$Header$'
|
|
337 |
!
|
|
338 |
|
|
339 |
version_CVS
|
|
340 |
^ '$Header$'
|
2628
|
341 |
!
|
|
342 |
|
2879
|
343 |
version_SVN
|
4020
|
344 |
^ '$Id$'
|
2408
|
345 |
! !
|
3398
|
346 |
|