author | Jan Vrany <jan.vrany@labware.com> |
Wed, 06 Oct 2021 12:18:22 +0100 | |
branch | jv |
changeset 1153 | 16866d65107a |
parent 1143 | 1999f5363e6f |
child 1167 | 37c202ea81a8 |
permissions | -rw-r--r-- |
1143
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
1 |
" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
2 |
COPYRIGHT (c) 2021 LabWare |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
3 |
" |
85 | 4 |
"{ Package: 'stx:goodies/monticello' }" |
5 |
||
1143
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
6 |
"{ NameSpace: Smalltalk }" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
7 |
|
85 | 8 |
Object subclass:#MCVersion |
741 | 9 |
instanceVariableNames:'package info snapshot dependencies cachable' |
85 | 10 |
classVariableNames:'' |
11 |
poolDictionaries:'' |
|
696 | 12 |
category:'SCM-Monticello-Versioning' |
85 | 13 |
! |
14 |
||
1143
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
15 |
!MCVersion class methodsFor:'documentation'! |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
16 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
17 |
copyright |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
18 |
" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
19 |
COPYRIGHT (c) 2021 LabWare |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
20 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
21 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
22 |
" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
23 |
! ! |
85 | 24 |
|
25 |
!MCVersion class methodsFor:'instance creation'! |
|
26 |
||
1143
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
27 |
forPackage: packageId |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
28 |
"Returns an MCVersion for currently loaded code" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
29 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
30 |
| pkg wc versionInfo version | |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
31 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
32 |
pkg := MCPackage named: packageId. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
33 |
wc := pkg workingCopy. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
34 |
versionInfo := MCVersionInfo forPackage: packageId. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
35 |
[ |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
36 |
version := wc newVersion. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
37 |
version snapshot options includeExtrasForSTX:false. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
38 |
] on:MCVersionNameAndMessageRequest do:[:ex | |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
39 |
ex resume:(Array with:versionInfo name with:versionInfo message) |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
40 |
]. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
41 |
version info:versionInfo. |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
42 |
^ version |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
43 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
44 |
" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
45 |
MCVersion forPackage: 'MachineArithmetic' |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
46 |
" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
47 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
48 |
"Created: / 03-05-2021 / 16:14:04 / Jan Vrany <jan.vrany@labware.com>" |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
49 |
! |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
50 |
|
85 | 51 |
package: aPackageOrPackageID |
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
52 |
aPackageOrPackageID isSymbol ifTrue:[ |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
53 |
"/ an ST/X package-ID |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
54 |
^ super package: aPackageOrPackageID |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
55 |
]. |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
56 |
"/ a monticello package-ID |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
57 |
^ self package: aPackageOrPackageID info: MCVersionInfo new |
85 | 58 |
|
59 |
"Modified: / 22-11-2006 / 14:16:22 / cg" |
|
60 |
! |
|
61 |
||
62 |
package: aPackage info: aVersionInfo |
|
63 |
^ self package: aPackage info: aVersionInfo snapshot: aPackage snapshot |
|
64 |
! |
|
65 |
||
66 |
package: aPackage info: aVersionInfo snapshot: aSnapshot |
|
67 |
^ self package: aPackage info: aVersionInfo snapshot: aSnapshot dependencies: #() |
|
68 |
! |
|
69 |
||
70 |
package: aPackage info: aVersionInfo snapshot: aSnapshot dependencies: aCollection |
|
71 |
^ self new initializeWithPackage: aPackage info: aVersionInfo snapshot: aSnapshot dependencies: aCollection |
|
72 |
! ! |
|
73 |
||
74 |
!MCVersion methodsFor:'accessing'! |
|
75 |
||
741 | 76 |
cachable:something |
77 |
cachable := something. |
|
78 |
! |
|
79 |
||
85 | 80 |
changes |
81 |
^ self snapshot patchRelativeToBase: package snapshot |
|
82 |
! |
|
83 |
||
84 |
dependencies |
|
85 |
^ dependencies ifNil: [#()] |
|
86 |
! |
|
87 |
||
88 |
fileName |
|
764 | 89 |
|rawName cookedName legalName| |
570 | 90 |
|
91 |
rawName := info name. |
|
764 | 92 |
cookedName := rawName copy replaceAny:'/:' with:$_. |
765 | 93 |
legalName := cookedName asFilename makeLegalFilename name. |
570 | 94 |
^ legalName, '.', self writerClass extension |
95 |
||
96 |
"Modified: / 24-07-2012 / 16:30:13 / cg" |
|
85 | 97 |
! |
98 |
||
99 |
info |
|
100 |
^ info |
|
101 |
! |
|
102 |
||
882 | 103 |
info: anMCAncestry |
104 |
info := anMCAncestry. |
|
105 |
||
106 |
"Modified (format): / 07-06-2013 / 01:01:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
107 |
! |
|
108 |
||
85 | 109 |
package |
110 |
^ package |
|
111 |
! |
|
112 |
||
113 |
snapshot |
|
114 |
^ snapshot |
|
115 |
! |
|
116 |
||
531 | 117 |
snapshot:anMCSnapshot |
118 |
snapshot := anMCSnapshot |
|
119 |
||
120 |
"Created: / 02-12-2011 / 16:10:18 / cg" |
|
121 |
! |
|
122 |
||
85 | 123 |
summary |
124 |
^ String streamContents: |
|
125 |
[:s | |
|
126 |
s nextPutAll: info summaryHeader. |
|
127 |
(dependencies isNil or: [dependencies isEmpty]) ifFalse: |
|
128 |
[s cr; nextPutAll: 'Dependencies: '. |
|
129 |
dependencies |
|
130 |
do: [:ea | s nextPutAll: ea versionInfo name] |
|
131 |
separatedBy: [s nextPutAll: ', ']]. |
|
132 |
s cr; cr; nextPutAll: info message] |
|
133 |
! |
|
134 |
||
135 |
workingCopy |
|
136 |
^ package workingCopy |
|
137 |
! |
|
138 |
||
139 |
writerClass |
|
737 | 140 |
Smalltalk isSmalltalkX ifTrue:[ |
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
141 |
^ MCStxMczWriter |
737 | 142 |
] ifFalse:[ |
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
143 |
^ MCMczWriter |
737 | 144 |
] |
85 | 145 |
! ! |
146 |
||
147 |
!MCVersion methodsFor:'actions'! |
|
148 |
||
149 |
addToCache |
|
1153
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
150 |
MCCacheRepository default storeVersion: self |
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
151 |
|
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
152 |
"Modified: / 06-10-2021 / 12:16:44 / Jan Vrany <jan.vrany@labware.com>" |
85 | 153 |
! |
154 |
||
155 |
adopt |
|
156 |
self workingCopy adopt: self |
|
157 |
! |
|
158 |
||
159 |
browse |
|
160 |
(MCSnapshotBrowser forSnapshot: self snapshot) |
|
161 |
showLabelled: 'Snapshot of ', self fileName |
|
162 |
! |
|
163 |
||
164 |
fileOutOn: aStream |
|
165 |
self writerClass fileOut: self on: aStream |
|
166 |
! |
|
167 |
||
168 |
load |
|
169 |
MCVersionLoader loadVersion: self |
|
170 |
! |
|
171 |
||
172 |
merge |
|
173 |
MCVersionMerger mergeVersion: self |
|
174 |
! |
|
175 |
||
176 |
open |
|
177 |
(MCVersionInspector new version: self) show |
|
178 |
! ! |
|
179 |
||
180 |
!MCVersion methodsFor:'converting'! |
|
181 |
||
182 |
asDiffAgainst: aVersion |
|
183 |
aVersion info = self info ifTrue: [self error: 'Cannot diff against self!!']. |
|
184 |
^ MCDiffyVersion |
|
185 |
package: self package |
|
186 |
info: self info |
|
187 |
snapshot: self snapshot |
|
188 |
dependencies: self dependencies |
|
189 |
baseVersion: aVersion |
|
190 |
! ! |
|
191 |
||
192 |
!MCVersion methodsFor:'enumerating'! |
|
193 |
||
194 |
allAvailableDependenciesDo: aBlock |
|
195 |
| version | |
|
196 |
self dependencies do: |
|
197 |
[:ea | |
|
198 |
[version _ ea resolve. |
|
199 |
version allAvailableDependenciesDo: aBlock. |
|
200 |
aBlock value: version] |
|
201 |
on: Error do: []] |
|
202 |
! |
|
203 |
||
204 |
allDependenciesDo: aBlock |
|
205 |
self allDependenciesDo: aBlock ifUnresolved: [:ignored | true] |
|
206 |
! |
|
207 |
||
208 |
allDependenciesDo: aBlock ifUnresolved: failBlock |
|
209 |
| dict | |
|
210 |
dict _ Dictionary new. |
|
211 |
self allDependenciesNotIn: dict do: aBlock ifUnresolved: failBlock |
|
212 |
! |
|
213 |
||
214 |
allDependenciesNotIn: aDictionary do: aBlock ifUnresolved: failBlock |
|
215 |
| version | |
|
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
216 |
self dependencies do: |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
217 |
[:ea | |
85 | 218 |
version := aDictionary at: ea ifAbsent: [ea resolve]. |
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
219 |
version |
85 | 220 |
ifNil: [failBlock value: ea] |
221 |
ifNotNil: [(aDictionary includes: version) ifFalse: |
|
222 |
[aDictionary at: ea put: version. |
|
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
223 |
version |
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
224 |
allDependenciesNotIn: aDictionary |
85 | 225 |
do: aBlock |
226 |
ifUnresolved: failBlock. |
|
227 |
aBlock value: version]]] |
|
228 |
! |
|
229 |
||
230 |
withAllDependenciesDo: aBlock |
|
231 |
self allDependenciesDo: aBlock ifUnresolved: [:ignored]. |
|
232 |
aBlock value: self |
|
233 |
! |
|
234 |
||
235 |
withAllDependenciesDo: aBlock ifUnresolved: failBlock |
|
236 |
| dict | |
|
237 |
dict _ Dictionary new. |
|
238 |
self allDependenciesNotIn: dict do: aBlock ifUnresolved: failBlock. |
|
239 |
aBlock value: self |
|
240 |
! ! |
|
241 |
||
242 |
!MCVersion methodsFor:'initialize-release'! |
|
243 |
||
244 |
initializeWithPackage: aPackage info: aVersionInfo snapshot: aSnapshot dependencies: aCollection |
|
1153
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
245 |
package _ aPackage. |
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
246 |
info _ aVersionInfo. |
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
247 |
snapshot _ aSnapshot. |
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
248 |
dependencies _ aCollection. |
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
249 |
"/ self addToCache. |
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
250 |
|
16866d65107a
Do not cache `MCVersion`s in cache repository
Jan Vrany <jan.vrany@labware.com>
parents:
1143
diff
changeset
|
251 |
"Modified: / 06-10-2021 / 12:17:04 / Jan Vrany <jan.vrany@labware.com>" |
85 | 252 |
! |
253 |
||
254 |
setPackage: aPackage info: aVersionInfo snapshot: aSnapshot dependencies: aCollection |
|
255 |
package _ aPackage. |
|
256 |
info _ aVersionInfo. |
|
257 |
snapshot _ aSnapshot. |
|
258 |
dependencies _ aCollection |
|
259 |
! ! |
|
260 |
||
261 |
!MCVersion methodsFor:'printing'! |
|
262 |
||
263 |
printOn: aStream |
|
264 |
super printOn: aStream. |
|
265 |
aStream nextPut: $(. |
|
266 |
aStream nextPutAll: self info name. |
|
267 |
aStream nextPut: $). |
|
268 |
! ! |
|
269 |
||
270 |
!MCVersion methodsFor:'testing'! |
|
271 |
||
272 |
canOptimizeLoading |
|
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
273 |
"Answer whether I can provide a patch for the working copy without the usual diff pass" |
85 | 274 |
^false |
275 |
! |
|
276 |
||
277 |
isCacheable |
|
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
278 |
^ cachable ? true |
85 | 279 |
! |
280 |
||
281 |
isDiffy |
|
282 |
^ false |
|
283 |
! ! |
|
284 |
||
285 |
!MCVersion class methodsFor:'documentation'! |
|
286 |
||
287 |
version |
|
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
288 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCVersion.st,v 1.10 2013-07-27 13:50:54 cg Exp $' |
741 | 289 |
! |
290 |
||
291 |
version_CVS |
|
891
a4e2e9b2947d
wether -> whether (lookup what wether is ;-)
Claus Gittinger <cg@exept.de>
parents:
882
diff
changeset
|
292 |
^ '$Header: /cvs/stx/stx/goodies/monticello/MCVersion.st,v 1.10 2013-07-27 13:50:54 cg Exp $' |
1143
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
293 |
! |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
294 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
295 |
version_HG |
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
296 |
|
1999f5363e6f
Add utility `MCVersion class >> #forPackage:`
Jan Vrany <jan.vrany@labware.com>
parents:
891
diff
changeset
|
297 |
^ '$Changeset: <not expanded> $' |
85 | 298 |
! ! |
737 | 299 |