author | convert-repo |
Tue, 09 Aug 2016 03:35:19 +0000 | |
changeset 1012 | 6c2b1a2886d5 |
parent 783 | b4b44454973b |
child 1042 | 3b8c88c55251 |
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 |
|
783 | 95 |
^ ((OrderedSet with:MCCacheRepository default) |
96 |
addAll:repositories; |
|
97 |
yourself) |
|
98 |
asOrderedCollection |
|
99 |
select: [ :ea | ea isValid ] |
|
541 | 100 |
|
101 |
"Modified: / 04-12-2011 / 09:04:42 / cg" |
|
79 | 102 |
! |
103 |
||
561 | 104 |
repositories: anOrderedCollection |
105 |
||
106 |
repositories := anOrderedCollection copy. |
|
107 |
"Ensure, that repositories contain cache as first" |
|
108 |
repositories remove: MCCacheRepository default ifAbsent:[]. |
|
109 |
repositories addFirst: MCCacheRepository default. |
|
110 |
self == self class default ifTrue:[ |
|
111 |
UserPreferences current mcRepositories: repositories asArray literalArrayEncoding |
|
112 |
]. |
|
113 |
||
114 |
"Created: / 04-04-2012 / 11:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
115 |
! |
|
116 |
||
79 | 117 |
repositoriesDo: aBlock |
118 |
self repositories do: [:ea | [aBlock value: ea] on: Error do: []] |
|
541 | 119 |
! ! |
120 |
||
121 |
!MCRepositoryGroup methodsFor:'searching'! |
|
79 | 122 |
|
123 |
versionWithInfo: aVersionInfo |
|
124 |
^self versionWithInfo: aVersionInfo ifNone: [ self error: 'Could not find version ', aVersionInfo name printString,'. Maybe you need to add a repository?' ] |
|
125 |
! |
|
126 |
||
127 |
versionWithInfo: aVersionInfo ifNone: aBlock |
|
128 |
self repositoriesDo: [:ea | (ea versionWithInfo: aVersionInfo) ifNotNilDo: [:v | ^ v]]. |
|
129 |
^aBlock value |
|
130 |
! ! |
|
131 |
||
132 |
!MCRepositoryGroup class methodsFor:'documentation'! |
|
133 |
||
134 |
version |
|
783 | 135 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCRepositoryGroup.st,v 1.9 2013-04-18 23:51:57 cg Exp $' |
79 | 136 |
! ! |
783 | 137 |