author | Claus Gittinger <cg@exept.de> |
Tue, 11 Sep 2012 23:14:01 +0200 | |
changeset 590 | af671bba9a44 |
parent 566 | 2cdc9be3bc68 |
child 783 | b4b44454973b |
permissions | -rw-r--r-- |
79 | 1 |
"{ Package: 'stx:goodies/monticello' }" |
2 |
||
3 |
Object subclass:#MCRepositoryGroup |
|
4 |
instanceVariableNames:'repositories' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
590 | 7 |
category:'SCM-Monticello-Versioning' |
79 | 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 |
|
561 | 24 |
default isNil ifTrue: [default := self new]. |
25 |
^default |
|
26 |
||
27 |
"Modified: / 04-04-2012 / 11:04:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
79 | 28 |
! |
29 |
||
30 |
new |
|
31 |
^ self basicNew initialize |
|
32 |
! ! |
|
33 |
||
34 |
!MCRepositoryGroup methodsFor:'as yet unclassified'! |
|
35 |
||
36 |
addRepository: aRepository |
|
541 | 37 |
((repositories includes: aRepository) or: [aRepository == MCCacheRepository default]) |
552 | 38 |
ifFalse: [ |
39 |
repositories add: aRepository. |
|
40 |
self class default addRepository: aRepository. |
|
41 |
self changed: #repositories |
|
541 | 42 |
]. |
43 |
||
44 |
"Modified: / 04-12-2011 / 09:04:24 / cg" |
|
45 |
! |
|
46 |
||
47 |
flushRepositories |
|
48 |
"/ cg: mhmh - what should we do here ? |
|
556
f9aca2ebc86f
comment/format in: #flushRepositories
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
552
diff
changeset
|
49 |
"/ called by UserPreferences >> mcRepositories: |
541 | 50 |
|
51 |
self initializeRepositoriesFromUserSettings |
|
52 |
||
53 |
"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
|
54 |
"Modified (comment): / 24-01-2012 / 09:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
79 | 55 |
! |
56 |
||
57 |
includes: aRepository |
|
58 |
^ self repositories includes: aRepository |
|
59 |
! |
|
60 |
||
61 |
includesVersionNamed: aString |
|
62 |
self repositoriesDo: [:ea | (ea includesVersionNamed: aString) ifTrue: [^ true]]. |
|
552 | 63 |
^ false |
79 | 64 |
! |
65 |
||
66 |
initialize |
|
541 | 67 |
"/ repositories _ OrderedCollection new |
68 |
self initializeRepositoriesFromUserSettings |
|
69 |
||
70 |
"Modified: / 04-12-2011 / 09:07:23 / cg" |
|
71 |
! |
|
72 |
||
73 |
initializeRepositoriesFromUserSettings |
|
74 |
|litArray reps| |
|
75 |
||
561 | 76 |
litArray := UserPreferences current mcRepositories. |
566
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
77 |
litArray == false ifTrue:[ |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
78 |
"there is no entry in the UserPreferneces, so false - the default value - is returned" |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
79 |
reps := #(). |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
80 |
] ifFalse:[ |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
81 |
reps := litArray decodeAsLiteralArray. |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
82 |
]. |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
83 |
repositories := reps asOrderedCollection. |
541 | 84 |
|
85 |
"Created: / 04-12-2011 / 09:06:53 / cg" |
|
561 | 86 |
"Modified: / 04-04-2012 / 11:08:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
79 | 87 |
! |
88 |
||
89 |
removeRepository: aRepository |
|
90 |
repositories remove: aRepository ifAbsent: []. |
|
91 |
self changed: #repositories |
|
92 |
! |
|
93 |
||
94 |
repositories |
|
541 | 95 |
^ ((OrderedCollection withAll:repositories) |
552 | 96 |
addFirst:(MCCacheRepository default); |
97 |
yourself) |
|
98 |
select: [ :ea | ea isValid ] |
|
541 | 99 |
|
100 |
"Modified: / 04-12-2011 / 09:04:42 / cg" |
|
79 | 101 |
! |
102 |
||
561 | 103 |
repositories: anOrderedCollection |
104 |
||
105 |
repositories := anOrderedCollection copy. |
|
106 |
"Ensure, that repositories contain cache as first" |
|
107 |
repositories remove: MCCacheRepository default ifAbsent:[]. |
|
108 |
repositories addFirst: MCCacheRepository default. |
|
109 |
self == self class default ifTrue:[ |
|
110 |
UserPreferences current mcRepositories: repositories asArray literalArrayEncoding |
|
111 |
]. |
|
112 |
||
113 |
"Created: / 04-04-2012 / 11:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
114 |
! |
|
115 |
||
79 | 116 |
repositoriesDo: aBlock |
117 |
self repositories do: [:ea | [aBlock value: ea] on: Error do: []] |
|
541 | 118 |
! ! |
119 |
||
120 |
!MCRepositoryGroup methodsFor:'searching'! |
|
79 | 121 |
|
122 |
versionWithInfo: aVersionInfo |
|
123 |
^self versionWithInfo: aVersionInfo ifNone: [ self error: 'Could not find version ', aVersionInfo name printString,'. Maybe you need to add a repository?' ] |
|
124 |
! |
|
125 |
||
126 |
versionWithInfo: aVersionInfo ifNone: aBlock |
|
127 |
self repositoriesDo: [:ea | (ea versionWithInfo: aVersionInfo) ifNotNilDo: [:v | ^ v]]. |
|
128 |
^aBlock value |
|
129 |
! ! |
|
130 |
||
131 |
!MCRepositoryGroup class methodsFor:'documentation'! |
|
132 |
||
133 |
version |
|
590 | 134 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCRepositoryGroup.st,v 1.8 2012-09-11 21:14:01 cg Exp $' |
79 | 135 |
! ! |