author | Claus Gittinger <cg@exept.de> |
Tue, 29 Nov 2011 11:56:34 +0100 | |
changeset 2629 | 4786ed332f59 |
parent 2407 | 239b5c4aef83 |
child 2630 | deae273e56c3 |
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 |
||
108 |
versionA:a versionB:b versionBase: base |
|
109 |
|ds diffsByClass | |
|
110 |
||
111 |
"For now, use diff algorithm in ChangeSet>>difSetsAgainst: |
|
112 |
it looks very optimized" |
|
113 |
diffsByClass := Dictionary new. |
|
114 |
ds := a diffSetsAgainst:b. |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
115 |
ds onlyInReceiver do:[:chg | |
2407 | 116 |
(diffsByClass |
117 |
at: (chg nonMetaClassName ifNil:[chg class name]) |
|
118 |
ifAbsentPut:[ChangeSetDiffSet new name: chg nonMetaClassName]) |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
119 |
add:(ChangeSetDiffEntry versionA:chg) |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
120 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
121 |
ds changed do:[:chgPair | |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
122 |
| include | |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
123 |
|
2407 | 124 |
include := chgPair first isMethodChange not |
125 |
or:[(AbstractSourceCodeManager isVersionMethodSelector: |
|
126 |
chgPair first selector) not]. |
|
127 |
include ifTrue:[ |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
128 |
(diffsByClass |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
129 |
at: chgPair first nonMetaClassName |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
130 |
ifAbsentPut:[ChangeSetDiffSet new name: chgPair first nonMetaClassName]) |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
131 |
add:(ChangeSetDiffEntry versionA:chgPair first versionB:chgPair second) |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
132 |
] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
133 |
]. |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
134 |
ds onlyInArg do:[:chg | |
2407 | 135 |
(diffsByClass |
136 |
at: chg nonMetaClassName |
|
137 |
ifAbsentPut:[ChangeSetDiffSet new name: chg nonMetaClassName]) |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
138 |
add:(ChangeSetDiffEntry versionB:chg) |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
139 |
]. |
2407 | 140 |
|
141 |
||
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
142 |
base notNil ifTrue:[ |
2407 | 143 |
"Try to assign base version to each diff item" |
144 |
"Sorry, we are using O^2 algorithm here, I'm too lazy now :-)" |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
145 |
diffsByClass do:[:diffs| |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
146 |
diffs do:[:diff| |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
147 |
| versionBase | |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
148 |
|
2407 | 149 |
versionBase := base detect:[:each|each isForSameAs: diff versionA] ifNone:[nil]. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
150 |
versionBase isNil ifTrue:[ |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
151 |
diff versionA isClassRemoveChangeOrMethodRemoveChange not |
2407 | 152 |
ifTrue:[versionBase := diff versionA asAntiChange] |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
153 |
ifFalse:[versionBase := diff versionA copy] |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
154 |
]. |
2407 | 155 |
diff versionBase: versionBase. |
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
156 |
diff automerge |
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
157 |
] |
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 |
]. |
2407 | 160 |
|
161 |
diffsByClass size = 1 |
|
162 |
ifTrue:[diffset addAll: diffsByClass anyOne diffs] |
|
163 |
ifFalse:[diffset addAll: diffsByClass values]. |
|
164 |
||
165 |
diffset versionALabel: a name. |
|
166 |
diffset versionBLabel: b name. |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
167 |
base notNil ifTrue:[ |
2407 | 168 |
diffset versionBaseLabel: base name. |
169 |
]. |
|
170 |
||
171 |
"Created: / 02-11-2009 / 16:17:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
172 |
"Modified: / 29-06-2011 / 08:22:49 / Jan Vrany <enter your email here>" |
|
173 |
"Modified: / 06-07-2011 / 13:00:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
174 |
"Modified: / 29-11-2011 / 11:24:42 / cg" |
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 |
|
2629
4786ed332f59
changed: #versionA:versionB:versionBase:
Claus Gittinger <cg@exept.de>
parents:
2407
diff
changeset
|
193 |
^ '$Header: /cvs/stx/stx/libbasic3/ChangeSetDiff.st,v 1.2 2011-11-29 10:56:34 cg Exp $' |
2407 | 194 |
! ! |