author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Wed, 08 Feb 2012 09:53:30 +0100 | |
changeset 992 | 6abbd4b70f2d |
parent 849 | 29ba71795d59 |
child 993 | 4c27971cd991 |
permissions | -rw-r--r-- |
677 | 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 |
" |
|
387 | 26 |
"{ Package: 'stx:libsvn' }" |
74 | 27 |
|
28 |
"{ NameSpace: SVN }" |
|
29 |
||
30 |
CVSTask subclass:#SyncWithCVSTask |
|
31 |
instanceVariableNames:'cvsWc newFiles obsoleteFiles branchPath' |
|
32 |
classVariableNames:'' |
|
33 |
poolDictionaries:'' |
|
34 |
category:'SVN-Tasks' |
|
35 |
! |
|
36 |
||
677 | 37 |
!SyncWithCVSTask 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 |
! ! |
|
74 | 67 |
|
68 |
!SyncWithCVSTask class methodsFor:'accessing'! |
|
69 |
||
70 |
cvsRoot |
|
71 |
||
72 |
^(Smalltalk at:#CVSSourceCodeManager:CVSRoot) |
|
73 |
? CVSRoot |
|
74 |
? ':pserver:cvs@cvs.smalltalk-x.de:/cvs/stx' |
|
75 |
||
76 |
"Created: / 19-08-2009 / 11:44:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
77 |
! ! |
|
78 |
||
677 | 79 |
!SyncWithCVSTask class methodsFor:'others'! |
80 |
||
81 |
version_CVS |
|
849
29ba71795d59
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
677
diff
changeset
|
82 |
^ '$Header$' |
677 | 83 |
! ! |
84 |
||
74 | 85 |
!SyncWithCVSTask class methodsFor:'updating'! |
86 |
||
87 |
update:pkgs |
|
88 |
^ self doFor:pkgs |
|
89 |
||
90 |
"Created: / 28-05-2009 / 11:10:01 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
91 |
! |
|
92 |
||
93 |
update:pkgs logOn:log |
|
94 |
^ self doFor:pkgs logOn:log |
|
95 |
||
96 |
"Created: / 28-05-2009 / 11:09:55 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
97 |
! |
|
98 |
||
99 |
updateJv |
|
100 |
"Updates repositories at smalltalk.felk.cvut.cz" |
|
101 |
||
102 |
" |
|
103 |
SVN::SyncWithCVSTask updateJv |
|
104 |
" |
|
105 |
||
106 |
self |
|
107 |
update:#( |
|
108 |
#'stx:libbasic' |
|
109 |
#'stx:libbasic2' |
|
992 | 110 |
"/ #'stx:libbasic3' |
677 | 111 |
#'stx:libcomp' |
992 | 112 |
"/ #'stx:libcompat' |
677 | 113 |
#'stx:libjavascript' |
74 | 114 |
#'stx:libtool' |
992 | 115 |
"/ #'stx:libview' |
116 |
"/ #'stx:goodies/sunit' |
|
74 | 117 |
) |
118 |
logOn: |
|
119 |
Filename homeDirectory / 'Projects' / 'SmalltalkX' / |
|
120 |
('cvs-sync-log-', (Date today printStringFormat:'%y-%m-%d') , '.txt') |
|
121 |
||
122 |
"Created: / 19-08-2009 / 11:34:31 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
123 |
"Modified: / 19-08-2009 / 12:49:59 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
992 | 124 |
"Modified: / 08-02-2012 / 08:52:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 125 |
! ! |
126 |
||
127 |
!SyncWithCVSTask methodsFor:'accessing'! |
|
128 |
||
129 |
branchPath |
|
130 |
^ branchPath |
|
131 |
! |
|
132 |
||
133 |
branchPath:aString |
|
134 |
||
135 |
branchPath := aString. |
|
136 |
||
137 |
"Modified: / 19-08-2009 / 11:17:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
138 |
! |
|
139 |
||
140 |
package: aString |
|
141 |
||
142 |
super package: aString. |
|
143 |
(tmpDir construct: 'cvs-working-copy') recursiveMakeDirectory. |
|
144 |
cvsWc := (tmpDir construct: 'cvs-working-copy') construct: packageDir. |
|
145 |
cvsRoot := CVSSourceCodeManager getCVSROOTForModule: package. |
|
146 |
||
147 |
"Created: / 28-05-2009 / 09:22:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
148 |
"Modified: / 28-05-2009 / 11:45:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
149 |
! ! |
|
150 |
||
151 |
!SyncWithCVSTask methodsFor:'executing'! |
|
152 |
||
153 |
do |
|
154 |
self notify: 'Syncing package ', package. |
|
155 |
self |
|
156 |
doCVSCheckout; |
|
157 |
doCVSFixPackageContent; |
|
158 |
doSVNCheckout; |
|
159 |
doUpdate; |
|
160 |
doSVNCommit; |
|
161 |
doCleanup. |
|
162 |
self notify: 'Package ' , package , ' synced' |
|
163 |
||
164 |
"Created: / 02-06-2009 / 18:41:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
165 |
! |
|
166 |
||
167 |
doCVSFixPackageContent |
|
168 |
||
169 |
self |
|
170 |
doFixPackageContentIn:cvsWc |
|
171 |
||
172 |
"Created: / 02-06-2009 / 18:51:52 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
173 |
! |
|
174 |
||
175 |
doUpdate |
|
176 |
self |
|
677 | 177 |
doCopyFiles; |
74 | 178 |
doNormalizeVersionMethodIn: workingCopy path doCopy: true; |
179 |
doSVNAddFiles: newFiles; |
|
677 | 180 |
doSVNSetSvnKeywordPropertyFor: (newFiles reject:[:f|f isDirectory]); |
181 |
doSVNSetSvnEolStylePropertyFor: (newFiles reject:[:f|f isDirectory]); |
|
74 | 182 |
yourself |
183 |
||
184 |
"Created: / 02-06-2009 / 18:59:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
185 |
"Modified: / 19-08-2009 / 11:26:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
677 | 186 |
"Modified: / 23-04-2011 / 12:47:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 187 |
! ! |
188 |
||
189 |
!SyncWithCVSTask methodsFor:'executing - private'! |
|
190 |
||
191 |
doCVSCheckout |
|
192 |
||
193 |
| cvs | |
|
194 |
cvs := OSProcess new |
|
195 |
executable: '/usr/bin/cvs'; |
|
196 |
arguments: { |
|
197 |
'-d'. |
|
198 |
cvsRoot. |
|
199 |
'checkout'. |
|
200 |
packageDir. |
|
201 |
}; |
|
202 |
stdout: transcript; |
|
203 |
stderr: transcript; |
|
204 |
workdir: (tmpDir construct:'cvs-working-copy'). |
|
205 |
cvs execute. |
|
206 |
self |
|
207 |
assert: cvs exitValue = 0 |
|
208 |
message: 'cvs failed to finish properly. Check transcript'. |
|
209 |
||
210 |
"Created: / 02-06-2009 / 17:19:42 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
211 |
"Modified: / 19-08-2009 / 11:47:59 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
212 |
! |
|
213 |
||
214 |
doCopyFiles |
|
215 |
| cvsFiles svnFilesSeen | |
|
216 |
||
217 |
cvsFiles := cvsWc recursiveDirectoryContents |
|
218 |
reject: [:e | e asFilename directoryName endsWith: 'CVS' ]. |
|
219 |
svnFilesSeen := Set new. |
|
220 |
cvsFiles do: |
|
221 |
[:cvsFileName | |
|
222 |
| cvsFile svnFile svnFileCopy | |
|
223 |
||
224 |
cvsFile := cvsWc construct: cvsFileName. |
|
225 |
svnFile := workingCopy path / cvsFileName. |
|
226 |
svnFileCopy := workingCopy path / (cvsFileName , '~'). |
|
227 |
svnFilesSeen add: svnFile. |
|
228 |
svnFile exists |
|
229 |
ifTrue: |
|
230 |
[ (self is: cvsFile |
|
231 |
sameAs: (svnFileCopy exists ifTrue: [ svnFileCopy ] ifFalse: [ svnFile ])) |
|
232 |
ifFalse: |
|
233 |
[ cvsFile copyTo: svnFile. |
|
234 |
self notify: 'Updating ' , cvsFileName. ]. |
|
235 |
svnFileCopy exists ifTrue: [ self removeFiles: (Array with: svnFileCopy) ] ] |
|
236 |
ifFalse: |
|
677 | 237 |
[ |
238 |
| svnDir | |
|
239 |
svnDir := svnFile directory. |
|
240 |
[svnDir exists] whileFalse: |
|
241 |
[svnDir recursiveMakeDirectory. |
|
242 |
newFiles addFirst: svnDir. |
|
243 |
svnDir := svnDir directory]. |
|
244 |
||
245 |
newFiles add: svnFile. |
|
74 | 246 |
cvsFile copyTo: svnFile. |
247 |
self notify: 'Updating ' , cvsFileName. ]. ]. |
|
248 |
obsoleteFiles := (workingCopy path recursiveDirectoryContentsAsFilenames |
|
249 |
reject: [:e | e directory baseName = '.svn' ]) \ svnFilesSeen. |
|
250 |
||
251 |
"Created: / 02-06-2009 / 18:52:07 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
252 |
"Modified: / 19-08-2009 / 11:27:41 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
677 | 253 |
"Modified: / 20-11-2009 / 11:36:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 254 |
! |
255 |
||
256 |
doSVNAddFiles |
|
677 | 257 |
|
258 |
| newFileNames | |
|
74 | 259 |
newFiles isEmpty ifTrue: [ ^ self ]. |
677 | 260 |
|
261 |
newFileNames := newFiles collect: [:e | e pathName ]. |
|
262 |
||
74 | 263 |
(AddCommand new) |
264 |
workingCopy: workingCopy; |
|
677 | 265 |
paths: newFileNames; |
74 | 266 |
execute. |
267 |
||
268 |
"Created: / 28-05-2009 / 10:59:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
269 |
"Modified: / 19-08-2009 / 11:27:46 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
677 | 270 |
"Modified: / 23-04-2011 / 12:41:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 271 |
! |
272 |
||
273 |
doSVNAddFiles: files |
|
274 |
files isEmpty ifTrue: [ ^ self ]. |
|
275 |
(AddCommand new) |
|
276 |
workingCopy: workingCopy; |
|
277 |
paths: (files collect: [:e | e pathName ]); |
|
278 |
execute. |
|
279 |
||
280 |
"Created: / 02-06-2009 / 19:39:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
281 |
"Modified: / 19-08-2009 / 11:27:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
282 |
! ! |
|
283 |
||
284 |
!SyncWithCVSTask methodsFor:'initialization'! |
|
285 |
||
286 |
initialize |
|
287 |
||
288 |
super initialize. |
|
289 |
branchPath := '/trunk'. |
|
677 | 290 |
newFiles := OrderedSet new. |
74 | 291 |
obsoleteFiles := Set new. |
292 |
||
293 |
"Created: / 28-05-2009 / 09:08:32 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
294 |
"Modified: / 19-08-2009 / 12:29:57 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
677 | 295 |
"Modified: / 20-11-2009 / 11:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
74 | 296 |
! ! |
297 |
||
298 |
!SyncWithCVSTask methodsFor:'passes'! |
|
299 |
||
300 |
pass56_RemoveFiles |
|
301 |
||
302 |
" |
|
303 |
svnFilesObsolete isEmpty ifTrue:[^self]. |
|
304 |
||
305 |
DeleteCommand new |
|
306 |
workingCopy:svnWc pathName; |
|
307 |
paths:(svnFilesObsolete collect:[:e|e pathName]); |
|
308 |
execute. |
|
309 |
" |
|
310 |
||
311 |
"Created: / 28-05-2009 / 10:59:58 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
312 |
"Modified: / 28-05-2009 / 17:52:36 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
313 |
! ! |
|
314 |
||
315 |
!SyncWithCVSTask methodsFor:'private'! |
|
316 |
||
317 |
is: fileA sameAs: fileB |
|
318 |
||
319 |
^false"/(fileA suffix = 'st' and:[fileB suffix = 'st']) |
|
320 |
ifTrue: [self isSource: fileA sameAs: fileB] |
|
321 |
ifFalse:[self isContent: fileA sameAs: fileB] |
|
322 |
||
323 |
"Created: / 28-05-2009 / 19:58:05 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
324 |
"Modified: / 02-06-2009 / 20:04:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
325 |
! |
|
326 |
||
327 |
isContent: fileA sameAs: fileB |
|
328 |
||
329 |
^( |
|
330 |
(MD5Stream hashValueOfFile: fileA) |
|
331 |
= (MD5Stream hashValueOfFile: fileB) |
|
332 |
) |
|
333 |
ifTrue:[true] ifFalse:["self halt."false] |
|
334 |
||
335 |
"Created: / 28-05-2009 / 22:28:04 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
336 |
"Modified: / 03-06-2009 / 11:12:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
337 |
! |
|
338 |
||
339 |
isSource: fileA sameAs: fileB |
|
340 |
||
341 |
|rejectedVersionMethods changeSetA changeSetB diff | |
|
342 |
||
343 |
rejectedVersionMethods := #( version version_CVS version_SVN ). |
|
344 |
||
345 |
changeSetA := (ChangeSet fromFile: fileA) reject: |
|
346 |
[:ch|ch isMethodChange |
|
347 |
and:[ch isForMeta |
|
348 |
and:[rejectedVersionMethods includes:ch changeSelector]]]. |
|
349 |
changeSetB := (ChangeSet fromFile: fileB) reject: |
|
350 |
[:ch|ch isMethodChange |
|
351 |
and:[ch isForMeta |
|
352 |
and:[rejectedVersionMethods includes:ch changeSelector]]]. |
|
353 |
diff := changeSetA diffSetsAgainst: changeSetB. |
|
354 |
^diff isEmpty |
|
355 |
||
356 |
"Created: / 28-05-2009 / 22:27:01 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
357 |
"Modified: / 02-06-2009 / 20:22:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
358 |
! |
|
359 |
||
360 |
removeFiles: files |
|
361 |
||
362 |
files do: |
|
363 |
[:file|(cvsWc construct: file) remove] |
|
364 |
||
365 |
"Modified: / 02-06-2009 / 19:53:40 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
366 |
! |
|
367 |
||
368 |
renameFile:file1 to:file2 |
|
369 |
||
370 |
file1 asFilename renameTo: file2 asString |
|
371 |
||
372 |
"Modified: / 02-06-2009 / 19:36:29 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
373 |
! |
|
374 |
||
375 |
svnBranchPath |
|
376 |
||
377 |
^branchPath |
|
378 |
||
379 |
"Created: / 19-08-2009 / 11:16:54 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
380 |
! |
|
381 |
||
382 |
svnCommitMessage |
|
383 |
||
384 |
^'Synchronized with CVS repository at: |
|
385 |
', cvsRoot asString |
|
386 |
||
387 |
"Created: / 28-05-2009 / 09:18:02 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
388 |
! |
|
389 |
||
390 |
svnRepositoryUrl |
|
391 |
||
392 |
^ (RepositoryManager repositoryUrlForPackage: package) |
|
393 |
||
394 |
"Modified: / 19-08-2009 / 11:09:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
395 |
! ! |
|
396 |
||
397 |
!SyncWithCVSTask class methodsFor:'documentation'! |
|
398 |
||
399 |
version |
|
849
29ba71795d59
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
677
diff
changeset
|
400 |
^ '$Header$' |
158 | 401 |
! |
402 |
||
403 |
version_SVN |
|
849
29ba71795d59
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
677
diff
changeset
|
404 |
^ '§Id: SVN__SyncWithCVSTask.st 362 2011-08-08 13:07:42Z vranyj1 §' |
74 | 405 |
! ! |