author | Merge Script |
Sat, 19 Nov 2016 06:53:11 +0100 | |
branch | jv |
changeset 1182 | 38600a7a9203 |
parent 908 | 1fbf10af5f02 |
permissions | -rw-r--r-- |
658 | 1 |
" |
2 |
Copyright (c) 2007-2010 Jan Vrany |
|
3 |
Copyright (c) 2009-2010 eXept Software AG |
|
4 |
||
5 |
Permission is hereby granted, free of charge, to any person |
|
6 |
obtaining a copy of this software and associated documentation |
|
7 |
files (the 'Software'), to deal in the Software without |
|
8 |
restriction, including without limitation the rights to use, |
|
9 |
copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
10 |
copies of the Software, and to permit persons to whom the |
|
11 |
Software is furnished to do so, subject to the following |
|
12 |
conditions: |
|
13 |
||
14 |
The above copyright notice and this permission notice shall be |
|
15 |
included in all copies or substantial portions of the Software. |
|
16 |
||
17 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, |
|
18 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
19 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
20 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
21 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
22 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
23 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
24 |
OTHER DEALINGS IN THE SOFTWARE. |
|
25 |
" |
|
26 |
"{ Package: 'stx:libsvn' }" |
|
27 |
||
28 |
"{ NameSpace: SVN }" |
|
29 |
||
30 |
FileoutLikeTask subclass:#UpdateLikeTask |
|
31 |
instanceVariableNames:'notifications updates conflicts resolution' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
category:'SVN-Tasks' |
|
35 |
! |
|
36 |
||
37 |
!UpdateLikeTask class methodsFor:'documentation'! |
|
38 |
||
39 |
copyright |
|
40 |
" |
|
41 |
Copyright (c) 2007-2010 Jan Vrany |
|
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 |
||
908
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
68 |
!UpdateLikeTask class methodsFor:'others'! |
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
69 |
|
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
70 |
version_CVS |
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
71 |
^ '$Header$' |
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
72 |
! ! |
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
73 |
|
658 | 74 |
!UpdateLikeTask methodsFor:'accessing'! |
75 |
||
76 |
conflicts |
|
77 |
^ conflicts |
|
78 |
! |
|
79 |
||
80 |
conflicts:something |
|
81 |
"set the value of the instance variable 'conflicts' and send a change notification (automatically generated)" |
|
82 |
||
83 |
(conflicts ~~ something) ifTrue:[ |
|
84 |
conflicts := something. |
|
85 |
self changed:#conflicts with: something |
|
86 |
]. |
|
87 |
||
88 |
"Modified: / 25-11-2009 / 20:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
89 |
! |
|
90 |
||
91 |
notifications |
|
92 |
^ notifications |
|
93 |
! |
|
94 |
||
95 |
resolution |
|
96 |
||
97 |
" |
|
98 |
Tools::ChangeSetBrowser new |
|
99 |
changeset: updates; |
|
100 |
open |
|
101 |
||
102 |
Tools::ChangeSetBrowser new |
|
103 |
changeset: conflicts resolution; |
|
104 |
open |
|
105 |
||
106 |
" |
|
107 |
||
108 |
||
109 |
^resolution |
|
110 |
ifNotNil:[resolution] |
|
111 |
ifNil:[updates , conflicts resolution] |
|
112 |
||
113 |
"Created: / 26-11-2009 / 08:45:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
114 |
! |
|
115 |
||
116 |
resolution: aChangeSet |
|
117 |
||
118 |
resolution := aChangeSet. |
|
119 |
self changed: #resolution with: aChangeSet |
|
120 |
||
121 |
"Created: / 26-11-2009 / 08:46:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
122 |
! |
|
123 |
||
124 |
updates |
|
125 |
^ updates |
|
126 |
! |
|
127 |
||
128 |
updates:something |
|
129 |
"set the value of the instance variable 'updates' and send a change notification (automatically generated)" |
|
130 |
||
131 |
(updates ~~ something) ifTrue:[ |
|
132 |
updates := something. |
|
133 |
self changed:#updates with: something |
|
134 |
]. |
|
135 |
||
136 |
"Modified: / 25-11-2009 / 20:40:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
137 |
! ! |
|
138 |
||
139 |
!UpdateLikeTask methodsFor:'executing'! |
|
140 |
||
141 |
do |
|
142 |
" |
|
143 |
Perform whole task" |
|
144 |
||
145 |
self |
|
146 |
doComputeUpdates; |
|
147 |
doApplyUpdates. |
|
148 |
||
149 |
"Modified: / 23-11-2009 / 15:47:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
150 |
! |
|
151 |
||
152 |
doApplyUpdates |
|
153 |
|resolutionToApply| |
|
154 |
||
155 |
resolutionToApply := self resolution select:[:chg | chg removed not ]. |
|
156 |
" |
|
157 |
Tools::ChangeSetBrowser new |
|
158 |
changeset:resolutionToApply; |
|
159 |
open. |
|
160 |
" |
|
161 |
self do:[ |
|
162 |
resolutionToApply isNilOrEmptyCollection ifFalse:[ |
|
163 |
(Class updateChangeFileQuerySignal , Class updateChangeListQuerySignal) |
|
164 |
answer:false |
|
165 |
do:[ |
|
166 |
resolutionToApply |
|
167 |
withIndexDo:[:change :index | |
|
168 |
change apply. |
|
169 |
ProgressNotification notify:'Applying changes' |
|
170 |
progress:(100 / resolutionToApply size) * index |
|
171 |
] |
|
172 |
] |
|
173 |
]. |
|
174 |
] |
|
175 |
||
176 |
"Created: / 23-03-2009 / 18:36:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
177 |
"Modified: / 17-08-2009 / 19:39:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
178 |
"Modified: / 26-11-2009 / 14:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
179 |
! |
|
180 |
||
181 |
doComputeUpdates |
|
182 |
self workingCopy ensureIsValid. |
|
183 |
self |
|
184 |
doRevert; |
|
185 |
doFileOutAll; |
|
186 |
doUpdate; |
|
187 |
doProcessNotifications |
|
188 |
||
189 |
"Created: / 22-11-2009 / 07:29:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
190 |
"Modified: / 26-11-2009 / 14:54:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
191 |
! ! |
|
192 |
||
193 |
!UpdateLikeTask methodsFor:'executing - private'! |
|
194 |
||
195 |
doProcessNotifications |
|
196 |
updates := ChangeSet new. |
|
197 |
conflicts := DiffSet new. |
|
198 |
resolution := nil. |
|
199 |
notifications |
|
200 |
withIndexDo:[:each :index | |
|
201 |
ProgressNotification notify:('Processing ' , each entry path) |
|
202 |
progress:(100 / notifications size) * index. |
|
203 |
(each action isConflict or:[ each entry isSourceEntry ]) ifTrue:[ |
|
204 |
each processUsing:self |
|
205 |
] |
|
206 |
]. |
|
207 |
self changed:#updates with:updates. |
|
208 |
self changed:#conflicts with:conflicts. |
|
209 |
||
210 |
" |
|
211 |
SVN::MergeBrowser new |
|
212 |
diffset: conflicts; |
|
213 |
open" |
|
214 |
"Modified: / 18-08-2009 / 08:59:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
215 |
"Modified: / 26-11-2009 / 14:53:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
216 |
! |
|
217 |
||
218 |
doRevert |
|
219 |
ActivityNotification notify:'Reverting local changes'. |
|
220 |
(RevertCommand new) |
|
221 |
workingCopy:self workingCopy; |
|
222 |
paths:(ProgrammingLanguage all |
|
223 |
collect:[:lang | '*.' , lang sourceFileSuffix ]); |
|
224 |
execute. |
|
225 |
||
226 |
"Modified: / 26-11-2009 / 15:13:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
227 |
! |
|
228 |
||
229 |
doUpdate |
|
230 |
||
231 |
^self subclassResponsibility |
|
232 |
||
233 |
"Created: / 26-11-2009 / 14:54:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
234 |
! ! |
|
235 |
||
236 |
!UpdateLikeTask methodsFor:'processing - private'! |
|
237 |
||
238 |
processAddedEntry:entry |
|
239 |
entry programmingLanguage isSmalltalk ifTrue:[ |
|
240 |
updates addAll:(ChangeSet fromStream:entry readStream) |
|
241 |
] ifFalse:[ |
|
242 |
"/self error:'Non smalltalk source not yet supported' |
|
243 |
self breakPoint: #jv |
|
244 |
] |
|
245 |
||
246 |
"Created: / 27-08-2009 / 08:54:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
247 |
"Modified: / 17-02-2010 / 13:52:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
248 |
! |
|
249 |
||
250 |
processConflictEntry: entry |
|
251 |
||
252 |
| working merge base | |
|
253 |
||
254 |
"Ignore generated files, they will be regenerated..." |
|
255 |
(self filesToGenerate includes: entry path) ifTrue: |
|
256 |
[^self]. |
|
257 |
entry programmingLanguage isSmalltalk ifFalse: |
|
258 |
[^self error:'Only Smalltalk source file merging is supported right now, sorry.']. |
|
259 |
||
260 |
working := entry fileMergeWorking. |
|
261 |
merge := entry fileMergeRight. |
|
262 |
base := entry fileMergeLeft. |
|
263 |
||
264 |
conflicts add: |
|
265 |
((ChangeSetDiff |
|
266 |
versionA: (ChangeSet fromFile: working) |
|
267 |
versionB: (ChangeSet fromFile: merge) |
|
268 |
versionBase: (ChangeSet fromFile: base)) |
|
269 |
name: entry className; |
|
270 |
versionALabel: 'Current (in image)'; |
|
271 |
versionBLabel: merge suffix , ' (to be merged in)'); |
|
272 |
versionBaseLabel: base suffix , ' (base)'. |
|
273 |
||
274 |
"Created: / 23-11-2009 / 17:40:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
275 |
"Modified: / 27-11-2009 / 11:34:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
276 |
"Modified: / 07-07-2011 / 20:02:50 / jv" |
|
277 |
! |
|
278 |
||
279 |
processDeletedEntry:entry |
|
280 |
entry programmingLanguage isSmalltalk ifTrue:[ |
|
281 |
entry path = 'extensions.st' ifTrue:[ |
|
282 |
self halt "not yet finished" |
|
283 |
]. |
|
284 |
self halt. |
|
285 |
] |
|
286 |
||
287 |
"Created: / 27-08-2009 / 09:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
288 |
! |
|
289 |
||
290 |
processMergedEntry: aWCNotification |
|
291 |
||
292 |
^ self processUpdatedEntry: aWCNotification |
|
293 |
||
294 |
"Created: / 26-11-2009 / 15:36:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
295 |
"Modified: / 27-11-2009 / 11:12:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
296 |
! |
|
297 |
||
298 |
processNoneEntry:entry |
|
299 |
||
300 |
"Nothing to do" |
|
301 |
||
302 |
"Created: / 07-04-2010 / 00:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
303 |
! |
|
304 |
||
305 |
processUpdatedEntry:entry |
|
306 |
||
307 |
| class wcChangeset imageChangeset diffset | |
|
308 |
"We don't care about non source code files..." |
|
309 |
entry isSourceEntry ifFalse: |
|
310 |
[^self]. |
|
311 |
wcChangeset := entry asChangeSet. |
|
312 |
(wcChangeset first isClassDefinitionChange) |
|
313 |
ifTrue:[class := wcChangeset first changeClass]. |
|
314 |
(class isNil or:[class isLoaded not]) ifTrue:[^self]. |
|
315 |
imageChangeset := ChangeSet forExistingClass: class. |
|
316 |
||
317 |
diffset := imageChangeset diffSetsAgainst: wcChangeset. |
|
318 |
||
319 |
diffset onlyInReceiver do: |
|
320 |
[:chg|updates add:chg asAntiChange]. |
|
321 |
diffset changed do: |
|
322 |
[:chgPair|updates add:chgPair second]. |
|
323 |
diffset onlyInArg do: |
|
324 |
[:chg|updates add:chg]. |
|
325 |
||
326 |
"Created: / 26-11-2009 / 19:01:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
327 |
"Modified: / 27-11-2009 / 11:35:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
328 |
! ! |
|
329 |
||
330 |
!UpdateLikeTask methodsFor:'queries'! |
|
331 |
||
332 |
hasChanges |
|
333 |
||
334 |
(updates isNil or:[conflicts isNil]) |
|
335 |
ifTrue:[self error:'#doComputeChanges should be invoked before asking for changes']. |
|
336 |
||
337 |
^updates isEmpty not or:[conflicts isEmpty not] |
|
338 |
||
339 |
"Created: / 09-12-2009 / 17:39:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
340 |
! ! |
|
341 |
||
342 |
!UpdateLikeTask methodsFor:'testing'! |
|
343 |
||
344 |
isMergeTask |
|
345 |
^ false |
|
346 |
! |
|
347 |
||
348 |
isUpdateTask |
|
349 |
^ false |
|
350 |
! ! |
|
351 |
||
352 |
!UpdateLikeTask class methodsFor:'documentation'! |
|
353 |
||
354 |
version |
|
355 |
^ '$Header$' |
|
356 |
! |
|
357 |
||
358 |
version_SVN |
|
908
1fbf10af5f02
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
658
diff
changeset
|
359 |
^ '§Id: SVN__UpdateLikeTask.st 371 2011-09-28 18:47:07Z vranyj1 §' |
658 | 360 |
! ! |