637
|
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 |
Object subclass:#Configuration
|
|
31 |
instanceVariableNames:'name repositories'
|
|
32 |
classVariableNames:'Current Configurations'
|
|
33 |
poolDictionaries:''
|
|
34 |
category:'SVN-Configuration'
|
|
35 |
!
|
|
36 |
|
|
37 |
Object subclass:#Repository
|
|
38 |
instanceVariableNames:'package pattern url branch'
|
|
39 |
classVariableNames:''
|
|
40 |
poolDictionaries:''
|
|
41 |
privateIn:Configuration
|
|
42 |
!
|
|
43 |
|
|
44 |
!Configuration class methodsFor:'documentation'!
|
|
45 |
|
|
46 |
copyright
|
|
47 |
"
|
|
48 |
Copyright (c) 2007-2010 Jan Vrany
|
|
49 |
Copyright (c) 2009-2010 eXept Software AG
|
|
50 |
|
|
51 |
Permission is hereby granted, free of charge, to any person
|
|
52 |
obtaining a copy of this software and associated documentation
|
|
53 |
files (the 'Software'), to deal in the Software without
|
|
54 |
restriction, including without limitation the rights to use,
|
|
55 |
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
56 |
copies of the Software, and to permit persons to whom the
|
|
57 |
Software is furnished to do so, subject to the following
|
|
58 |
conditions:
|
|
59 |
|
|
60 |
The above copyright notice and this permission notice shall be
|
|
61 |
included in all copies or substantial portions of the Software.
|
|
62 |
|
|
63 |
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
64 |
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
65 |
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
66 |
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
67 |
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
68 |
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
69 |
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
70 |
OTHER DEALINGS IN THE SOFTWARE.
|
|
71 |
|
|
72 |
"
|
|
73 |
! !
|
|
74 |
|
|
75 |
!Configuration class methodsFor:'instance creation'!
|
|
76 |
|
|
77 |
named: aString
|
|
78 |
|
|
79 |
^self new name: aString.
|
|
80 |
"
|
|
81 |
self named: 'Default configuration'
|
|
82 |
"
|
|
83 |
|
|
84 |
"Created: / 09-01-2010 / 12:23:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
85 |
"Modified: / 11-02-2010 / 18:52:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
86 |
!
|
|
87 |
|
|
88 |
new
|
|
89 |
"return an initialized instance"
|
|
90 |
|
|
91 |
^ self basicNew initialize.
|
|
92 |
!
|
|
93 |
|
|
94 |
newRepository
|
|
95 |
|
|
96 |
^Repository new.
|
|
97 |
|
|
98 |
"Created: / 09-03-2010 / 18:34:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
99 |
! !
|
|
100 |
|
|
101 |
!Configuration class methodsFor:'accessing'!
|
|
102 |
|
|
103 |
configurations
|
|
104 |
|
|
105 |
Configurations ifNil:
|
|
106 |
[Configurations := UserPreferences current svnConfigurations2].
|
|
107 |
^Configurations
|
|
108 |
|
|
109 |
"Created: / 09-01-2010 / 15:46:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
110 |
"Modified: / 11-02-2010 / 18:55:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
111 |
!
|
|
112 |
|
|
113 |
configurations: aCollection"of Configuration"
|
|
114 |
|
|
115 |
UserPreferences current svnConfigurations2: aCollection
|
|
116 |
|
|
117 |
"Created: / 11-02-2010 / 16:17:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
118 |
!
|
|
119 |
|
|
120 |
current
|
|
121 |
|
|
122 |
Current ifNil:
|
|
123 |
[Current := UserPreferences current svnCurrentConfiguration].
|
|
124 |
^Current
|
|
125 |
|
|
126 |
"Created: / 09-01-2010 / 12:27:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
127 |
"Modified: / 11-02-2010 / 16:15:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
128 |
!
|
|
129 |
|
|
130 |
current: aConfiguration
|
|
131 |
|
|
132 |
UserPreferences current svnCurrentConfiguration: aConfiguration
|
|
133 |
|
|
134 |
"Created: / 10-03-2010 / 13:21:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
135 |
!
|
|
136 |
|
|
137 |
defaultName
|
|
138 |
|
|
139 |
^'Default configuration'
|
|
140 |
|
|
141 |
"Created: / 11-02-2010 / 18:55:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
142 |
!
|
|
143 |
|
|
144 |
variableValuesForPackage:pkg
|
|
145 |
|packageId packagePath|
|
|
146 |
|
|
147 |
packageId := pkg asPackageId.
|
|
148 |
packagePath := pkg asString copyReplaceAll:$: with:$/.
|
|
149 |
^ ((Dictionary new)
|
|
150 |
at:'MODULE' put:packageId module;
|
|
151 |
at:'DIRECTORY' put:packageId directory;
|
|
152 |
at:'PATH' put:packagePath;
|
|
153 |
at:'DOTTED_PATH' put:(packagePath copyReplaceAll:$/ with:$.);
|
|
154 |
"/for compatibility, will wanish
|
|
155 |
at:'p' put:packagePath;
|
|
156 |
"/ Bit hakish, but works :-)
|
|
157 |
at: 'BRANCH' put: '%(BRANCH)';
|
|
158 |
yourself)
|
|
159 |
|
|
160 |
"Created: / 09-03-2010 / 22:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
161 |
"Modified: / 13-03-2011 / 09:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
162 |
! !
|
|
163 |
|
|
164 |
!Configuration class methodsFor:'accessing - private'!
|
|
165 |
|
|
166 |
getConfigurations
|
|
167 |
|
|
168 |
^Configurations
|
|
169 |
|
|
170 |
"Created: / 10-03-2010 / 13:24:23 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
171 |
!
|
|
172 |
|
|
173 |
getCurrent
|
|
174 |
|
|
175 |
^Current
|
|
176 |
|
|
177 |
"Created: / 10-03-2010 / 13:23:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
178 |
!
|
|
179 |
|
|
180 |
setConfigurations: aCollection
|
|
181 |
|
|
182 |
Configurations := aCollection asOrderedCollection.
|
|
183 |
Current ifNotNil:
|
|
184 |
[Current := Configurations
|
|
185 |
detect:[:each|each name = Current name]
|
|
186 |
ifNone:[self error:'Current configuration is not in new configurations!!']].
|
|
187 |
|
|
188 |
"Created: / 09-01-2010 / 15:37:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
189 |
!
|
|
190 |
|
|
191 |
setCurrent: aConfiguration
|
|
192 |
|
|
193 |
Current := aConfiguration.
|
|
194 |
|
|
195 |
"Created: / 10-03-2010 / 13:20:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
196 |
! !
|
|
197 |
|
|
198 |
!Configuration class methodsFor:'utilities'!
|
|
199 |
|
|
200 |
flushCaches
|
|
201 |
|
|
202 |
Current := nil.
|
|
203 |
Configurations := nil.
|
|
204 |
|
|
205 |
"Created: / 11-02-2010 / 16:08:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
206 |
! !
|
|
207 |
|
|
208 |
!Configuration methodsFor:'accessing'!
|
|
209 |
|
|
210 |
name
|
|
211 |
^ name
|
|
212 |
!
|
|
213 |
|
|
214 |
name:aString
|
|
215 |
name := aString.
|
|
216 |
!
|
|
217 |
|
|
218 |
package: package url: url
|
|
219 |
|
|
220 |
^repositories add:
|
|
221 |
(Configuration::Repository
|
|
222 |
package: package
|
|
223 |
url: url).
|
|
224 |
|
|
225 |
"Created: / 11-03-2011 / 18:06:56 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
226 |
!
|
|
227 |
|
|
228 |
repositories
|
|
229 |
^ repositories
|
|
230 |
!
|
|
231 |
|
|
232 |
repositories:aCollection
|
|
233 |
repositories := aCollection.
|
|
234 |
!
|
|
235 |
|
|
236 |
repositoryFor: packageId
|
|
237 |
|
|
238 |
repositories do:
|
|
239 |
[:repoConf|
|
|
240 |
(repoConf matches: packageId)
|
|
241 |
ifTrue:[^repoConf repositoryFor: packageId]].
|
|
242 |
"Nothing found"
|
|
243 |
^nil
|
|
244 |
|
|
245 |
"Created: / 09-01-2010 / 12:05:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
246 |
! !
|
|
247 |
|
|
248 |
!Configuration methodsFor:'comparing'!
|
|
249 |
|
|
250 |
= anotherConfig
|
|
251 |
|
|
252 |
self class = anotherConfig class ifFalse:[^false].
|
|
253 |
self name = anotherConfig name ifFalse:[^false].
|
|
254 |
self repositories asArray = anotherConfig repositories asArray ifFalse:[^false].
|
|
255 |
^true
|
|
256 |
|
|
257 |
"Created: / 10-03-2010 / 13:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
258 |
"Modified: / 14-03-2011 / 11:26:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
259 |
!
|
|
260 |
|
|
261 |
hash
|
|
262 |
|
|
263 |
^name hash
|
|
264 |
|
|
265 |
"Created: / 10-03-2010 / 13:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
266 |
! !
|
|
267 |
|
|
268 |
!Configuration methodsFor:'displaying'!
|
|
269 |
|
|
270 |
displayString
|
|
271 |
|
|
272 |
^name
|
|
273 |
|
|
274 |
"Created: / 11-02-2010 / 19:13:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
275 |
! !
|
|
276 |
|
|
277 |
!Configuration methodsFor:'initialization'!
|
|
278 |
|
|
279 |
initialize
|
|
280 |
"Invoked when a new instance is created."
|
|
281 |
|
|
282 |
name := '<unnamed>'.
|
|
283 |
repositories := List new
|
|
284 |
|
|
285 |
"/ super initialize. -- commented since inherited method does nothing
|
|
286 |
|
|
287 |
"Modified: / 30-04-2011 / 23:17:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
288 |
"Modified: / 30-04-2011 / 23:17:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
289 |
! !
|
|
290 |
|
|
291 |
!Configuration methodsFor:'printing & storing'!
|
|
292 |
|
|
293 |
printOn:aStream
|
|
294 |
"append a printed representation if the receiver to the argument, aStream"
|
|
295 |
|
|
296 |
super printOn:aStream.
|
|
297 |
aStream nextPut:$(.
|
|
298 |
name printOn:aStream.
|
|
299 |
aStream nextPut:$).
|
|
300 |
|
|
301 |
"Modified: / 09-01-2010 / 12:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
302 |
! !
|
|
303 |
|
|
304 |
!Configuration::Repository class methodsFor:'instance creation'!
|
|
305 |
|
|
306 |
package: package url: url
|
|
307 |
|
|
308 |
^self new
|
|
309 |
package: package;
|
|
310 |
url: url;
|
|
311 |
yourself
|
|
312 |
|
|
313 |
"Created: / 09-01-2010 / 12:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
314 |
!
|
|
315 |
|
|
316 |
package: package url: url branch: branch
|
|
317 |
|
|
318 |
^self new
|
|
319 |
package: package;
|
|
320 |
url: url;
|
|
321 |
branch: branch;
|
|
322 |
yourself
|
|
323 |
|
|
324 |
"Created: / 09-01-2010 / 14:59:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
325 |
! !
|
|
326 |
|
|
327 |
!Configuration::Repository methodsFor:'accessing'!
|
|
328 |
|
|
329 |
branch
|
|
330 |
^ branch
|
|
331 |
!
|
|
332 |
|
|
333 |
branch:aString
|
|
334 |
branch := aString.
|
|
335 |
!
|
|
336 |
|
|
337 |
package
|
|
338 |
^ package
|
|
339 |
!
|
|
340 |
|
|
341 |
package:aString
|
|
342 |
package := aString.
|
|
343 |
pattern := PackagePattern for: aString
|
|
344 |
|
|
345 |
"Modified: / 13-03-2011 / 08:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
346 |
!
|
|
347 |
|
|
348 |
repositoryFor: packageId
|
|
349 |
|
|
350 |
^(Repository
|
|
351 |
package: packageId asSymbol
|
|
352 |
url: (self urlFor: packageId))
|
|
353 |
preferredBranch: branch
|
|
354 |
|
|
355 |
"Created: / 09-01-2010 / 12:20:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
356 |
"Modified: / 10-03-2010 / 18:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
357 |
!
|
|
358 |
|
|
359 |
url
|
|
360 |
^ url
|
|
361 |
!
|
|
362 |
|
|
363 |
url:aString
|
|
364 |
url := aString.
|
|
365 |
!
|
|
366 |
|
|
367 |
urlFor:pkg
|
|
368 |
|
|
369 |
| placeholders repoUrl |
|
|
370 |
placeholders := Configuration variableValuesForPackage:pkg.
|
|
371 |
pattern match: pkg into: placeholders.
|
|
372 |
repoUrl := url asString expandPlaceholdersWith: placeholders.
|
|
373 |
(repoUrl includesSubString: '%(BRANCH)') ifFalse:[
|
|
374 |
repoUrl := repoUrl , '/%(BRANCH)'.
|
|
375 |
].
|
|
376 |
^repoUrl
|
|
377 |
|
|
378 |
"Created: / 09-01-2010 / 11:33:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
379 |
"Modified: / 14-03-2011 / 09:38:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
380 |
! !
|
|
381 |
|
|
382 |
!Configuration::Repository methodsFor:'comparing'!
|
|
383 |
|
|
384 |
= anotherConf
|
|
385 |
|
|
386 |
^self class == anotherConf class
|
|
387 |
and:[package = anotherConf package
|
|
388 |
and:[url = anotherConf url
|
|
389 |
and:[branch = anotherConf branch]]].
|
|
390 |
|
|
391 |
"Created: / 09-01-2010 / 11:20:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
392 |
"Modified: / 06-05-2011 / 21:13:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
393 |
!
|
|
394 |
|
|
395 |
hash
|
|
396 |
|
|
397 |
^package hash bitXor: url hash
|
|
398 |
|
|
399 |
"Created: / 09-01-2010 / 11:21:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
400 |
! !
|
|
401 |
|
|
402 |
!Configuration::Repository methodsFor:'encoding & decoding'!
|
|
403 |
|
|
404 |
skippedInLiteralEncoding
|
|
405 |
"return a Collection with it's elements are slots for skipping"
|
|
406 |
|
|
407 |
^ #(pattern)
|
|
408 |
|
|
409 |
"Created: / 14-03-2011 / 09:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
410 |
! !
|
|
411 |
|
|
412 |
!Configuration::Repository methodsFor:'queries'!
|
|
413 |
|
|
414 |
matches: packageId
|
|
415 |
|
|
416 |
packageId ifNil:[^false].
|
|
417 |
|
|
418 |
^pattern matches: packageId
|
|
419 |
|
|
420 |
"Created: / 09-01-2010 / 11:29:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
421 |
"Modified: / 13-03-2011 / 08:58:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
|
|
422 |
! !
|
|
423 |
|
|
424 |
!Configuration class methodsFor:'documentation'!
|
|
425 |
|
733
|
426 |
version
|
|
427 |
^ '$Header$'
|
|
428 |
!
|
|
429 |
|
|
430 |
version_CVS
|
|
431 |
^ '$Header$'
|
|
432 |
!
|
|
433 |
|
637
|
434 |
version_SVN
|
733
|
435 |
^ '§Id: SVN__Configuration.st 350 2011-07-07 18:42:56Z vranyj1 §'
|
637
|
436 |
! !
|