author | Claus Gittinger <cg@exept.de> |
Mon, 20 Aug 2018 10:11:25 +0200 | |
changeset 4346 | 6604af2f1554 |
parent 4206 | f9fd49077c35 |
child 4386 | 2aaa979df793 |
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 |
||
4019 | 29 |
"{ NameSpace: Smalltalk }" |
30 |
||
2407 | 31 |
Object subclass:#ChangeSetDiff |
2878 | 32 |
instanceVariableNames:'diffset same' |
2407 | 33 |
classVariableNames:'' |
34 |
poolDictionaries:'' |
|
35 |
category:'System-Changes-Diff' |
|
36 |
! |
|
37 |
||
38 |
!ChangeSetDiff 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 |
!ChangeSetDiff class methodsFor:'instance creation'! |
|
71 |
||
72 |
new |
|
73 |
^ self basicNew initialize. |
|
74 |
! ! |
|
75 |
||
76 |
!ChangeSetDiff class methodsFor:'utilities'! |
|
77 |
||
78 |
versionA:changesetA versionB:changesetB |
|
79 |
^ (self new) |
|
80 |
versionA:changesetA versionB:changesetB; |
|
81 |
diffset |
|
82 |
||
83 |
"Created: / 02-11-2009 / 16:12:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
84 |
! |
|
85 |
||
86 |
versionA:changesetA versionB:changesetB versionBase: versionBase |
|
87 |
^ (self new) |
|
88 |
versionA:changesetA versionB:changesetB versionBase: versionBase; |
|
89 |
diffset |
|
90 |
||
91 |
"Created: / 03-11-2009 / 07:58:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
92 |
! ! |
|
93 |
||
94 |
!ChangeSetDiff methodsFor:'accessing'! |
|
95 |
||
96 |
diffset |
|
97 |
^ diffset |
|
2878 | 98 |
! |
99 |
||
100 |
same |
|
101 |
^ same |
|
2407 | 102 |
! ! |
103 |
||
104 |
!ChangeSetDiff methodsFor:'diffing'! |
|
105 |
||
106 |
versionA:changesetA versionB:changesetB |
|
107 |
||
108 |
self versionA:changesetA versionB:changesetB versionBase: nil |
|
109 |
||
110 |
"Created: / 31-10-2009 / 19:12:54 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
111 |
"Modified: / 02-11-2009 / 18:38:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
112 |
! |
|
113 |
||
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
114 |
versionA:a versionB:b versionBase:base |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
115 |
|ds diffsByClass include| |
2407 | 116 |
|
117 |
diffsByClass := Dictionary new. |
|
118 |
ds := a diffSetsAgainst:b. |
|
2878 | 119 |
same := ds same. |
120 |
||
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
121 |
include := [:chg | |
2878 | 122 |
true"(AbstractSourceCodeManager isVersionMethodSelector:chg selector) not" |
123 |
]. |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
124 |
ds onlyInReceiver do:[:chg | |
3440 | 125 |
(include value:chg) ifTrue:[ |
126 |
(diffsByClass at:chg nonMetaClassName |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
127 |
ifAbsentPut:[ChangeSetDiffSet new name:chg nonMetaClassName]) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
128 |
add:(ChangeSetDiffEntry versionA:chg) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
129 |
] |
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 |
ds changed do:[:chgPair | |
3440 | 132 |
| chg | |
133 |
||
134 |
chg := chgPair first ? chgPair second. |
|
135 |
(include value:chg) ifTrue:[ |
|
136 |
(diffsByClass at:chg nonMetaClassName |
|
137 |
ifAbsentPut:[ChangeSetDiffSet new name:chg nonMetaClassName]) |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
138 |
add:(ChangeSetDiffEntry versionA:chgPair first versionB:chgPair second) |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
139 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
140 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
141 |
ds onlyInArg do:[:chg | |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
142 |
(include value:chg) ifTrue:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
143 |
(diffsByClass at:chg nonMetaClassName |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
144 |
ifAbsentPut:[ChangeSetDiffSet new name:chg nonMetaClassName]) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
145 |
add:(ChangeSetDiffEntry versionB:chg) |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
146 |
] |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
147 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
148 |
base notNil ifTrue:[ |
2407 | 149 |
"Try to assign base version to each diff item" |
150 |
"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
|
151 |
diffsByClass do:[:diffs | |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
152 |
diffs do:[:diff | |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
153 |
|versionBase| |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
154 |
|
2878 | 155 |
versionBase := base detect:[:each | each isForSameAs:(diff versionA ? diff versionB)] ifNone:[nil]. |
156 |
||
157 |
"/ only the category is different; |
|
158 |
"/ make it a MethodCategory changes. |
|
159 |
(versionBase notNil and:[versionBase isMethodCodeChange and:[ |
|
160 |
diff versionA notNil and:[diff versionA isMethodCategoryChange |
|
161 |
and:[diff versionA notNil and:[diff versionB isMethodCategoryChange]]]]]) ifTrue:[ |
|
162 |
versionBase := MethodCategoryChange new |
|
163 |
className:versionBase className |
|
164 |
selector:versionBase selector |
|
165 |
category:versionBase methodCategory; |
|
166 |
origin: versionBase |
|
167 |
]. |
|
168 |
"/ versionBase isNil ifTrue:[ |
|
169 |
"/ diff versionA isClassRemoveChangeOrMethodRemoveChange not ifTrue:[ |
|
170 |
"/ versionBase := diff versionA asAntiChange |
|
171 |
"/ ] ifFalse:[ |
|
172 |
"/ versionBase := diff versionA copy |
|
173 |
"/ ] |
|
174 |
"/ ]. |
|
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
175 |
diff versionBase:versionBase. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
176 |
diff automerge |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
177 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
178 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
179 |
]. |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
180 |
diffsByClass size = 1 ifTrue:[ |
3693 | 181 |
diffset addAll:diffsByClass anElement diffs |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
182 |
] ifFalse:[ |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
183 |
diffset addAll:diffsByClass values |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
184 |
]. |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
185 |
diffset versionALabel:a name. |
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
186 |
diffset versionBLabel:b name. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
187 |
base notNil ifTrue:[ |
2630
deae273e56c3
changed: #versionA:versionB:versionBase: - fomatting && do not include version methods
vrany
parents:
2629
diff
changeset
|
188 |
diffset versionBaseLabel:base name. |
2407 | 189 |
]. |
190 |
||
191 |
"Created: / 02-11-2009 / 16:17:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
4206 | 192 |
"Modified: / 29-06-2011 / 08:22:49 / Jan Vrany" |
3440 | 193 |
"Modified: / 18-12-2013 / 21:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2407 | 194 |
! ! |
195 |
||
196 |
!ChangeSetDiff methodsFor:'initialization'! |
|
197 |
||
198 |
initialize |
|
199 |
"Invoked when a new instance is created." |
|
200 |
||
201 |
"/ please change as required (and remove this comment) |
|
202 |
diffset := ChangeSetDiffSet new. |
|
2878 | 203 |
same := ChangeSet new. |
2407 | 204 |
|
205 |
"/ super initialize. -- commented since inherited method does nothing |
|
206 |
||
2878 | 207 |
"Modified: / 19-03-2012 / 21:51:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
2407 | 208 |
! ! |
209 |
||
210 |
!ChangeSetDiff class methodsFor:'documentation'! |
|
211 |
||
4019 | 212 |
version_CVS |
213 |
^ '$Header$' |
|
214 |
! |
|
215 |
||
2878 | 216 |
version_SVN |
4019 | 217 |
^ '$Id$' |
2407 | 218 |
! ! |
3440 | 219 |