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