|
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 |
|
68 !UpdateLikeTask methodsFor:'accessing'! |
|
69 |
|
70 conflicts |
|
71 ^ conflicts |
|
72 ! |
|
73 |
|
74 conflicts:something |
|
75 "set the value of the instance variable 'conflicts' and send a change notification (automatically generated)" |
|
76 |
|
77 (conflicts ~~ something) ifTrue:[ |
|
78 conflicts := something. |
|
79 self changed:#conflicts with: something |
|
80 ]. |
|
81 |
|
82 "Modified: / 25-11-2009 / 20:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
83 ! |
|
84 |
|
85 notifications |
|
86 ^ notifications |
|
87 ! |
|
88 |
|
89 resolution |
|
90 |
|
91 " |
|
92 Tools::ChangeSetBrowser new |
|
93 changeset: updates; |
|
94 open |
|
95 |
|
96 Tools::ChangeSetBrowser new |
|
97 changeset: conflicts resolution; |
|
98 open |
|
99 |
|
100 " |
|
101 |
|
102 |
|
103 ^resolution |
|
104 ifNotNil:[resolution] |
|
105 ifNil:[updates , conflicts resolution] |
|
106 |
|
107 "Created: / 26-11-2009 / 08:45:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
108 ! |
|
109 |
|
110 resolution: aChangeSet |
|
111 |
|
112 resolution := aChangeSet. |
|
113 self changed: #resolution with: aChangeSet |
|
114 |
|
115 "Created: / 26-11-2009 / 08:46:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
116 ! |
|
117 |
|
118 updates |
|
119 ^ updates |
|
120 ! |
|
121 |
|
122 updates:something |
|
123 "set the value of the instance variable 'updates' and send a change notification (automatically generated)" |
|
124 |
|
125 (updates ~~ something) ifTrue:[ |
|
126 updates := something. |
|
127 self changed:#updates with: something |
|
128 ]. |
|
129 |
|
130 "Modified: / 25-11-2009 / 20:40:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
131 ! ! |
|
132 |
|
133 !UpdateLikeTask methodsFor:'executing'! |
|
134 |
|
135 do |
|
136 " |
|
137 Perform whole task" |
|
138 |
|
139 self |
|
140 doComputeUpdates; |
|
141 doApplyUpdates. |
|
142 |
|
143 "Modified: / 23-11-2009 / 15:47:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
144 ! |
|
145 |
|
146 doApplyUpdates |
|
147 |resolutionToApply| |
|
148 |
|
149 resolutionToApply := self resolution select:[:chg | chg removed not ]. |
|
150 " |
|
151 Tools::ChangeSetBrowser new |
|
152 changeset:resolutionToApply; |
|
153 open. |
|
154 " |
|
155 self do:[ |
|
156 resolutionToApply isNilOrEmptyCollection ifFalse:[ |
|
157 (Class updateChangeFileQuerySignal , Class updateChangeListQuerySignal) |
|
158 answer:false |
|
159 do:[ |
|
160 resolutionToApply |
|
161 withIndexDo:[:change :index | |
|
162 change apply. |
|
163 ProgressNotification notify:'Applying changes' |
|
164 progress:(100 / resolutionToApply size) * index |
|
165 ] |
|
166 ] |
|
167 ]. |
|
168 ] |
|
169 |
|
170 "Created: / 23-03-2009 / 18:36:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
171 "Modified: / 17-08-2009 / 19:39:17 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
172 "Modified: / 26-11-2009 / 14:50:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
173 ! |
|
174 |
|
175 doComputeUpdates |
|
176 self workingCopy ensureIsValid. |
|
177 self |
|
178 doRevert; |
|
179 doFileOutAll; |
|
180 doUpdate; |
|
181 doProcessNotifications |
|
182 |
|
183 "Created: / 22-11-2009 / 07:29:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
184 "Modified: / 26-11-2009 / 14:54:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
185 ! ! |
|
186 |
|
187 !UpdateLikeTask methodsFor:'executing - private'! |
|
188 |
|
189 doProcessNotifications |
|
190 updates := ChangeSet new. |
|
191 conflicts := DiffSet new. |
|
192 resolution := nil. |
|
193 notifications |
|
194 withIndexDo:[:each :index | |
|
195 ProgressNotification notify:('Processing ' , each entry path) |
|
196 progress:(100 / notifications size) * index. |
|
197 (each action isConflict or:[ each entry isSourceEntry ]) ifTrue:[ |
|
198 each processUsing:self |
|
199 ] |
|
200 ]. |
|
201 self changed:#updates with:updates. |
|
202 self changed:#conflicts with:conflicts. |
|
203 |
|
204 " |
|
205 SVN::MergeBrowser new |
|
206 diffset: conflicts; |
|
207 open" |
|
208 "Modified: / 18-08-2009 / 08:59:11 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
209 "Modified: / 26-11-2009 / 14:53:11 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
210 ! |
|
211 |
|
212 doRevert |
|
213 ActivityNotification notify:'Reverting local changes'. |
|
214 (RevertCommand new) |
|
215 workingCopy:self workingCopy; |
|
216 paths:(ProgrammingLanguage all |
|
217 collect:[:lang | '*.' , lang sourceFileSuffix ]); |
|
218 execute. |
|
219 |
|
220 "Modified: / 26-11-2009 / 15:13:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
221 ! |
|
222 |
|
223 doUpdate |
|
224 |
|
225 ^self subclassResponsibility |
|
226 |
|
227 "Created: / 26-11-2009 / 14:54:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
228 ! ! |
|
229 |
|
230 !UpdateLikeTask methodsFor:'processing - private'! |
|
231 |
|
232 processAddedEntry:entry |
|
233 entry programmingLanguage isSmalltalk ifTrue:[ |
|
234 updates addAll:(ChangeSet fromStream:entry readStream) |
|
235 ] ifFalse:[ |
|
236 "/self error:'Non smalltalk source not yet supported' |
|
237 self breakPoint: #jv |
|
238 ] |
|
239 |
|
240 "Created: / 27-08-2009 / 08:54:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
241 "Modified: / 17-02-2010 / 13:52:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
242 ! |
|
243 |
|
244 processConflictEntry: entry |
|
245 |
|
246 | working merge base | |
|
247 |
|
248 "Ignore generated files, they will be regenerated..." |
|
249 (self filesToGenerate includes: entry path) ifTrue: |
|
250 [^self]. |
|
251 entry programmingLanguage isSmalltalk ifFalse: |
|
252 [^self error:'Only Smalltalk source file merging is supported right now, sorry.']. |
|
253 |
|
254 working := entry fileMergeWorking. |
|
255 merge := entry fileMergeRight. |
|
256 base := entry fileMergeLeft. |
|
257 |
|
258 conflicts add: |
|
259 ((ChangeSetDiff |
|
260 versionA: (ChangeSet fromFile: working) |
|
261 versionB: (ChangeSet fromFile: merge) |
|
262 versionBase: (ChangeSet fromFile: base)) |
|
263 name: entry className; |
|
264 versionALabel: 'Current (in image)'; |
|
265 versionBLabel: merge suffix , ' (to be merged in)'); |
|
266 versionBaseLabel: base suffix , ' (base)'. |
|
267 |
|
268 "Created: / 23-11-2009 / 17:40:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
269 "Modified: / 27-11-2009 / 11:34:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
270 "Modified: / 07-07-2011 / 20:02:50 / jv" |
|
271 ! |
|
272 |
|
273 processDeletedEntry:entry |
|
274 entry programmingLanguage isSmalltalk ifTrue:[ |
|
275 entry path = 'extensions.st' ifTrue:[ |
|
276 self halt "not yet finished" |
|
277 ]. |
|
278 self halt. |
|
279 ] |
|
280 |
|
281 "Created: / 27-08-2009 / 09:56:25 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
282 ! |
|
283 |
|
284 processMergedEntry: aWCNotification |
|
285 |
|
286 ^ self processUpdatedEntry: aWCNotification |
|
287 |
|
288 "Created: / 26-11-2009 / 15:36:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
289 "Modified: / 27-11-2009 / 11:12:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
290 ! |
|
291 |
|
292 processNoneEntry:entry |
|
293 |
|
294 "Nothing to do" |
|
295 |
|
296 "Created: / 07-04-2010 / 00:14:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
297 ! |
|
298 |
|
299 processUpdatedEntry:entry |
|
300 |
|
301 | class wcChangeset imageChangeset diffset | |
|
302 "We don't care about non source code files..." |
|
303 entry isSourceEntry ifFalse: |
|
304 [^self]. |
|
305 wcChangeset := entry asChangeSet. |
|
306 (wcChangeset first isClassDefinitionChange) |
|
307 ifTrue:[class := wcChangeset first changeClass]. |
|
308 (class isNil or:[class isLoaded not]) ifTrue:[^self]. |
|
309 imageChangeset := ChangeSet forExistingClass: class. |
|
310 |
|
311 diffset := imageChangeset diffSetsAgainst: wcChangeset. |
|
312 |
|
313 diffset onlyInReceiver do: |
|
314 [:chg|updates add:chg asAntiChange]. |
|
315 diffset changed do: |
|
316 [:chgPair|updates add:chgPair second]. |
|
317 diffset onlyInArg do: |
|
318 [:chg|updates add:chg]. |
|
319 |
|
320 "Created: / 26-11-2009 / 19:01:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
321 "Modified: / 27-11-2009 / 11:35:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
322 ! ! |
|
323 |
|
324 !UpdateLikeTask methodsFor:'queries'! |
|
325 |
|
326 hasChanges |
|
327 |
|
328 (updates isNil or:[conflicts isNil]) |
|
329 ifTrue:[self error:'#doComputeChanges should be invoked before asking for changes']. |
|
330 |
|
331 ^updates isEmpty not or:[conflicts isEmpty not] |
|
332 |
|
333 "Created: / 09-12-2009 / 17:39:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
334 ! ! |
|
335 |
|
336 !UpdateLikeTask methodsFor:'testing'! |
|
337 |
|
338 isMergeTask |
|
339 ^ false |
|
340 ! |
|
341 |
|
342 isUpdateTask |
|
343 ^ false |
|
344 ! ! |
|
345 |
|
346 !UpdateLikeTask class methodsFor:'documentation'! |
|
347 |
|
348 version |
|
349 ^ '$Header$' |
|
350 ! |
|
351 |
|
352 version_CVS |
|
353 ^ '$Header$' |
|
354 ! |
|
355 |
|
356 version_SVN |
|
357 ^ '§Id: SVN__UpdateLikeTask.st 352 2011-07-07 19:06:31Z vranyj1 §' |
|
358 ! ! |