123
|
1 |
"{ Package: 'stx:goodies/monticello' }"
|
|
2 |
|
|
3 |
MCVersionInspector subclass:#MCFileRepositoryInspector
|
|
4 |
instanceVariableNames:'repository versions loaded newer inherited selectedPackage
|
|
5 |
selectedVersion order versionInfo'
|
|
6 |
classVariableNames:'Order'
|
|
7 |
poolDictionaries:''
|
586
|
8 |
category:'SCM-Monticello-UI'
|
123
|
9 |
!
|
|
10 |
|
793
|
11 |
!MCFileRepositoryInspector class methodsFor:'documentation'!
|
|
12 |
|
|
13 |
documentation
|
|
14 |
"
|
|
15 |
I'm a monticello tool composed of three panes to browse repositories and the packages they contain. You get an instance of me when you click on a repository in Monticello browser and press open.
|
|
16 |
|
|
17 |
My left pane presents the packages, my right one their versions and the bottom one the commit log of the selected package versions.
|
|
18 |
|
|
19 |
I underline the packages you already loaded, and highlight the ones you don't have updated to the last version. I also highlight the versions you did not load yet.
|
|
20 |
|
|
21 |
Example: I can browse packages of PharoInbox with:
|
|
22 |
(MCFileRepositoryInspector
|
|
23 |
repository: (MCHttpRepository
|
|
24 |
location: 'http://www.squeaksource.com/PharoInbox'
|
|
25 |
user: ''
|
|
26 |
password: '')
|
|
27 |
workingCopy: nil) show.
|
|
28 |
"
|
|
29 |
! !
|
123
|
30 |
|
|
31 |
!MCFileRepositoryInspector class methodsFor:'as yet unclassified'!
|
|
32 |
|
|
33 |
order
|
|
34 |
Order isNil
|
|
35 |
ifTrue: [ Order _ 5 ].
|
|
36 |
^Order
|
|
37 |
!
|
|
38 |
|
|
39 |
order: anInteger
|
|
40 |
Order _ anInteger
|
|
41 |
!
|
|
42 |
|
|
43 |
repository: aFileBasedRepository workingCopy: aWorkingCopy
|
|
44 |
^self new
|
|
45 |
setRepository: aFileBasedRepository workingCopy: aWorkingCopy;
|
|
46 |
yourself
|
|
47 |
! !
|
|
48 |
|
|
49 |
!MCFileRepositoryInspector class methodsFor:'class initialization'!
|
|
50 |
|
|
51 |
initialize
|
|
52 |
"self initialize"
|
|
53 |
|
|
54 |
self migrateInstances
|
|
55 |
!
|
|
56 |
|
|
57 |
migrateInstances
|
|
58 |
self allSubInstancesDo: [:inst |
|
|
59 |
#(packageList versionList) do: [:each |
|
|
60 |
[(inst findListMorph: each) highlightSelector: nil]
|
|
61 |
on: Error do: [:ignore | ]]].
|
|
62 |
! !
|
|
63 |
|
|
64 |
!MCFileRepositoryInspector methodsFor:'as yet unclassified'!
|
|
65 |
|
|
66 |
load
|
|
67 |
self hasVersion ifTrue:
|
|
68 |
[self version isCacheable
|
|
69 |
ifTrue: [version workingCopy repositoryGroup addRepository: repository].
|
|
70 |
super load.
|
|
71 |
self refresh].
|
|
72 |
!
|
|
73 |
|
|
74 |
merge
|
|
75 |
super merge.
|
|
76 |
self refresh.
|
|
77 |
!
|
|
78 |
|
|
79 |
refresh
|
|
80 |
| packageNames name latest av |
|
|
81 |
packageNames _ Set new.
|
|
82 |
versions _ repository readableFileNames collect: [ :each |
|
|
83 |
name _ (each copyUpToLast: $.) copyUpTo: $(.
|
|
84 |
name last isDigit ifFalse: [Array with: name with: '' with: '' with: each]
|
|
85 |
ifTrue:
|
|
86 |
[Array
|
|
87 |
with: (packageNames add: (name copyUpToLast: $-)) "pkg name"
|
|
88 |
with: ((name copyAfterLast: $-) upTo: $.) "user"
|
|
89 |
with: ((name copyAfterLast: $-) copyAfter: $.) asInteger "version"
|
|
90 |
with: each]].
|
|
91 |
newer _ Set new.
|
|
92 |
inherited _ Set new.
|
|
93 |
loaded _ Set new.
|
|
94 |
(MCWorkingCopy allManagers
|
|
95 |
" select: [ :each | packageNames includes: each packageName]")
|
|
96 |
do: [:each |
|
|
97 |
each ancestors do: [ :ancestor |
|
|
98 |
loaded add: ancestor name.
|
|
99 |
ancestor ancestorsDoWhileTrue: [:heir |
|
|
100 |
(inherited includes: heir name)
|
|
101 |
ifTrue: [false]
|
|
102 |
ifFalse: [inherited add: heir name. true]]].
|
|
103 |
latest _ (versions select: [:v | v first = each package name])
|
|
104 |
detectMax: [:v | v third].
|
|
105 |
(latest notNil and: [
|
|
106 |
each ancestors allSatisfy: [:ancestor |
|
|
107 |
av _ ((ancestor name copyAfterLast: $-) copyAfter: $.) asInteger.
|
|
108 |
av < latest third or: [
|
|
109 |
av = latest third and: [((ancestor name copyAfterLast: $-) upTo: $.) ~= latest second]]]])
|
|
110 |
ifTrue: [newer add: each package name ]].
|
|
111 |
|
|
112 |
self changed: #packageList; changed: #versionList
|
|
113 |
!
|
|
114 |
|
|
115 |
setRepository: aFileBasedRepository workingCopy: aWorkingCopy
|
|
116 |
order _ self class order.
|
|
117 |
repository _ aFileBasedRepository.
|
|
118 |
self refresh.
|
|
119 |
aWorkingCopy
|
|
120 |
ifNil: [selectedPackage _ self packageList isEmpty ifFalse: [self packageList first]]
|
|
121 |
ifNotNil: [ selectedPackage _ aWorkingCopy ancestry ancestorString copyUpToLast: $- ].
|
|
122 |
MCWorkingCopy addDependent: self.
|
|
123 |
! !
|
|
124 |
|
|
125 |
!MCFileRepositoryInspector methodsFor:'morphic ui'!
|
|
126 |
|
|
127 |
buttonSpecs
|
|
128 |
^#(('Refresh' refresh 'refresh the version-list')) , super buttonSpecs
|
|
129 |
!
|
|
130 |
|
|
131 |
defaultExtent
|
|
132 |
^450@300
|
|
133 |
!
|
|
134 |
|
|
135 |
defaultLabel
|
|
136 |
^'Repository: ' , repository description
|
|
137 |
!
|
|
138 |
|
|
139 |
hasVersion
|
|
140 |
^ selectedVersion notNil
|
|
141 |
!
|
|
142 |
|
|
143 |
order: anInteger
|
|
144 |
self class order: (order _ anInteger).
|
|
145 |
self changed: #versionList.
|
|
146 |
!
|
|
147 |
|
|
148 |
orderSpecs
|
|
149 |
^{
|
|
150 |
'unchanged' -> nil.
|
|
151 |
'order by package' -> [ :x :y | x first <= y first ].
|
|
152 |
'order by author' -> [ :x :y | x second <= y second ].
|
|
153 |
'order by version-string' -> [ :x :y | x third <= y third ].
|
|
154 |
'order by version-number' -> [ :x :y | x third asNumber >= y third asNumber ].
|
|
155 |
'order by filename' -> [ :x :y | x fourth <= y fourth ].
|
|
156 |
}
|
|
157 |
!
|
|
158 |
|
|
159 |
orderString: anIndex
|
|
160 |
^String streamContents: [ :stream |
|
|
161 |
order = anIndex
|
|
162 |
ifTrue: [ stream nextPutAll: '<yes>' ]
|
|
163 |
ifFalse: [ stream nextPutAll: '<no>' ].
|
|
164 |
stream nextPutAll: (self orderSpecs at: anIndex) key ]
|
|
165 |
!
|
|
166 |
|
|
167 |
packageHighlight: aString
|
|
168 |
|
|
169 |
newer ifNil: [newer := #()].
|
|
170 |
^(loaded anySatisfy: [:each | (each copyUpToLast: $-) = aString])
|
|
171 |
ifTrue: [
|
|
172 |
Text string: aString
|
|
173 |
attribute: (TextEmphasis new emphasisCode: (
|
|
174 |
((newer includes: aString)
|
|
175 |
ifTrue: [5] ifFalse: [4])))]
|
|
176 |
ifFalse: [aString]
|
|
177 |
!
|
|
178 |
|
|
179 |
packageList
|
|
180 |
| result |
|
|
181 |
result _ versions
|
|
182 |
inject: Set new
|
|
183 |
into: [ :set :each | set add: each first; yourself ].
|
|
184 |
|
|
185 |
"sort loaded packages first, then alphabetically"
|
|
186 |
result _ result asSortedCollection: [:a :b |
|
|
187 |
| loadedA loadedB |
|
|
188 |
loadedA _ loaded anySatisfy: [:each | (each copyUpToLast: $-) = a].
|
|
189 |
loadedB _ loaded anySatisfy: [:each | (each copyUpToLast: $-) = b].
|
|
190 |
loadedA = loadedB
|
|
191 |
ifTrue: [a < b]
|
|
192 |
ifFalse: [loadedA]].
|
|
193 |
|
|
194 |
^result collect: [:each | self packageHighlight: each]
|
|
195 |
!
|
|
196 |
|
|
197 |
packageListMenu: aMenu
|
|
198 |
^aMenu
|
|
199 |
!
|
|
200 |
|
|
201 |
packageSelection
|
|
202 |
^self packageList indexOf: selectedPackage
|
|
203 |
!
|
|
204 |
|
|
205 |
packageSelection: aNumber
|
|
206 |
selectedPackage _ aNumber isZero
|
|
207 |
ifFalse: [ (self packageList at: aNumber) asString ].
|
|
208 |
self versionSelection: 0.
|
|
209 |
self changed: #packageSelection; changed: #versionList
|
|
210 |
!
|
|
211 |
|
|
212 |
version
|
|
213 |
^ version ifNil:
|
|
214 |
[Cursor wait showWhile:
|
|
215 |
[version _ repository versionFromFileNamed: selectedVersion].
|
|
216 |
version]
|
|
217 |
!
|
|
218 |
|
|
219 |
versionHighlight: aString
|
|
220 |
|
|
221 |
| verName |
|
|
222 |
inherited ifNil: [inherited := #()].
|
|
223 |
verName := (aString copyUpToLast: $.) copyUpTo: $(.
|
|
224 |
^Text
|
|
225 |
string: aString
|
|
226 |
attribute: (TextEmphasis new emphasisCode: (
|
|
227 |
((loaded includes: verName) ifTrue: [ 4 "underlined" ]
|
|
228 |
ifFalse: [ (inherited includes: verName)
|
|
229 |
ifTrue: [ 0 ]
|
|
230 |
ifFalse: [ 1 "bold" ] ])))
|
|
231 |
!
|
|
232 |
|
|
233 |
versionInfo
|
|
234 |
^ versionInfo ifNil: [versionInfo _ repository versionInfoFromFileNamed: selectedVersion]
|
|
235 |
!
|
|
236 |
|
|
237 |
versionList
|
|
238 |
| result sortBlock |
|
|
239 |
result _ selectedPackage isNil
|
|
240 |
ifTrue: [ versions ]
|
|
241 |
ifFalse: [ versions select: [ :each | selectedPackage = each first ] ].
|
|
242 |
sortBlock _ (self orderSpecs at: order) value.
|
|
243 |
sortBlock isNil ifFalse: [
|
|
244 |
result _ result asSortedCollection: [:a :b | [sortBlock value: a value: b] on: Error do: [true]]].
|
|
245 |
^result _ result
|
|
246 |
collect: [ :each | self versionHighlight: each fourth ]
|
|
247 |
!
|
|
248 |
|
|
249 |
versionListMenu: aMenu
|
|
250 |
1 to: self orderSpecs size do: [ :index |
|
|
251 |
aMenu addUpdating: #orderString: target: self selector: #order: argumentList: { index } ].
|
|
252 |
^aMenu
|
|
253 |
!
|
|
254 |
|
|
255 |
versionSelection
|
|
256 |
^self versionList indexOf: selectedVersion
|
|
257 |
!
|
|
258 |
|
|
259 |
versionSelection: aNumber
|
|
260 |
aNumber isZero
|
|
261 |
ifTrue: [ selectedVersion _ version _ versionInfo _ nil ]
|
|
262 |
ifFalse: [
|
|
263 |
selectedVersion _ (self versionList at: aNumber) asString.
|
|
264 |
version _ versionInfo _ nil].
|
|
265 |
self changed: #versionSelection; changed: #summary; changed: #hasVersion
|
|
266 |
!
|
|
267 |
|
|
268 |
versionSummary
|
|
269 |
^ version
|
|
270 |
ifNotNil: [version summary]
|
|
271 |
ifNil: [self versionInfo summary]
|
|
272 |
!
|
|
273 |
|
|
274 |
widgetSpecs
|
|
275 |
^#( ((buttonRow) (0 0 1 0) (0 0 0 30))
|
|
276 |
((listMorph: package) (0 0 0.5 0.6) (0 30 0 0))
|
|
277 |
((listMorph: version) (0.5 0 1 0.6) (0 30 0 0))
|
|
278 |
((textMorph: summary) (0 0.6 1 1) (0 0 0 0)) )
|
|
279 |
! !
|
|
280 |
|
|
281 |
!MCFileRepositoryInspector class methodsFor:'documentation'!
|
|
282 |
|
|
283 |
version
|
793
|
284 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCFileRepositoryInspector.st,v 1.3 2013-05-15 12:03:44 cg Exp $'
|
123
|
285 |
! !
|
|
286 |
|
793
|
287 |
|
123
|
288 |
MCFileRepositoryInspector initialize!
|