author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 01 Oct 2011 13:17:26 +0200 | |
changeset 857 | 8e9d19f07197 |
parent 792 | 6e8464f6c4c1 |
child 920 | 26b894d9cc79 |
permissions | -rw-r--r-- |
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 |
|
857
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
31 |
instanceVariableNames:'name repositories' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
32 |
classVariableNames:'Current Configurations' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
33 |
poolDictionaries:'' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
34 |
category:'SVN-Configuration' |
637 | 35 |
! |
36 |
||
37 |
Object subclass:#Repository |
|
857
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
38 |
instanceVariableNames:'package pattern url branch' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
39 |
classVariableNames:'' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
40 |
poolDictionaries:'' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
41 |
privateIn:Configuration |
637 | 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 |
||
792 | 122 |
Current ifNil:[ |
123 |
"/ cg: seems to be called BEFORE that method is there (sometimes?) |
|
124 |
(UserPreferences implements:#svnCurrentConfiguration) ifTrue:[ |
|
125 |
Current := UserPreferences current svnCurrentConfiguration. |
|
126 |
] |
|
127 |
]. |
|
637 | 128 |
^Current |
129 |
||
130 |
"Created: / 09-01-2010 / 12:27:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
131 |
"Modified: / 11-02-2010 / 16:15:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
792 | 132 |
"Modified (format): / 23-08-2011 / 18:29:02 / cg" |
637 | 133 |
! |
134 |
||
135 |
current: aConfiguration |
|
136 |
||
137 |
UserPreferences current svnCurrentConfiguration: aConfiguration |
|
138 |
||
139 |
"Created: / 10-03-2010 / 13:21:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
140 |
! |
|
141 |
||
142 |
defaultName |
|
143 |
||
144 |
^'Default configuration' |
|
145 |
||
146 |
"Created: / 11-02-2010 / 18:55:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
variableValuesForPackage:pkg |
|
150 |
|packageId packagePath| |
|
151 |
||
152 |
packageId := pkg asPackageId. |
|
153 |
packagePath := pkg asString copyReplaceAll:$: with:$/. |
|
154 |
^ ((Dictionary new) |
|
155 |
at:'MODULE' put:packageId module; |
|
156 |
at:'DIRECTORY' put:packageId directory; |
|
157 |
at:'PATH' put:packagePath; |
|
158 |
at:'DOTTED_PATH' put:(packagePath copyReplaceAll:$/ with:$.); |
|
159 |
"/for compatibility, will wanish |
|
160 |
at:'p' put:packagePath; |
|
161 |
"/ Bit hakish, but works :-) |
|
162 |
at: 'BRANCH' put: '%(BRANCH)'; |
|
163 |
yourself) |
|
164 |
||
165 |
"Created: / 09-03-2010 / 22:34:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
166 |
"Modified: / 13-03-2011 / 09:16:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
167 |
! ! |
|
168 |
||
169 |
!Configuration class methodsFor:'accessing - private'! |
|
170 |
||
171 |
getConfigurations |
|
172 |
||
173 |
^Configurations |
|
174 |
||
175 |
"Created: / 10-03-2010 / 13:24:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
176 |
! |
|
177 |
||
178 |
getCurrent |
|
179 |
||
180 |
^Current |
|
181 |
||
182 |
"Created: / 10-03-2010 / 13:23:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
183 |
! |
|
184 |
||
185 |
setConfigurations: aCollection |
|
186 |
||
187 |
Configurations := aCollection asOrderedCollection. |
|
188 |
Current ifNotNil: |
|
189 |
[Current := Configurations |
|
190 |
detect:[:each|each name = Current name] |
|
191 |
ifNone:[self error:'Current configuration is not in new configurations!!']]. |
|
192 |
||
193 |
"Created: / 09-01-2010 / 15:37:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
194 |
! |
|
195 |
||
196 |
setCurrent: aConfiguration |
|
197 |
||
198 |
Current := aConfiguration. |
|
199 |
||
200 |
"Created: / 10-03-2010 / 13:20:19 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
201 |
! ! |
|
202 |
||
857
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
203 |
!Configuration class methodsFor:'others'! |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
204 |
|
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
205 |
version_CVS |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
206 |
^ '$Header$' |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
207 |
! ! |
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
208 |
|
637 | 209 |
!Configuration class methodsFor:'utilities'! |
210 |
||
211 |
flushCaches |
|
212 |
||
213 |
Current := nil. |
|
214 |
Configurations := nil. |
|
215 |
||
216 |
"Created: / 11-02-2010 / 16:08:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
217 |
! ! |
|
218 |
||
219 |
!Configuration methodsFor:'accessing'! |
|
220 |
||
221 |
name |
|
222 |
^ name |
|
223 |
! |
|
224 |
||
225 |
name:aString |
|
226 |
name := aString. |
|
227 |
! |
|
228 |
||
229 |
package: package url: url |
|
230 |
||
231 |
^repositories add: |
|
232 |
(Configuration::Repository |
|
233 |
package: package |
|
234 |
url: url). |
|
235 |
||
236 |
"Created: / 11-03-2011 / 18:06:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
237 |
! |
|
238 |
||
239 |
repositories |
|
240 |
^ repositories |
|
241 |
! |
|
242 |
||
243 |
repositories:aCollection |
|
244 |
repositories := aCollection. |
|
245 |
! |
|
246 |
||
247 |
repositoryFor: packageId |
|
248 |
||
249 |
repositories do: |
|
250 |
[:repoConf| |
|
251 |
(repoConf matches: packageId) |
|
252 |
ifTrue:[^repoConf repositoryFor: packageId]]. |
|
253 |
"Nothing found" |
|
254 |
^nil |
|
255 |
||
256 |
"Created: / 09-01-2010 / 12:05:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
257 |
! ! |
|
258 |
||
259 |
!Configuration methodsFor:'comparing'! |
|
260 |
||
261 |
= anotherConfig |
|
262 |
||
263 |
self class = anotherConfig class ifFalse:[^false]. |
|
264 |
self name = anotherConfig name ifFalse:[^false]. |
|
265 |
self repositories asArray = anotherConfig repositories asArray ifFalse:[^false]. |
|
266 |
^true |
|
267 |
||
268 |
"Created: / 10-03-2010 / 13:35:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
269 |
"Modified: / 14-03-2011 / 11:26:20 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
270 |
! |
|
271 |
||
272 |
hash |
|
273 |
||
274 |
^name hash |
|
275 |
||
276 |
"Created: / 10-03-2010 / 13:34:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
277 |
! ! |
|
278 |
||
279 |
!Configuration methodsFor:'displaying'! |
|
280 |
||
281 |
displayString |
|
282 |
||
283 |
^name |
|
284 |
||
285 |
"Created: / 11-02-2010 / 19:13:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
286 |
! ! |
|
287 |
||
288 |
!Configuration methodsFor:'initialization'! |
|
289 |
||
290 |
initialize |
|
291 |
"Invoked when a new instance is created." |
|
292 |
||
293 |
name := '<unnamed>'. |
|
294 |
repositories := List new |
|
295 |
||
296 |
"/ super initialize. -- commented since inherited method does nothing |
|
297 |
||
298 |
"Modified: / 30-04-2011 / 23:17:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
299 |
"Modified: / 30-04-2011 / 23:17:42 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
300 |
! ! |
|
301 |
||
302 |
!Configuration methodsFor:'printing & storing'! |
|
303 |
||
304 |
printOn:aStream |
|
305 |
"append a printed representation if the receiver to the argument, aStream" |
|
306 |
||
307 |
super printOn:aStream. |
|
308 |
aStream nextPut:$(. |
|
309 |
name printOn:aStream. |
|
310 |
aStream nextPut:$). |
|
311 |
||
312 |
"Modified: / 09-01-2010 / 12:29:57 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
313 |
! ! |
|
314 |
||
315 |
!Configuration::Repository class methodsFor:'instance creation'! |
|
316 |
||
317 |
package: package url: url |
|
318 |
||
319 |
^self new |
|
320 |
package: package; |
|
321 |
url: url; |
|
322 |
yourself |
|
323 |
||
324 |
"Created: / 09-01-2010 / 12:49:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
325 |
! |
|
326 |
||
327 |
package: package url: url branch: branch |
|
328 |
||
329 |
^self new |
|
330 |
package: package; |
|
331 |
url: url; |
|
332 |
branch: branch; |
|
333 |
yourself |
|
334 |
||
335 |
"Created: / 09-01-2010 / 14:59:13 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
336 |
! ! |
|
337 |
||
338 |
!Configuration::Repository methodsFor:'accessing'! |
|
339 |
||
340 |
branch |
|
341 |
^ branch |
|
342 |
! |
|
343 |
||
344 |
branch:aString |
|
345 |
branch := aString. |
|
346 |
! |
|
347 |
||
348 |
package |
|
349 |
^ package |
|
350 |
! |
|
351 |
||
352 |
package:aString |
|
353 |
package := aString. |
|
354 |
pattern := PackagePattern for: aString |
|
355 |
||
356 |
"Modified: / 13-03-2011 / 08:55:34 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
357 |
! |
|
358 |
||
359 |
repositoryFor: packageId |
|
360 |
||
361 |
^(Repository |
|
362 |
package: packageId asSymbol |
|
363 |
url: (self urlFor: packageId)) |
|
364 |
preferredBranch: branch |
|
365 |
||
366 |
"Created: / 09-01-2010 / 12:20:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
367 |
"Modified: / 10-03-2010 / 18:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
368 |
! |
|
369 |
||
370 |
url |
|
371 |
^ url |
|
372 |
! |
|
373 |
||
374 |
url:aString |
|
375 |
url := aString. |
|
376 |
! |
|
377 |
||
378 |
urlFor:pkg |
|
379 |
||
380 |
| placeholders repoUrl | |
|
381 |
placeholders := Configuration variableValuesForPackage:pkg. |
|
382 |
pattern match: pkg into: placeholders. |
|
383 |
repoUrl := url asString expandPlaceholdersWith: placeholders. |
|
384 |
(repoUrl includesSubString: '%(BRANCH)') ifFalse:[ |
|
385 |
repoUrl := repoUrl , '/%(BRANCH)'. |
|
386 |
]. |
|
387 |
^repoUrl |
|
388 |
||
389 |
"Created: / 09-01-2010 / 11:33:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
390 |
"Modified: / 14-03-2011 / 09:38:59 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
391 |
! ! |
|
392 |
||
393 |
!Configuration::Repository methodsFor:'comparing'! |
|
394 |
||
395 |
= anotherConf |
|
396 |
||
397 |
^self class == anotherConf class |
|
398 |
and:[package = anotherConf package |
|
399 |
and:[url = anotherConf url |
|
400 |
and:[branch = anotherConf branch]]]. |
|
401 |
||
402 |
"Created: / 09-01-2010 / 11:20:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
403 |
"Modified: / 06-05-2011 / 21:13:12 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
404 |
! |
|
405 |
||
406 |
hash |
|
407 |
||
408 |
^package hash bitXor: url hash |
|
409 |
||
410 |
"Created: / 09-01-2010 / 11:21:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
411 |
! ! |
|
412 |
||
413 |
!Configuration::Repository methodsFor:'encoding & decoding'! |
|
414 |
||
415 |
skippedInLiteralEncoding |
|
416 |
"return a Collection with it's elements are slots for skipping" |
|
417 |
||
418 |
^ #(pattern) |
|
419 |
||
420 |
"Created: / 14-03-2011 / 09:30:33 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
421 |
! ! |
|
422 |
||
423 |
!Configuration::Repository methodsFor:'queries'! |
|
424 |
||
425 |
matches: packageId |
|
426 |
||
427 |
packageId ifNil:[^false]. |
|
428 |
||
429 |
^pattern matches: packageId |
|
430 |
||
431 |
"Created: / 09-01-2010 / 11:29:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
432 |
"Modified: / 13-03-2011 / 08:58:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
433 |
! ! |
|
434 |
||
435 |
!Configuration class methodsFor:'documentation'! |
|
436 |
||
733 | 437 |
version |
438 |
^ '$Header$' |
|
439 |
! |
|
440 |
||
441 |
version_CVS |
|
442 |
^ '$Header$' |
|
857
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
443 |
|
733 | 444 |
! |
445 |
||
637 | 446 |
version_SVN |
857
8e9d19f07197
checkin to get version methods correct
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
792
diff
changeset
|
447 |
^ '§Id: SVN__Configuration.st 363 2011-08-08 13:49:48Z vranyj1 §' |
637 | 448 |
! ! |