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])
|
|
35 |
ifFalse: [
|
|
36 |
repositories add: aRepository.
|
|
37 |
self class default addRepository: aRepository.
|
|
38 |
self changed: #repositories
|
|
39 |
].
|
|
40 |
|
|
41 |
"Modified: / 04-12-2011 / 09:04:24 / cg"
|
|
42 |
!
|
|
43 |
|
|
44 |
flushRepositories
|
|
45 |
"/ cg: mhmh - what should we do here ?
|
|
46 |
"/ called by UserPreferences >> mvRepositories:
|
|
47 |
|
|
48 |
self initializeRepositoriesFromUserSettings
|
|
49 |
|
|
50 |
"Created: / 01-12-2011 / 20:35:13 / cg"
|
79
|
51 |
!
|
|
52 |
|
525
|
53 |
flushRepositories
|
|
54 |
"/ cg: mhmh - what should we do here ?
|
|
55 |
"/ called by UserPreferences >> mvRepositories:
|
|
56 |
|
|
57 |
"Created: / 01-12-2011 / 20:35:13 / cg"
|
|
58 |
!
|
|
59 |
|
79
|
60 |
includes: aRepository
|
|
61 |
^ self repositories includes: aRepository
|
|
62 |
!
|
|
63 |
|
|
64 |
includesVersionNamed: aString
|
|
65 |
self repositoriesDo: [:ea | (ea includesVersionNamed: aString) ifTrue: [^ true]].
|
|
66 |
^ false
|
|
67 |
!
|
|
68 |
|
|
69 |
initialize
|
541
|
70 |
"/ repositories _ OrderedCollection new
|
|
71 |
self initializeRepositoriesFromUserSettings
|
|
72 |
|
|
73 |
"Modified: / 04-12-2011 / 09:07:23 / cg"
|
|
74 |
!
|
|
75 |
|
|
76 |
initializeRepositoriesFromUserSettings
|
|
77 |
|litArray reps|
|
|
78 |
|
|
79 |
litArray := UserPreferences current at: #mcRepositories ifAbsent:#().
|
|
80 |
reps := litArray decodeAsLiteralArray.
|
|
81 |
repositories := OrderedCollection withAll:reps.
|
|
82 |
|
|
83 |
"Created: / 04-12-2011 / 09:06:53 / cg"
|
79
|
84 |
!
|
|
85 |
|
|
86 |
removeRepository: aRepository
|
|
87 |
repositories remove: aRepository ifAbsent: [].
|
|
88 |
self changed: #repositories
|
|
89 |
!
|
|
90 |
|
|
91 |
repositories
|
541
|
92 |
^ ((OrderedCollection withAll:repositories)
|
|
93 |
addFirst:(MCCacheRepository default);
|
|
94 |
yourself)
|
|
95 |
select: [ :ea | ea isValid ]
|
|
96 |
|
|
97 |
"Modified: / 04-12-2011 / 09:04:42 / cg"
|
79
|
98 |
!
|
|
99 |
|
|
100 |
repositoriesDo: aBlock
|
|
101 |
self repositories do: [:ea | [aBlock value: ea] on: Error do: []]
|
541
|
102 |
! !
|
|
103 |
|
|
104 |
!MCRepositoryGroup methodsFor:'searching'!
|
79
|
105 |
|
|
106 |
versionWithInfo: aVersionInfo
|
|
107 |
^self versionWithInfo: aVersionInfo ifNone: [ self error: 'Could not find version ', aVersionInfo name printString,'. Maybe you need to add a repository?' ]
|
|
108 |
!
|
|
109 |
|
|
110 |
versionWithInfo: aVersionInfo ifNone: aBlock
|
|
111 |
self repositoriesDo: [:ea | (ea versionWithInfo: aVersionInfo) ifNotNilDo: [:v | ^ v]].
|
|
112 |
^aBlock value
|
|
113 |
! !
|
|
114 |
|
|
115 |
!MCRepositoryGroup class methodsFor:'documentation'!
|
|
116 |
|
|
117 |
version
|
541
|
118 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCRepositoryGroup.st,v 1.3 2011-12-04 14:44:55 cg Exp $'
|
79
|
119 |
! !
|