author | vrany |
Tue, 29 Nov 2011 14:12:30 +0100 | |
changeset 2630 | deae273e56c3 |
parent 2629 | 4786ed332f59 |
child 2878 | 6b43d308b5f7 |
child 3011 | 1997ff6e7e55 |
permissions | -rw-r--r-- |
2407 | 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 |
||
29 |
Object subclass:#ChangeSetDiff |
|
30 |
instanceVariableNames:'diffset' |
|
31 |
classVariableNames:'' |
|
32 |
poolDictionaries:'' |
|
33 |
category:'System-Changes-Diff' |
|
34 |
! |
|
35 |
||
36 |
!ChangeSetDiff class methodsFor:'documentation'! |
|
37 |
||
38 |
copyright |
|
39 |
" |
|
40 |
Copyright (c) 2007-2010 Jan Vrany, SWING Research Group, |
|
41 |
Czech Technical University in Prague |
|
42 |
Copyright (c) 2009-2010 eXept Software AG |
|
43 |
||
44 |
Permission is hereby granted, free of charge, to any person |
|
45 |
obtaining a copy of this software and associated documentation |
|
46 |
files (the 'Software'), to deal in the Software without |
|
47 |
restriction, including without limitation the rights to use, |
|
48 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
49 |
copies of the Software, and to permit persons to whom the |
|
50 |
Software is furnished to do so, subject to the following |
|
51 |
conditions: |
|
52 |
||
53 |
The above copyright notice and this permission notice shall be |
|
54 |
included in all copies or substantial portions of the Software. |
|
55 |
||
56 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
57 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
58 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
59 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
60 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
61 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
62 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
63 |
OTHER DEALINGS IN THE SOFTWARE. |
|
64 |
||
65 |
" |
|
66 |
! ! |
|
67 |
||
68 |
!ChangeSetDiff class methodsFor:'instance creation'! |
|
69 |
||
70 |
new |
|
71 |
^ self basicNew initialize. |
|
72 |
! ! |
|
73 |
||
74 |
!ChangeSetDiff class methodsFor:'utilities'! |
|
75 |
||
76 |
versionA:changesetA versionB:changesetB |
|
77 |
^ (self new) |
|
78 |
versionA:changesetA versionB:changesetB; |
|
79 |
diffset |
|
80 |
||
81 |
"Created: / 02-11-2009 / 16:12:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
82 |
! |
|
83 |
||
84 |
versionA:changesetA versionB:changesetB versionBase: versionBase |
|
85 |
^ (self new) |
|
86 |
versionA:changesetA versionB:changesetB versionBase: versionBase; |
|
87 |
diffset |
|
88 |
||
89 |
"Created: / 03-11-2009 / 07:58:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
90 |
! ! |
|
91 |
||
92 |
!ChangeSetDiff methodsFor:'accessing'! |
|
93 |
||
94 |
diffset |
|
95 |
^ diffset |
|
96 |
! ! |
|
97 |
||
98 |
!ChangeSetDiff methodsFor:'diffing'! |
|
99 |
||
100 |
versionA:changesetA versionB:changesetB |
|
101 |
||
102 |
self versionA:changesetA versionB:changesetB versionBase: nil |
|
103 |
||
104 |
"Created: / 31-10-2009 / 19:12:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
105 |
"Modified: / 02-11-2009 / 18:38:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
106 |
! |
|
107 |
||
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
108 |
versionA:a versionB:b versionBase:base |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
109 |
|ds diffsByClass include| |
2407 | 110 |
|
111 |
diffsByClass := Dictionary new. |
|
112 |
ds := a diffSetsAgainst:b. |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
113 |
include := [:chg | |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
114 |
(AbstractSourceCodeManager isVersionMethodSelector:chg selector) not |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
115 |
]. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
116 |
ds onlyInReceiver do:[:chg | |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
117 |
(include value:chg) ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
118 |
(diffsByClass at:(chg nonMetaClassName isNil ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
119 |
chg class name |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
120 |
]) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
121 |
ifAbsentPut:[ChangeSetDiffSet new name:chg nonMetaClassName]) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
122 |
add:(ChangeSetDiffEntry versionA:chg) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
123 |
] |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
124 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
125 |
ds changed do:[:chgPair | |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
126 |
(include value:chgPair first) ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
127 |
(diffsByClass at:chgPair first nonMetaClassName |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
128 |
ifAbsentPut:[ChangeSetDiffSet new name:chgPair first nonMetaClassName]) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
129 |
add:(ChangeSetDiffEntry versionA:chgPair first versionB:chgPair second) |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
130 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
131 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
132 |
ds onlyInArg do:[:chg | |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
133 |
(include value:chg) ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
134 |
(diffsByClass at:chg nonMetaClassName |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
135 |
ifAbsentPut:[ChangeSetDiffSet new name:chg nonMetaClassName]) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
136 |
add:(ChangeSetDiffEntry versionB:chg) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
137 |
] |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
138 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
139 |
base notNil ifTrue:[ |
2407 | 140 |
"Try to assign base version to each diff item" |
141 |
"Sorry, we are using O^2 algorithm here, I'm too lazy now :-)" |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
142 |
diffsByClass do:[:diffs | |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
143 |
diffs do:[:diff | |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
144 |
|versionBase| |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
145 |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
146 |
versionBase := base |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
147 |
detect:[:each | each isForSameAs:diff versionA] |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
148 |
ifNone:[nil]. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
149 |
versionBase isNil ifTrue:[ |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
150 |
diff versionA isClassRemoveChangeOrMethodRemoveChange not ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
151 |
versionBase := diff versionA asAntiChange |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
152 |
] ifFalse:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
153 |
versionBase := diff versionA copy |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
154 |
] |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
155 |
]. |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
156 |
diff versionBase:versionBase. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
157 |
diff automerge |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
158 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
159 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
160 |
]. |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
161 |
diffsByClass size = 1 ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
162 |
diffset addAll:diffsByClass anyOne diffs |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
163 |
] ifFalse:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
164 |
diffset addAll:diffsByClass values |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
165 |
]. |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
166 |
diffset versionALabel:a name. |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
167 |
diffset versionBLabel:b name. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
168 |
base notNil ifTrue:[ |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
169 |
diffset versionBaseLabel:base name. |
2407 | 170 |
]. |
171 |
||
172 |
"Created: / 02-11-2009 / 16:17:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
173 |
"Modified: / 29-06-2011 / 08:22:49 / Jan Vrany <enter your email here>" |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
174 |
"Modified (format): / 29-11-2011 / 14:11:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2407 | 175 |
! ! |
176 |
||
177 |
!ChangeSetDiff methodsFor:'initialization'! |
|
178 |
||
179 |
initialize |
|
180 |
"Invoked when a new instance is created." |
|
181 |
||
182 |
"/ please change as required (and remove this comment) |
|
183 |
diffset := ChangeSetDiffSet new. |
|
184 |
||
185 |
"/ super initialize. -- commented since inherited method does nothing |
|
186 |
||
187 |
"Modified: / 06-07-2011 / 13:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
188 |
! ! |
|
189 |
||
190 |
!ChangeSetDiff class methodsFor:'documentation'! |
|
191 |
||
192 |
version_CVS |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
193 |
^ '$Header: /cvs/stx/stx/libbasic3/ChangeSetDiff.st,v 1.3 2011-11-29 13:12:30 vrany Exp $' |
2407 | 194 |
! ! |