62
|
1 |
"{ Package: 'cvut:stx/goodies/libsvn' }"
|
|
2 |
|
|
3 |
"{ NameSpace: SVN }"
|
|
4 |
|
|
5 |
Task subclass:#CVSTask
|
|
6 |
instanceVariableNames:'packageDir tmpDir cvsRoot transcript'
|
|
7 |
classVariableNames:'CVSRoot'
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SVN-Tasks'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!CVSTask class methodsFor:'instance creation'!
|
|
14 |
|
|
15 |
new
|
|
16 |
^ self basicNew initialize.
|
|
17 |
! !
|
|
18 |
|
|
19 |
!CVSTask class methodsFor:'accessing'!
|
|
20 |
|
|
21 |
cvsRoot
|
|
22 |
|
|
23 |
^CVSRoot
|
|
24 |
|
|
25 |
"
|
|
26 |
self cvsRoot
|
|
27 |
self cvsRoot: '/home/janfrog/Projects/SmalltalkX/sandbox/cvs'
|
|
28 |
"
|
|
29 |
|
|
30 |
"Created: / 25-05-2009 / 19:52:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
31 |
"Modified: / 26-05-2009 / 18:26:31 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
32 |
!
|
|
33 |
|
|
34 |
cvsRoot: aString
|
|
35 |
|
|
36 |
CVSRoot := aString
|
|
37 |
|
|
38 |
"
|
|
39 |
CVS2SVN_Convert cvsRoot: '/home/janfrog/Projects/SmalltalkX/sandbox/cvs'
|
|
40 |
"
|
|
41 |
|
|
42 |
"Created: / 25-05-2009 / 19:51:49 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
43 |
! !
|
|
44 |
|
|
45 |
!CVSTask class methodsFor:'execution'!
|
|
46 |
|
|
47 |
doFor:packages
|
|
48 |
self doFor:packages
|
|
49 |
logOn:Filename defaultTempDirectoryName pathName
|
|
50 |
, Filename separatorString , 'convert.log'
|
|
51 |
|
|
52 |
"Created: / 26-05-2009 / 18:20:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
53 |
"Modified: / 28-05-2009 / 11:41:56 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
54 |
!
|
|
55 |
|
|
56 |
doFor: pkgs logOn: log
|
|
57 |
| transcript packages failed |
|
|
58 |
|
|
59 |
packages := pkgs isString ifTrue: [ Array with: pkgs ] ifFalse: [ pkgs ].
|
|
60 |
transcript := SplittingWriteStream
|
|
61 |
on: Transcript
|
|
62 |
and: log asFilename writeStream.
|
|
63 |
transcript showCR: 'Logging on ' , log asString.
|
|
64 |
|
|
65 |
failed := false.
|
|
66 |
|
|
67 |
packages do:
|
|
68 |
[:pkg|
|
|
69 |
[self new package: pkg; transcript: transcript; do]
|
|
70 |
on: Error do:
|
|
71 |
[:ex|
|
|
72 |
transcript showCR: 'ERROR: Synchronization of ' , pkg , ' failed!!'.
|
|
73 |
ex suspendedContext fullPrintAllOn:transcript.
|
|
74 |
failed := true]].
|
|
75 |
failed ifTrue:
|
|
76 |
[transcript
|
|
77 |
showCR:'Synchronization of one or more packages failed!!';
|
|
78 |
showCR:'See the log for details'].
|
|
79 |
|
|
80 |
transcript outStream2 close.
|
|
81 |
|
|
82 |
"Created: / 26-05-2009 / 18:08:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
83 |
"Modified: / 19-08-2009 / 12:39:35 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
84 |
! !
|
|
85 |
|
|
86 |
!CVSTask methodsFor:'accessing'!
|
|
87 |
|
|
88 |
cvsRoot
|
|
89 |
^ cvsRoot
|
|
90 |
!
|
|
91 |
|
|
92 |
cvsRoot:aStringOrFilename
|
|
93 |
cvsRoot := aStringOrFilename asFilename.
|
|
94 |
|
|
95 |
"Modified: / 25-05-2009 / 19:54:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
96 |
!
|
|
97 |
|
|
98 |
obsoleteFileNames
|
|
99 |
|
|
100 |
^#(
|
|
101 |
'.cvsignore'
|
|
102 |
)
|
|
103 |
|
|
104 |
"Created: / 30-05-2009 / 15:48:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
105 |
"Modified: / 02-06-2009 / 13:38:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
106 |
!
|
|
107 |
|
|
108 |
package
|
|
109 |
^ package
|
|
110 |
!
|
|
111 |
|
|
112 |
package: aStringOrSymbol
|
|
113 |
package := aStringOrSymbol asSymbol.
|
|
114 |
packageDir := (aStringOrSymbol asString copyReplaceAll: $: with: $/)
|
|
115 |
asSymbol.
|
|
116 |
workingCopy := self svnWorkingCopy.
|
|
117 |
|
|
118 |
"Modified: / 19-08-2009 / 11:26:24 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
119 |
!
|
|
120 |
|
|
121 |
svnWorkingCopyPath
|
|
122 |
^ (tmpDir construct: 'svn-working-copy') construct: (packageDir asFilename baseName)
|
|
123 |
|
|
124 |
"Modified: / 19-08-2009 / 11:25:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
125 |
!
|
|
126 |
|
|
127 |
transcript
|
|
128 |
^ transcript
|
|
129 |
!
|
|
130 |
|
|
131 |
transcript:something
|
|
132 |
transcript := something.
|
|
133 |
! !
|
|
134 |
|
|
135 |
!CVSTask methodsFor:'executing'!
|
|
136 |
|
|
137 |
doCleanup
|
|
138 |
|
|
139 |
tmpDir recursiveRemove
|
|
140 |
|
|
141 |
"Created: / 29-05-2009 / 17:17:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
142 |
!
|
|
143 |
|
|
144 |
doFixPackageContentIn: dir
|
|
145 |
|
|
146 |
self
|
|
147 |
doRemoveObsoleteFilesIn: dir;
|
|
148 |
doNormalizeClassContainerNamesIn: dir;
|
|
149 |
doNormalizeEndOfLineIn: dir;
|
|
150 |
doNormalizeVersionMethodIn: dir
|
|
151 |
|
|
152 |
"Created: / 02-06-2009 / 17:31:18 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
153 |
! !
|
|
154 |
|
|
155 |
!CVSTask methodsFor:'executing - helpers'!
|
|
156 |
|
|
157 |
doNormalizeClassContainerNamesIn: dir
|
|
158 |
| files |
|
|
159 |
|
|
160 |
self notify: 'Normalizing class container names'.
|
|
161 |
files := dir directoryContentsAsFilenamesMatching: '*.st'.
|
|
162 |
files do:
|
|
163 |
[:file |
|
|
164 |
| change |
|
|
165 |
|
|
166 |
change := (ChangeSet fromFile: file) first.
|
|
167 |
change isClassDefinitionChange
|
|
168 |
ifTrue:
|
|
169 |
[ | oldName newName |
|
|
170 |
|
|
171 |
oldName := file baseName.
|
|
172 |
newName := (change className replaceAll: $: with: $_) , '.st'.
|
|
173 |
oldName ~= newName
|
|
174 |
ifTrue:
|
|
175 |
[ | sed |
|
|
176 |
|
|
177 |
self renameFile: (dir / oldName) to: (dir / newName).
|
|
178 |
"
|
|
179 |
Also, we have to update makefiles. Grrr, I hate this
|
|
180 |
build system.
|
|
181 |
"
|
|
182 |
sed := (OSProcess new)
|
|
183 |
executable: '/bin/sed';
|
|
184 |
workdir: dir;
|
|
185 |
arguments: (Array
|
|
186 |
with: '-i'
|
|
187 |
with: '-e'
|
|
188 |
with: ('"s/' , (oldName upTo: $.) , '/' , (newName upTo: $.) , '/g"'))
|
|
189 |
, (dir
|
|
190 |
directoryContentsMatching: #( 'Make.*' 'Makefile' 'makefile' '*.mak' 'abbrev.stc' ));
|
|
191 |
stdout: transcript;
|
|
192 |
stderr: transcript.
|
|
193 |
sed execute.
|
|
194 |
self assert: sed exitValue = 0
|
|
195 |
message: 'sed failed to finish properly. Check transcript'. ] ] ].
|
|
196 |
|
|
197 |
"Created: / 29-05-2009 / 18:27:10 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
198 |
"Modified: / 03-06-2009 / 12:19:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
199 |
!
|
|
200 |
|
|
201 |
doNormalizeEndOfLineIn: dir
|
|
202 |
| files sed |
|
|
203 |
|
|
204 |
self notify: 'Normalizing end-of-lines'.
|
|
205 |
files := dir directoryContentsAsFilenames select: [:e | e suffix = 'st' ].
|
|
206 |
sed := (OSProcess new)
|
|
207 |
executable: '/bin/sed';
|
|
208 |
arguments: (Array
|
|
209 |
with: '-i'
|
|
210 |
with: '-e'
|
|
211 |
with: 's/\r[^\n]/\n/g') , (files collect: [:e | e pathName ]);
|
|
212 |
stdout: transcript;
|
|
213 |
stderr: transcript.
|
|
214 |
sed execute.
|
|
215 |
self assert: sed exitValue = 0
|
|
216 |
message: 'sed failed to finish properly. Check transcript'.
|
|
217 |
|
|
218 |
"Created: / 29-05-2009 / 18:27:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
219 |
"Modified: / 30-05-2009 / 16:06:18 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
220 |
!
|
|
221 |
|
|
222 |
doNormalizeVersionMethodIn: dir
|
|
223 |
|
|
224 |
self doNormalizeVersionMethodIn: dir doCopy: false
|
|
225 |
|
|
226 |
"Created: / 29-05-2009 / 18:27:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
227 |
"Modified: / 03-06-2009 / 11:22:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
228 |
!
|
|
229 |
|
|
230 |
doNormalizeVersionMethodIn: dir doCopy: doCopy
|
|
231 |
| files sed |
|
|
232 |
|
|
233 |
self notify: 'Normalizing #version methods'.
|
|
234 |
files := dir
|
|
235 |
directoryContentsAsFilenamesMatching: #( '*.st' 'Make.*' 'Makefile' 'makefile' '*.mak' '*.c' '*.cc' ).
|
|
236 |
doCopy
|
|
237 |
ifTrue:
|
|
238 |
[ files do: [:f | f copyTo: (f pathName , '~') asFilename ].
|
|
239 |
files := files collect: [:f | (f pathName , '~') asFilename ] ].
|
|
240 |
sed := (OSProcess new)
|
|
241 |
executable: '/bin/sed';
|
|
242 |
arguments: (Array
|
|
243 |
with: '-i'
|
|
244 |
with: '-e'
|
|
245 |
with: '"s/''\$Id.*\$''/''\$Id\$''/g"'
|
|
246 |
with: '-e'
|
|
247 |
with: '"s/''\$Header.*\$''/''\$Id\$''/g"')
|
|
248 |
, (files collect: [:e | e pathName ]);
|
|
249 |
stdout: transcript;
|
|
250 |
stderr: transcript.
|
|
251 |
sed execute.
|
|
252 |
self assert: sed exitValue = 0
|
|
253 |
message: 'sed failed to finish properly. Check transcript'.
|
|
254 |
|
|
255 |
"Created: / 03-06-2009 / 11:26:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
256 |
!
|
|
257 |
|
|
258 |
doRemoveDuplicateCommaVFilesInAtticIn:cvsDir
|
|
259 |
|cvsAtticDir cvsDirContents|
|
|
260 |
|
|
261 |
cvsAtticDir := cvsDir construct:'Attic'.
|
|
262 |
cvsDirContents := cvsDir directoryContents.
|
|
263 |
cvsAtticDir exists ifTrue:[
|
|
264 |
cvsAtticDir
|
|
265 |
directoryContentsAsFilenamesDo:[:atticFile |
|
|
266 |
(cvsDirContents includes:atticFile baseName) ifTrue:[
|
|
267 |
self info:'removing stale file ' , atticFile baseName , ' in Attic'.
|
|
268 |
atticFile remove
|
|
269 |
|
|
270 |
"/cvsAtticDir remove.
|
|
271 |
]
|
|
272 |
]
|
|
273 |
].
|
|
274 |
cvsDir
|
|
275 |
directoryContentsAsFilenamesDo:[:file |
|
|
276 |
(file isDirectory and:[ file baseName ~= 'Attic' ]) ifTrue:[
|
|
277 |
self doRemoveDuplicateCommaVFilesInAtticIn:file
|
|
278 |
]
|
|
279 |
]
|
|
280 |
|
|
281 |
"Created: / 25-05-2009 / 22:35:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
282 |
"Modified: / 26-05-2009 / 18:27:06 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
283 |
!
|
|
284 |
|
|
285 |
doRemoveObsoleteFilesIn: dir
|
|
286 |
|
|
287 |
self notify: 'Removing obsolete files'.
|
|
288 |
self removeFiles: self obsoleteFileNames.
|
|
289 |
|
|
290 |
"Created: / 30-05-2009 / 15:43:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
291 |
!
|
|
292 |
|
|
293 |
doSVNAddFilesFor: files
|
|
294 |
self notify: 'Adding files'.
|
|
295 |
files isEmpty ifTrue: [ ^ self ].
|
|
296 |
(AddCommand new)
|
|
297 |
workingCopy: workingCopy;
|
|
298 |
paths: files;
|
|
299 |
execute
|
|
300 |
|
|
301 |
"Created: / 02-06-2009 / 19:01:17 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
302 |
"Modified: / 19-08-2009 / 11:26:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
303 |
!
|
|
304 |
|
|
305 |
doSVNSetSvnEolStylePropertyFor: files
|
|
306 |
self notify: 'Setting svn:eol-style property to LF'.
|
|
307 |
files isEmpty ifTrue: [ ^ self ].
|
|
308 |
(PropsetCommand new)
|
|
309 |
workingCopy: workingCopy;
|
|
310 |
name: 'svn:eol-style';
|
|
311 |
value: 'LF';
|
|
312 |
paths: files;
|
|
313 |
execute
|
|
314 |
|
|
315 |
"Modified: / 19-08-2009 / 11:27:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
316 |
!
|
|
317 |
|
|
318 |
doSVNSetSvnKeywordPropertyFor: files
|
|
319 |
self notify: 'Setting svn:keywords property to Id'.
|
|
320 |
files isEmpty ifTrue: [ ^ self ].
|
|
321 |
(PropsetCommand new)
|
|
322 |
workingCopy: workingCopy;
|
|
323 |
name: 'svn:keywords';
|
|
324 |
value: 'Id';
|
|
325 |
paths: files;
|
|
326 |
execute
|
|
327 |
|
|
328 |
"Modified: / 19-08-2009 / 11:27:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
329 |
! !
|
|
330 |
|
|
331 |
!CVSTask methodsFor:'executing - private'!
|
|
332 |
|
|
333 |
doSVNCheckout
|
|
334 |
self notify: 'Checking out'.
|
|
335 |
workingCopy checkout: Revision head
|
|
336 |
|
|
337 |
"Modified: / 19-08-2009 / 12:42:48 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
338 |
!
|
|
339 |
|
|
340 |
doSVNCommit
|
|
341 |
self notify: 'Commiting'.
|
|
342 |
(CommitCommand new)
|
|
343 |
workingCopy: workingCopy;
|
|
344 |
message: self svnCommitMessage;
|
|
345 |
execute
|
|
346 |
|
|
347 |
"Created: / 29-05-2009 / 18:13:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
348 |
"Modified: / 19-08-2009 / 11:28:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
349 |
! !
|
|
350 |
|
|
351 |
!CVSTask methodsFor:'initialization'!
|
|
352 |
|
|
353 |
initialize
|
|
354 |
|
|
355 |
cvsRoot := self class cvsRoot asFilename.
|
|
356 |
tmpDir := Filename newTemporaryDirectory.
|
|
357 |
|
|
358 |
"Modified: / 29-05-2009 / 17:13:53 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
359 |
! !
|
|
360 |
|
|
361 |
!CVSTask methodsFor:'passes'!
|
|
362 |
|
|
363 |
normalizeVersionMethod: files
|
|
364 |
| sed |
|
|
365 |
|
|
366 |
sed := (OSProcess new)
|
|
367 |
executable: '/bin/sed';
|
|
368 |
arguments: (Array
|
|
369 |
with: '-i'
|
|
370 |
with: '-e'
|
|
371 |
with: '"s/\^\ ?''$Id.*$''/\^''$' , 'Id$' , '''/g"'
|
|
372 |
with: '-e'
|
|
373 |
with: '"s/\^\ ?''\$Header.*\$''/\^ ''\$Id\$''/g"')
|
|
374 |
, (files collect: [:e | e pathName ]);
|
|
375 |
stdout: transcript;
|
|
376 |
stderr: transcript.
|
|
377 |
sed execute.
|
|
378 |
self assert: sed exitValue = 0
|
|
379 |
message: 'sed failed to finish properly. Check transcript'.
|
|
380 |
|
|
381 |
"Modified: / 19-08-2009 / 11:02:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
382 |
! !
|
|
383 |
|
|
384 |
!CVSTask methodsFor:'private'!
|
|
385 |
|
|
386 |
removeFiles:arg
|
|
387 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
388 |
|
|
389 |
^ self subclassResponsibility
|
|
390 |
!
|
|
391 |
|
|
392 |
renameFile:arg1 to:arg2
|
|
393 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
394 |
|
|
395 |
^ self subclassResponsibility
|
|
396 |
!
|
|
397 |
|
|
398 |
svnBranch
|
|
399 |
|
|
400 |
^Branch repository: self svnRepository path: self svnBranchPath
|
|
401 |
|
|
402 |
"Created: / 19-08-2009 / 11:20:16 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
403 |
!
|
|
404 |
|
|
405 |
svnBranchPath
|
|
406 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
407 |
|
|
408 |
^ self subclassResponsibility
|
|
409 |
|
|
410 |
"Created: / 19-08-2009 / 11:18:18 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
411 |
!
|
|
412 |
|
|
413 |
svnCommitMessage
|
|
414 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
415 |
|
|
416 |
^ self subclassResponsibility
|
|
417 |
!
|
|
418 |
|
|
419 |
svnRepository
|
|
420 |
|
|
421 |
^Repository package: package url: self svnRepositoryUrl
|
|
422 |
|
|
423 |
"Created: / 19-08-2009 / 11:12:25 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
424 |
"Modified: / 19-08-2009 / 12:23:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
425 |
!
|
|
426 |
|
|
427 |
svnRepositoryUrl
|
|
428 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
429 |
|
|
430 |
^ self subclassResponsibility
|
|
431 |
!
|
|
432 |
|
|
433 |
svnWorkingCopy
|
|
434 |
"raise an error: must be redefined in concrete subclass(es)"
|
|
435 |
|
|
436 |
^WorkingCopy
|
|
437 |
branch: self svnBranch
|
|
438 |
path: self svnWorkingCopyPath
|
|
439 |
|
|
440 |
"Created: / 19-08-2009 / 11:23:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
441 |
! !
|
|
442 |
|
|
443 |
!CVSTask class methodsFor:'documentation'!
|
|
444 |
|
|
445 |
version
|
|
446 |
^ '$Header$'
|
131
|
447 |
!
|
|
448 |
|
|
449 |
version_CVS
|
|
450 |
^ '$Header$'
|
|
451 |
!
|
|
452 |
|
|
453 |
version_SVN
|
|
454 |
^'Id: SVN__CVSTask.st 110 2009-08-19 13:21:10Z vranyj1 '
|
62
|
455 |
! !
|