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