74
|
1 |
"{ Package: 'cvut:stx/goodies/libsvn' }"
|
|
2 |
|
|
3 |
"{ NameSpace: SVN }"
|
|
4 |
|
|
5 |
CVSTask subclass:#SyncWithCVSTask
|
|
6 |
instanceVariableNames:'cvsWc newFiles obsoleteFiles branchPath'
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
|
9 |
category:'SVN-Tasks'
|
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!SyncWithCVSTask class methodsFor:'accessing'!
|
|
14 |
|
|
15 |
cvsRoot
|
|
16 |
|
|
17 |
^(Smalltalk at:#CVSSourceCodeManager:CVSRoot)
|
|
18 |
? CVSRoot
|
|
19 |
? ':pserver:cvs@cvs.smalltalk-x.de:/cvs/stx'
|
|
20 |
|
|
21 |
"Created: / 19-08-2009 / 11:44:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
22 |
! !
|
|
23 |
|
|
24 |
!SyncWithCVSTask class methodsFor:'updating'!
|
|
25 |
|
|
26 |
update:pkgs
|
|
27 |
^ self doFor:pkgs
|
|
28 |
|
|
29 |
"Created: / 28-05-2009 / 11:10:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
30 |
!
|
|
31 |
|
|
32 |
update:pkgs logOn:log
|
|
33 |
^ self doFor:pkgs logOn:log
|
|
34 |
|
|
35 |
"Created: / 28-05-2009 / 11:09:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
36 |
!
|
|
37 |
|
|
38 |
updateJv
|
|
39 |
"Updates repositories at smalltalk.felk.cvut.cz"
|
|
40 |
|
|
41 |
"
|
|
42 |
SVN::SyncWithCVSTask updateJv
|
|
43 |
"
|
|
44 |
|
|
45 |
self
|
|
46 |
update:#(
|
|
47 |
#'stx:libbasic'
|
|
48 |
#'stx:libbasic2'
|
|
49 |
#'stx:libbasic3'
|
|
50 |
#'stx:libtool'
|
|
51 |
)
|
|
52 |
logOn:
|
|
53 |
Filename homeDirectory / 'Projects' / 'SmalltalkX' /
|
|
54 |
('cvs-sync-log-', (Date today printStringFormat:'%y-%m-%d') , '.txt')
|
|
55 |
|
|
56 |
"Created: / 19-08-2009 / 11:34:31 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
57 |
"Modified: / 19-08-2009 / 12:49:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
58 |
! !
|
|
59 |
|
|
60 |
!SyncWithCVSTask methodsFor:'accessing'!
|
|
61 |
|
|
62 |
branchPath
|
|
63 |
^ branchPath
|
|
64 |
!
|
|
65 |
|
|
66 |
branchPath:aString
|
|
67 |
|
|
68 |
branchPath := aString.
|
|
69 |
|
|
70 |
"Modified: / 19-08-2009 / 11:17:38 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
71 |
!
|
|
72 |
|
|
73 |
package: aString
|
|
74 |
|
|
75 |
super package: aString.
|
|
76 |
(tmpDir construct: 'cvs-working-copy') recursiveMakeDirectory.
|
|
77 |
cvsWc := (tmpDir construct: 'cvs-working-copy') construct: packageDir.
|
|
78 |
cvsRoot := CVSSourceCodeManager getCVSROOTForModule: package.
|
|
79 |
|
|
80 |
"Created: / 28-05-2009 / 09:22:39 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
81 |
"Modified: / 28-05-2009 / 11:45:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
82 |
! !
|
|
83 |
|
|
84 |
!SyncWithCVSTask methodsFor:'executing'!
|
|
85 |
|
|
86 |
do
|
|
87 |
self notify: 'Syncing package ', package.
|
|
88 |
self
|
|
89 |
doCVSCheckout;
|
|
90 |
doCVSFixPackageContent;
|
|
91 |
doSVNCheckout;
|
|
92 |
doUpdate;
|
|
93 |
doSVNCommit;
|
|
94 |
doCleanup.
|
|
95 |
self notify: 'Package ' , package , ' synced'
|
|
96 |
|
|
97 |
"Created: / 02-06-2009 / 18:41:46 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
98 |
!
|
|
99 |
|
|
100 |
doCVSFixPackageContent
|
|
101 |
|
|
102 |
self
|
|
103 |
doFixPackageContentIn:cvsWc
|
|
104 |
|
|
105 |
"Created: / 02-06-2009 / 18:51:52 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
106 |
!
|
|
107 |
|
|
108 |
doUpdate
|
|
109 |
self
|
|
110 |
doNormalizeVersionMethodIn: workingCopy path doCopy: true;
|
|
111 |
doCopyFiles;
|
|
112 |
doSVNAddFiles: newFiles;
|
|
113 |
doSVNSetSvnKeywordPropertyFor: newFiles;
|
|
114 |
doSVNSetSvnEolStylePropertyFor: newFiles;
|
|
115 |
yourself
|
|
116 |
|
|
117 |
"Created: / 02-06-2009 / 18:59:19 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
118 |
"Modified: / 19-08-2009 / 11:26:44 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
119 |
! !
|
|
120 |
|
|
121 |
!SyncWithCVSTask methodsFor:'executing - private'!
|
|
122 |
|
|
123 |
doCVSCheckout
|
|
124 |
|
|
125 |
| cvs |
|
|
126 |
cvs := OSProcess new
|
|
127 |
executable: '/usr/bin/cvs';
|
|
128 |
arguments: {
|
|
129 |
'-d'.
|
|
130 |
cvsRoot.
|
|
131 |
'checkout'.
|
|
132 |
packageDir.
|
|
133 |
};
|
|
134 |
stdout: transcript;
|
|
135 |
stderr: transcript;
|
|
136 |
workdir: (tmpDir construct:'cvs-working-copy').
|
|
137 |
cvs execute.
|
|
138 |
self
|
|
139 |
assert: cvs exitValue = 0
|
|
140 |
message: 'cvs failed to finish properly. Check transcript'.
|
|
141 |
|
|
142 |
"Created: / 02-06-2009 / 17:19:42 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
143 |
"Modified: / 19-08-2009 / 11:47:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
144 |
!
|
|
145 |
|
|
146 |
doCopyFiles
|
|
147 |
| cvsFiles svnFilesSeen |
|
|
148 |
|
|
149 |
cvsFiles := cvsWc recursiveDirectoryContents
|
|
150 |
reject: [:e | e asFilename directoryName endsWith: 'CVS' ].
|
|
151 |
svnFilesSeen := Set new.
|
|
152 |
cvsFiles do:
|
|
153 |
[:cvsFileName |
|
|
154 |
| cvsFile svnFile svnFileCopy |
|
|
155 |
|
|
156 |
cvsFile := cvsWc construct: cvsFileName.
|
|
157 |
svnFile := workingCopy path / cvsFileName.
|
|
158 |
svnFileCopy := workingCopy path / (cvsFileName , '~').
|
|
159 |
svnFilesSeen add: svnFile.
|
|
160 |
svnFile exists
|
|
161 |
ifTrue:
|
|
162 |
[ (self is: cvsFile
|
|
163 |
sameAs: (svnFileCopy exists ifTrue: [ svnFileCopy ] ifFalse: [ svnFile ]))
|
|
164 |
ifFalse:
|
|
165 |
[ cvsFile copyTo: svnFile.
|
|
166 |
self notify: 'Updating ' , cvsFileName. ].
|
|
167 |
svnFileCopy exists ifTrue: [ self removeFiles: (Array with: svnFileCopy) ] ]
|
|
168 |
ifFalse:
|
|
169 |
[ newFiles add: svnFile.
|
|
170 |
cvsFile copyTo: svnFile.
|
|
171 |
self notify: 'Updating ' , cvsFileName. ]. ].
|
|
172 |
obsoleteFiles := (workingCopy path recursiveDirectoryContentsAsFilenames
|
|
173 |
reject: [:e | e directory baseName = '.svn' ]) \ svnFilesSeen.
|
|
174 |
|
|
175 |
"Created: / 02-06-2009 / 18:52:07 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
176 |
"Modified: / 19-08-2009 / 11:27:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
177 |
!
|
|
178 |
|
|
179 |
doSVNAddFiles
|
|
180 |
newFiles isEmpty ifTrue: [ ^ self ].
|
|
181 |
(AddCommand new)
|
|
182 |
workingCopy: workingCopy;
|
|
183 |
paths: (newFiles collect: [:e | e pathName ]);
|
|
184 |
execute.
|
|
185 |
|
|
186 |
"Created: / 28-05-2009 / 10:59:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
187 |
"Modified: / 19-08-2009 / 11:27:46 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
188 |
!
|
|
189 |
|
|
190 |
doSVNAddFiles: files
|
|
191 |
files isEmpty ifTrue: [ ^ self ].
|
|
192 |
(AddCommand new)
|
|
193 |
workingCopy: workingCopy;
|
|
194 |
paths: (files collect: [:e | e pathName ]);
|
|
195 |
execute.
|
|
196 |
|
|
197 |
"Created: / 02-06-2009 / 19:39:28 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
198 |
"Modified: / 19-08-2009 / 11:27:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
199 |
! !
|
|
200 |
|
|
201 |
!SyncWithCVSTask methodsFor:'initialization'!
|
|
202 |
|
|
203 |
initialize
|
|
204 |
|
|
205 |
super initialize.
|
|
206 |
branchPath := '/trunk'.
|
|
207 |
newFiles := Set new.
|
|
208 |
obsoleteFiles := Set new.
|
|
209 |
|
|
210 |
"Created: / 28-05-2009 / 09:08:32 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
211 |
"Modified: / 19-08-2009 / 12:29:57 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
212 |
! !
|
|
213 |
|
|
214 |
!SyncWithCVSTask methodsFor:'passes'!
|
|
215 |
|
|
216 |
pass56_RemoveFiles
|
|
217 |
|
|
218 |
"
|
|
219 |
svnFilesObsolete isEmpty ifTrue:[^self].
|
|
220 |
|
|
221 |
DeleteCommand new
|
|
222 |
workingCopy:svnWc pathName;
|
|
223 |
paths:(svnFilesObsolete collect:[:e|e pathName]);
|
|
224 |
execute.
|
|
225 |
"
|
|
226 |
|
|
227 |
"Created: / 28-05-2009 / 10:59:58 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
228 |
"Modified: / 28-05-2009 / 17:52:36 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
229 |
! !
|
|
230 |
|
|
231 |
!SyncWithCVSTask methodsFor:'private'!
|
|
232 |
|
|
233 |
is: fileA sameAs: fileB
|
|
234 |
|
|
235 |
^false"/(fileA suffix = 'st' and:[fileB suffix = 'st'])
|
|
236 |
ifTrue: [self isSource: fileA sameAs: fileB]
|
|
237 |
ifFalse:[self isContent: fileA sameAs: fileB]
|
|
238 |
|
|
239 |
"Created: / 28-05-2009 / 19:58:05 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
240 |
"Modified: / 02-06-2009 / 20:04:30 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
241 |
!
|
|
242 |
|
|
243 |
isContent: fileA sameAs: fileB
|
|
244 |
|
|
245 |
^(
|
|
246 |
(MD5Stream hashValueOfFile: fileA)
|
|
247 |
= (MD5Stream hashValueOfFile: fileB)
|
|
248 |
)
|
|
249 |
ifTrue:[true] ifFalse:["self halt."false]
|
|
250 |
|
|
251 |
"Created: / 28-05-2009 / 22:28:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
252 |
"Modified: / 03-06-2009 / 11:12:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
253 |
!
|
|
254 |
|
|
255 |
isSource: fileA sameAs: fileB
|
|
256 |
|
|
257 |
|rejectedVersionMethods changeSetA changeSetB diff |
|
|
258 |
|
|
259 |
rejectedVersionMethods := #( version version_CVS version_SVN ).
|
|
260 |
|
|
261 |
changeSetA := (ChangeSet fromFile: fileA) reject:
|
|
262 |
[:ch|ch isMethodChange
|
|
263 |
and:[ch isForMeta
|
|
264 |
and:[rejectedVersionMethods includes:ch changeSelector]]].
|
|
265 |
changeSetB := (ChangeSet fromFile: fileB) reject:
|
|
266 |
[:ch|ch isMethodChange
|
|
267 |
and:[ch isForMeta
|
|
268 |
and:[rejectedVersionMethods includes:ch changeSelector]]].
|
|
269 |
diff := changeSetA diffSetsAgainst: changeSetB.
|
|
270 |
^diff isEmpty
|
|
271 |
|
|
272 |
"Created: / 28-05-2009 / 22:27:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
273 |
"Modified: / 02-06-2009 / 20:22:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
274 |
!
|
|
275 |
|
|
276 |
removeFiles: files
|
|
277 |
|
|
278 |
files do:
|
|
279 |
[:file|(cvsWc construct: file) remove]
|
|
280 |
|
|
281 |
"Modified: / 02-06-2009 / 19:53:40 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
282 |
!
|
|
283 |
|
|
284 |
renameFile:file1 to:file2
|
|
285 |
|
|
286 |
file1 asFilename renameTo: file2 asString
|
|
287 |
|
|
288 |
"Modified: / 02-06-2009 / 19:36:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
289 |
!
|
|
290 |
|
|
291 |
svnBranchPath
|
|
292 |
|
|
293 |
^branchPath
|
|
294 |
|
|
295 |
"Created: / 19-08-2009 / 11:16:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
296 |
!
|
|
297 |
|
|
298 |
svnCommitMessage
|
|
299 |
|
|
300 |
^'Synchronized with CVS repository at:
|
|
301 |
', cvsRoot asString
|
|
302 |
|
|
303 |
"Created: / 28-05-2009 / 09:18:02 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
304 |
!
|
|
305 |
|
|
306 |
svnRepositoryUrl
|
|
307 |
|
|
308 |
^ (RepositoryManager repositoryUrlForPackage: package)
|
|
309 |
|
|
310 |
"Modified: / 19-08-2009 / 11:09:37 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
311 |
! !
|
|
312 |
|
|
313 |
!SyncWithCVSTask class methodsFor:'documentation'!
|
|
314 |
|
|
315 |
version
|
|
316 |
^ '$Header$'
|
158
|
317 |
!
|
|
318 |
|
|
319 |
version_CVS
|
|
320 |
^ '$Header$'
|
|
321 |
!
|
|
322 |
|
|
323 |
version_SVN
|
|
324 |
^'Id: SVN__SyncWithCVSTask.st 110 2009-08-19 13:21:10Z vranyj1 '
|
74
|
325 |
! !
|