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