author | Claus Gittinger <cg@exept.de> |
Mon, 14 May 2018 02:21:18 +0200 | |
changeset 1048 | 582b3a028cbc |
parent 1046 | 2c62588b53ed |
permissions | -rw-r--r-- |
1042 | 1 |
"{ Encoding: utf8 }" |
2 |
||
79 | 3 |
"{ Package: 'stx:goodies/monticello' }" |
4 |
||
1042 | 5 |
"{ NameSpace: Smalltalk }" |
6 |
||
79 | 7 |
Object subclass:#MCRepositoryGroup |
8 |
instanceVariableNames:'repositories' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
590 | 11 |
category:'SCM-Monticello-Versioning' |
79 | 12 |
! |
13 |
||
14 |
MCRepositoryGroup class instanceVariableNames:'default' |
|
15 |
||
16 |
" |
|
17 |
No other class instance variables are inherited by this class. |
|
18 |
" |
|
19 |
! |
|
20 |
||
21 |
MCRepositoryGroup comment:'A singleton class, holds the list of repositories. Can look for a requested VersionInfo among its repositories.' |
|
22 |
! |
|
23 |
||
24 |
||
25 |
!MCRepositoryGroup class methodsFor:'as yet unclassified'! |
|
26 |
||
27 |
default |
|
561 | 28 |
default isNil ifTrue: [default := self new]. |
29 |
^default |
|
30 |
||
31 |
"Modified: / 04-04-2012 / 11:04:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
79 | 32 |
! |
33 |
||
34 |
new |
|
35 |
^ self basicNew initialize |
|
36 |
! ! |
|
37 |
||
38 |
!MCRepositoryGroup methodsFor:'as yet unclassified'! |
|
39 |
||
40 |
addRepository: aRepository |
|
541 | 41 |
((repositories includes: aRepository) or: [aRepository == MCCacheRepository default]) |
552 | 42 |
ifFalse: [ |
43 |
repositories add: aRepository. |
|
44 |
self class default addRepository: aRepository. |
|
45 |
self changed: #repositories |
|
541 | 46 |
]. |
47 |
||
48 |
"Modified: / 04-12-2011 / 09:04:24 / cg" |
|
49 |
! |
|
50 |
||
51 |
flushRepositories |
|
52 |
"/ cg: mhmh - what should we do here ? |
|
556
f9aca2ebc86f
comment/format in: #flushRepositories
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
552
diff
changeset
|
53 |
"/ called by UserPreferences >> mcRepositories: |
541 | 54 |
|
55 |
self initializeRepositoriesFromUserSettings |
|
56 |
||
57 |
"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
|
58 |
"Modified (comment): / 24-01-2012 / 09:51:53 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
79 | 59 |
! |
60 |
||
61 |
includes: aRepository |
|
62 |
^ self repositories includes: aRepository |
|
63 |
! |
|
64 |
||
65 |
includesVersionNamed: aString |
|
66 |
self repositoriesDo: [:ea | (ea includesVersionNamed: aString) ifTrue: [^ true]]. |
|
552 | 67 |
^ false |
79 | 68 |
! |
69 |
||
70 |
initialize |
|
541 | 71 |
"/ repositories _ OrderedCollection new |
72 |
self initializeRepositoriesFromUserSettings |
|
73 |
||
74 |
"Modified: / 04-12-2011 / 09:07:23 / cg" |
|
75 |
! |
|
76 |
||
77 |
initializeRepositoriesFromUserSettings |
|
1042 | 78 |
|litArray reps dir rep| |
541 | 79 |
|
561 | 80 |
litArray := UserPreferences current mcRepositories. |
566
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
81 |
litArray == false ifTrue:[ |
1042 | 82 |
"there is no entry in the UserPreferences, so false - the default value - is returned" |
566
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
83 |
reps := #(). |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
84 |
] ifFalse:[ |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
85 |
reps := litArray decodeAsLiteralArray. |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
86 |
]. |
2cdc9be3bc68
changed: #initializeRepositoriesFromUserSettings
Stefan Vogel <sv@exept.de>
parents:
561
diff
changeset
|
87 |
repositories := reps asOrderedCollection. |
541 | 88 |
|
1042 | 89 |
((dir := Filename downloadsDirectory) notNil and:[dir exists]) ifTrue:[ |
90 |
rep := MCDirectoryRepository directory:dir pathName. |
|
1046 | 91 |
repositories add:rep |
1042 | 92 |
]. |
93 |
((dir := Smalltalk packageDirectoryForPackageId:'stx:goodies/monticello_packages') notNil and:[dir exists]) ifTrue:[ |
|
94 |
rep := MCDirectoryRepository directory:dir pathName. |
|
1046 | 95 |
repositories add:rep |
1042 | 96 |
]. |
97 |
||
541 | 98 |
"Created: / 04-12-2011 / 09:06:53 / cg" |
561 | 99 |
"Modified: / 04-04-2012 / 11:08:50 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
79 | 100 |
! |
101 |
||
102 |
removeRepository: aRepository |
|
103 |
repositories remove: aRepository ifAbsent: []. |
|
104 |
self changed: #repositories |
|
105 |
! |
|
106 |
||
107 |
repositories |
|
783 | 108 |
^ ((OrderedSet with:MCCacheRepository default) |
109 |
addAll:repositories; |
|
110 |
yourself) |
|
111 |
asOrderedCollection |
|
112 |
select: [ :ea | ea isValid ] |
|
541 | 113 |
|
114 |
"Modified: / 04-12-2011 / 09:04:42 / cg" |
|
79 | 115 |
! |
116 |
||
561 | 117 |
repositories: anOrderedCollection |
118 |
||
119 |
repositories := anOrderedCollection copy. |
|
120 |
"Ensure, that repositories contain cache as first" |
|
121 |
repositories remove: MCCacheRepository default ifAbsent:[]. |
|
122 |
repositories addFirst: MCCacheRepository default. |
|
123 |
self == self class default ifTrue:[ |
|
124 |
UserPreferences current mcRepositories: repositories asArray literalArrayEncoding |
|
125 |
]. |
|
126 |
||
127 |
"Created: / 04-04-2012 / 11:05:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
128 |
! |
|
129 |
||
79 | 130 |
repositoriesDo: aBlock |
131 |
self repositories do: [:ea | [aBlock value: ea] on: Error do: []] |
|
541 | 132 |
! ! |
133 |
||
134 |
!MCRepositoryGroup methodsFor:'searching'! |
|
79 | 135 |
|
136 |
versionWithInfo: aVersionInfo |
|
137 |
^self versionWithInfo: aVersionInfo ifNone: [ self error: 'Could not find version ', aVersionInfo name printString,'. Maybe you need to add a repository?' ] |
|
138 |
! |
|
139 |
||
140 |
versionWithInfo: aVersionInfo ifNone: aBlock |
|
141 |
self repositoriesDo: [:ea | (ea versionWithInfo: aVersionInfo) ifNotNilDo: [:v | ^ v]]. |
|
142 |
^aBlock value |
|
143 |
! ! |
|
144 |
||
145 |
!MCRepositoryGroup class methodsFor:'documentation'! |
|
146 |
||
147 |
version |
|
1042 | 148 |
^ '$Header$' |
79 | 149 |
! ! |
783 | 150 |