author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 24 Jan 2012 10:52:24 +0100 | |
changeset 556 | f9aca2ebc86f |
parent 552 | c0ecaa34cc64 |
child 561 | 0f55a0dccf06 |
permissions | -rw-r--r-- |
79 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
3 |
Object subclass:#MCRepositoryGroup |
|
4 |
instanceVariableNames:'repositories' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'Monticello-Versioning' |
|
8 |
! |
|
9 |
||
10 |
MCRepositoryGroup class instanceVariableNames:'default' |
|
11 |
||
12 |
" |
|
13 |
No other class instance variables are inherited by this class. |
|
14 |
" |
|
15 |
! |
|
16 |
||
17 |
MCRepositoryGroup comment:'A singleton class, holds the list of repositories. Can look for a requested VersionInfo among its repositories.' |
|
18 |
! |
|
19 |
||
20 |
||
21 |
!MCRepositoryGroup class methodsFor:'as yet unclassified'! |
|
22 |
||
23 |
default |
|
24 |
^ default ifNil: [default _ self new] |
|
25 |
! |
|
26 |
||
27 |
new |
|
28 |
^ self basicNew initialize |
|
29 |
! ! |
|
30 |
||
31 |
!MCRepositoryGroup methodsFor:'as yet unclassified'! |
|
32 |
||
33 |
addRepository: aRepository |
|
541 | 34 |
((repositories includes: aRepository) or: [aRepository == MCCacheRepository default]) |
552 | 35 |
ifFalse: [ |
36 |
repositories add: aRepository. |
|
37 |
self class default addRepository: aRepository. |
|
38 |
self changed: #repositories |
|
541 | 39 |
]. |
40 |
||
41 |
"Modified: / 04-12-2011 / 09:04:24 / cg" |
|
42 |
! |
|
43 |
||
44 |
flushRepositories |
|
45 |
"/ cg: mhmh - what should we do here ? |
|
556
f9aca2ebc86f
comment/format in: #flushRepositories
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
552
diff
changeset
|
46 |
"/ called by UserPreferences >> mcRepositories: |
541 | 47 |
|
48 |
self initializeRepositoriesFromUserSettings |
|
49 |
||
50 |
"Created: / 01-12-2011 / 20:35:13 / cg" |
|
556
f9aca2ebc86f
comment/format in: #flushRepositories
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
552
diff
changeset
|
51 |
"Modified (comment): / 24-01-2012 / 09:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
79 | 52 |
! |
53 |
||
54 |
includes: aRepository |
|
55 |
^ self repositories includes: aRepository |
|
56 |
! |
|
57 |
||
58 |
includesVersionNamed: aString |
|
59 |
self repositoriesDo: [:ea | (ea includesVersionNamed: aString) ifTrue: [^ true]]. |
|
552 | 60 |
^ false |
79 | 61 |
! |
62 |
||
63 |
initialize |
|
541 | 64 |
"/ repositories _ OrderedCollection new |
65 |
self initializeRepositoriesFromUserSettings |
|
66 |
||
67 |
"Modified: / 04-12-2011 / 09:07:23 / cg" |
|
68 |
! |
|
69 |
||
70 |
initializeRepositoriesFromUserSettings |
|
71 |
|litArray reps| |
|
72 |
||
73 |
litArray := UserPreferences current at: #mcRepositories ifAbsent:#(). |
|
74 |
reps := litArray decodeAsLiteralArray. |
|
75 |
repositories := OrderedCollection withAll:reps. |
|
76 |
||
77 |
"Created: / 04-12-2011 / 09:06:53 / cg" |
|
79 | 78 |
! |
79 |
||
80 |
removeRepository: aRepository |
|
81 |
repositories remove: aRepository ifAbsent: []. |
|
82 |
self changed: #repositories |
|
83 |
! |
|
84 |
||
85 |
repositories |
|
541 | 86 |
^ ((OrderedCollection withAll:repositories) |
552 | 87 |
addFirst:(MCCacheRepository default); |
88 |
yourself) |
|
89 |
select: [ :ea | ea isValid ] |
|
541 | 90 |
|
91 |
"Modified: / 04-12-2011 / 09:04:42 / cg" |
|
79 | 92 |
! |
93 |
||
94 |
repositoriesDo: aBlock |
|
95 |
self repositories do: [:ea | [aBlock value: ea] on: Error do: []] |
|
541 | 96 |
! ! |
97 |
||
98 |
!MCRepositoryGroup methodsFor:'searching'! |
|
79 | 99 |
|
100 |
versionWithInfo: aVersionInfo |
|
101 |
^self versionWithInfo: aVersionInfo ifNone: [ self error: 'Could not find version ', aVersionInfo name printString,'. Maybe you need to add a repository?' ] |
|
102 |
! |
|
103 |
||
104 |
versionWithInfo: aVersionInfo ifNone: aBlock |
|
105 |
self repositoriesDo: [:ea | (ea versionWithInfo: aVersionInfo) ifNotNilDo: [:v | ^ v]]. |
|
106 |
^aBlock value |
|
107 |
! ! |
|
108 |
||
109 |
!MCRepositoryGroup class methodsFor:'documentation'! |
|
110 |
||
111 |
version |
|
556
f9aca2ebc86f
comment/format in: #flushRepositories
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
552
diff
changeset
|
112 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCRepositoryGroup.st,v 1.5 2012-01-24 09:52:24 vrany Exp $' |
79 | 113 |
! ! |