|
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. |
|
115 ds onlyInReceiver do: |
|
116 [:chg | |
|
117 (diffsByClass |
|
118 at: (chg nonMetaClassName ifNil:[chg class name]) |
|
119 ifAbsentPut:[ChangeSetDiffSet new name: chg nonMetaClassName]) |
|
120 add:(ChangeSetDiffEntry versionA:chg)]. |
|
121 ds changed do: |
|
122 [:chgPair | | include | |
|
123 include := chgPair first isMethodChange not |
|
124 or:[(AbstractSourceCodeManager isVersionMethodSelector: |
|
125 chgPair first selector) not]. |
|
126 include ifTrue:[ |
|
127 (diffsByClass |
|
128 at: chgPair first nonMetaClassName |
|
129 ifAbsentPut:[ChangeSetDiffSet new name: chgPair first nonMetaClassName]) |
|
130 add:(ChangeSetDiffEntry versionA:chgPair first versionB:chgPair second)]]. |
|
131 ds onlyInArg do: |
|
132 [:chg | |
|
133 (diffsByClass |
|
134 at: chg nonMetaClassName |
|
135 ifAbsentPut:[ChangeSetDiffSet new name: chg nonMetaClassName]) |
|
136 add:(ChangeSetDiffEntry versionB:chg)]. |
|
137 |
|
138 |
|
139 base ifNotNil:[ |
|
140 "Try to assign base version to each diff item" |
|
141 "Sorry, we are using O^2 algorithm here, I'm too lazy now :-)" |
|
142 diffsByClass do: |
|
143 [:diffs| |
|
144 diffs do: |
|
145 [:diff| | versionBase | |
|
146 versionBase := base detect:[:each|each isForSameAs: diff versionA] ifNone:[nil]. |
|
147 versionBase ifNil: |
|
148 [diff versionA isClassRemoveChangeOrMethodRemoveChange not |
|
149 ifTrue:[versionBase := diff versionA asAntiChange] |
|
150 ifFalse:[versionBase := diff versionA copy]]. |
|
151 diff versionBase: versionBase. |
|
152 diff automerge]]]. |
|
153 |
|
154 diffsByClass size = 1 |
|
155 ifTrue:[diffset addAll: diffsByClass anyOne diffs] |
|
156 ifFalse:[diffset addAll: diffsByClass values]. |
|
157 |
|
158 diffset versionALabel: a name. |
|
159 diffset versionBLabel: b name. |
|
160 base ifNotNil:[ |
|
161 diffset versionBaseLabel: base name. |
|
162 ]. |
|
163 |
|
164 "Created: / 02-11-2009 / 16:17:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
165 "Modified: / 29-06-2011 / 08:22:49 / Jan Vrany <enter your email here>" |
|
166 "Modified: / 06-07-2011 / 13:00:27 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
167 ! ! |
|
168 |
|
169 !ChangeSetDiff methodsFor:'initialization'! |
|
170 |
|
171 initialize |
|
172 "Invoked when a new instance is created." |
|
173 |
|
174 "/ please change as required (and remove this comment) |
|
175 diffset := ChangeSetDiffSet new. |
|
176 |
|
177 "/ super initialize. -- commented since inherited method does nothing |
|
178 |
|
179 "Modified: / 06-07-2011 / 13:00:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
180 ! ! |
|
181 |
|
182 !ChangeSetDiff class methodsFor:'documentation'! |
|
183 |
|
184 version_CVS |
|
185 ^ '$Header: /cvs/stx/stx/libbasic3/ChangeSetDiff.st,v 1.1 2011-07-06 11:47:14 vrany Exp $' |
|
186 ! ! |