How to #currentVersion from a Configuration

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to #currentVersion from a Configuration

HilaireFernandes
Hello,

I use to do perform this code to get the installed version from a
ConfigurationOfDrGeo:

drgeoVersion
     ^ 'Installed version: ', ConfigurationOfDrGeo new project
currentVersion versionNumber versionString

It does not work anymore, and produce the following error stack

Any idea?

Hilaire


MetacelloMCVersionSpec(Object)>>error:
[ ^ self error: 'Name not found: ' , aString ] in
MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpec:forLoad:forMap:packages:
in Block: [ ^ self error: 'Name not found: ' , aString ]
[ (self importArray notNil or: [ self import notNil ])
     ifTrue:
         [ "expect the 'missing' name to be satisfied within context of
imported project"
         importArray
             ifNotNil: [ importArray
                     do: [ :assoc |
                         ((assoc value includes: aString) and: [ map
includesKey: assoc key ])
                             ifTrue: [ importSpec := (map at: assoc key)
                                     mergeImportLoads: {aString};
                                     yourself ] ].
                 importSpec ifNotNil: [ ^ importSpec ] ].
         (importSpec isNil and: [ self import notNil ])
             ifTrue: [ ^ (map at: self import ifAbsent: absentBlock)
                     mergeImportLoads: {aString};
                     yourself ] ].
(aString = 'default' or: [ aString = 'ALL' ])
     ifTrue: [ self project groupSpec
             name: aString;
             includes: self packageNames;
             yourself ]
     ifFalse: [ absentBlock value ] ] in
MetacelloMCVersionSpec(MetacelloVersionSpec)>>packageNamed:forLoad:forMap:ifAbsent:
in Block: [ (self importArray notNil or: [ self import notNi...etc...
Dictionary>>at:ifAbsent:
MetacelloMCVersionSpec(MetacelloVersionSpec)>>packageNamed:forLoad:forMap:ifAbsent:
MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpec:forLoad:forMap:packages:
[ :req |
(self
     resolveToLoadableSpec: req
     forLoad: forLoad
     forMap: map
     packages: packageMap)
     do: [ :loadableSpec |
         newReqd addAll: loadableSpec requires.
         newReqd addAll: loadableSpec includes ] ] in
MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpecs:forLoad:map:
in Block: [ :req | ...
Set>>do:
MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpecs:forLoad:map:
MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpecs:
[ :cache |
names := (self resolveToLoadableSpecs: nameList)
     collect: [ :spec | spec name ].
cache at: cacheKey put: names ] in
MetacelloMCVersionSpec(MetacelloVersionSpec)>>expandToLoadableSpecNames:
in Block: [ :cache | ...
[ :dict |
| cache |
cache := dict at: cacheName ifAbsent: [  ].
cache ~~ nil
     ifTrue: [ | value hasEntry |
         hasEntry := true.
         value := cache at: key ifAbsent: [ hasEntry := false ].
         hasEntry
             ifTrue: [ ^ value ] ]
     ifFalse: [ cache := cacheClass new.
         dict at: cacheName put: cache ].
^ aBlock value: cache ] in
IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
in Block: [ :dict | ...
[ ^ aBlock value: dict ] in
IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
in Block: [ ^ aBlock value: dict ]
BlockClosure>>on:do:
IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:at:doing:
MetacelloMCVersionSpec(MetacelloVersionSpec)>>expandToLoadableSpecNames:
MetacelloMCVersionSpec>>isPartiallyCurrent
[ :version |
| status matchBlock |
status := resolvedPackageAndProjectNames isNil
     ifTrue: [ version spec isPartiallyCurrent ]
     ifFalse: [ version spec
             isPartiallyCurrentAgainst: resolvedPackageAndProjectNames ].
matchBlock := [ :matchStatus |
cv := version copy.
cv versionStatus: matchStatus.
^ cache at: cacheKey put: cv ].
status isAllLoadedToSpec: matchBlock.
status isLoadedToSpec: matchBlock.
status isLoadedMatchConstraints: matchBlock.
status
     isSomethingLoaded: [ :matchStatus |
         latestSomethingLoaded isNil
             ifTrue: [ cv := version copy.
                 cv versionStatus: matchStatus.
                 latestSomethingLoaded := cv ] ] ] in [ :cache |
| cv versions latestSomethingLoaded |
cv := nil.
versions := self sortedAndFilteredVersions.
versions
     do: [ :version |
         | status matchBlock |
         status := resolvedPackageAndProjectNames isNil
             ifTrue: [ version spec isPartiallyCurrent ]
             ifFalse: [ version spec
                     isPartiallyCurrentAgainst:
resolvedPackageAndProjectNames ].
         matchBlock := [ :matchStatus |
         cv := version copy.
         cv versionStatus: matchStatus.
         ^ cache at: cacheKey put: cv ].
         status isAllLoadedToSpec: matchBlock.
         status isLoadedToSpec: matchBlock.
         status isLoadedMatchConstraints: matchBlock.
         status
             isSomethingLoaded: [ :matchStatus |
                 latestSomethingLoaded isNil
                     ifTrue: [ cv := version copy.
                         cv versionStatus: matchStatus.
                         latestSomethingLoaded := cv ] ] ].
latestSomethingLoaded
     ifNotNil: [ ^ cache at: cacheKey put: latestSomethingLoaded ].
^ cache at: cacheKey put: nil ] in
MetacelloMCProject(MetacelloProject)>>currentVersionAgainst: in Block: [
:version | ...
Array(SequenceableCollection)>>do:
[ :cache |
| cv versions latestSomethingLoaded |
cv := nil.
versions := self sortedAndFilteredVersions.
versions
     do: [ :version |
         | status matchBlock |
         status := resolvedPackageAndProjectNames isNil
             ifTrue: [ version spec isPartiallyCurrent ]
             ifFalse: [ version spec
                     isPartiallyCurrentAgainst:
resolvedPackageAndProjectNames ].
         matchBlock := [ :matchStatus |
         cv := version copy.
         cv versionStatus: matchStatus.
         ^ cache at: cacheKey put: cv ].
         status isAllLoadedToSpec: matchBlock.
         status isLoadedToSpec: matchBlock.
         status isLoadedMatchConstraints: matchBlock.
         status
             isSomethingLoaded: [ :matchStatus |
                 latestSomethingLoaded isNil
                     ifTrue: [ cv := version copy.
                         cv versionStatus: matchStatus.
                         latestSomethingLoaded := cv ] ] ].
latestSomethingLoaded
     ifNotNil: [ ^ cache at: cacheKey put: latestSomethingLoaded ].
^ cache at: cacheKey put: nil ] in
MetacelloMCProject(MetacelloProject)>>currentVersionAgainst: in Block: [
:cache | ...
[ :dict |
| cache |
cache := dict at: cacheName ifAbsent: [  ].
cache ~~ nil
     ifTrue: [ | value hasEntry |
         hasEntry := true.
         value := cache at: key ifAbsent: [ hasEntry := false ].
         hasEntry
             ifTrue: [ ^ value ] ]
     ifFalse: [ cache := cacheClass new.
         dict at: cacheName put: cache ].
^ aBlock value: cache ] in
IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
in Block: [ :dict | ...
[ ^ aBlock value: dict ] in
IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
in Block: [ ^ aBlock value: dict ]
BlockClosure>>on:do:
IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:at:doing:
MetacelloMCProject(MetacelloProject)>>currentVersionAgainst:
[ :cache |
cv := self currentVersionAgainst: nil.
^ cache at: cacheKey put: cv ] in
MetacelloMCProject(MetacelloProject)>>currentVersion in Block: [ :cache
| ...

--
Dr. Geo
http://drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: How to #currentVersion from a Configuration

Stephane Ducasse-3
In my pharo 6.1 image I have

currentVersion
| cacheKey cv |
cacheKey := self configuration class.
^ MetacelloPlatform current
stackCacheFor: #currentVersion
at: cacheKey
doing: [ :cache |
cv := self currentVersionAgainst: nil.
^ cache at: cacheKey put: cv ]

And we do not change the code that Dale release and he is making sure
that old code is working so this is strange.

Stef



On Mon, Apr 2, 2018 at 3:03 PM, Hilaire <[hidden email]> wrote:

> Hello,
>
> I use to do perform this code to get the installed version from a
> ConfigurationOfDrGeo:
>
> drgeoVersion
>     ^ 'Installed version: ', ConfigurationOfDrGeo new project currentVersion
> versionNumber versionString
>
> It does not work anymore, and produce the following error stack
>
> Any idea?
>
> Hilaire
>
>
> MetacelloMCVersionSpec(Object)>>error:
> [ ^ self error: 'Name not found: ' , aString ] in
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpec:forLoad:forMap:packages:
> in Block: [ ^ self error: 'Name not found: ' , aString ]
> [ (self importArray notNil or: [ self import notNil ])
>     ifTrue:
>         [ "expect the 'missing' name to be satisfied within context of
> imported project"
>         importArray
>             ifNotNil: [ importArray
>                     do: [ :assoc |
>                         ((assoc value includes: aString) and: [ map
> includesKey: assoc key ])
>                             ifTrue: [ importSpec := (map at: assoc key)
>                                     mergeImportLoads: {aString};
>                                     yourself ] ].
>                 importSpec ifNotNil: [ ^ importSpec ] ].
>         (importSpec isNil and: [ self import notNil ])
>             ifTrue: [ ^ (map at: self import ifAbsent: absentBlock)
>                     mergeImportLoads: {aString};
>                     yourself ] ].
> (aString = 'default' or: [ aString = 'ALL' ])
>     ifTrue: [ self project groupSpec
>             name: aString;
>             includes: self packageNames;
>             yourself ]
>     ifFalse: [ absentBlock value ] ] in
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>packageNamed:forLoad:forMap:ifAbsent:
> in Block: [ (self importArray notNil or: [ self import notNi...etc...
> Dictionary>>at:ifAbsent:
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>packageNamed:forLoad:forMap:ifAbsent:
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpec:forLoad:forMap:packages:
> [ :req |
> (self
>     resolveToLoadableSpec: req
>     forLoad: forLoad
>     forMap: map
>     packages: packageMap)
>     do: [ :loadableSpec |
>         newReqd addAll: loadableSpec requires.
>         newReqd addAll: loadableSpec includes ] ] in
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpecs:forLoad:map:
> in Block: [ :req | ...
> Set>>do:
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpecs:forLoad:map:
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>resolveToLoadableSpecs:
> [ :cache |
> names := (self resolveToLoadableSpecs: nameList)
>     collect: [ :spec | spec name ].
> cache at: cacheKey put: names ] in
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>expandToLoadableSpecNames: in
> Block: [ :cache | ...
> [ :dict |
> | cache |
> cache := dict at: cacheName ifAbsent: [  ].
> cache ~~ nil
>     ifTrue: [ | value hasEntry |
>         hasEntry := true.
>         value := cache at: key ifAbsent: [ hasEntry := false ].
>         hasEntry
>             ifTrue: [ ^ value ] ]
>     ifFalse: [ cache := cacheClass new.
>         dict at: cacheName put: cache ].
> ^ aBlock value: cache ] in
> IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
> in Block: [ :dict | ...
> [ ^ aBlock value: dict ] in
> IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
> in Block: [ ^ aBlock value: dict ]
> BlockClosure>>on:do:
> IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
> IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
> IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:at:doing:
> MetacelloMCVersionSpec(MetacelloVersionSpec)>>expandToLoadableSpecNames:
> MetacelloMCVersionSpec>>isPartiallyCurrent
> [ :version |
> | status matchBlock |
> status := resolvedPackageAndProjectNames isNil
>     ifTrue: [ version spec isPartiallyCurrent ]
>     ifFalse: [ version spec
>             isPartiallyCurrentAgainst: resolvedPackageAndProjectNames ].
> matchBlock := [ :matchStatus |
> cv := version copy.
> cv versionStatus: matchStatus.
> ^ cache at: cacheKey put: cv ].
> status isAllLoadedToSpec: matchBlock.
> status isLoadedToSpec: matchBlock.
> status isLoadedMatchConstraints: matchBlock.
> status
>     isSomethingLoaded: [ :matchStatus |
>         latestSomethingLoaded isNil
>             ifTrue: [ cv := version copy.
>                 cv versionStatus: matchStatus.
>                 latestSomethingLoaded := cv ] ] ] in [ :cache |
> | cv versions latestSomethingLoaded |
> cv := nil.
> versions := self sortedAndFilteredVersions.
> versions
>     do: [ :version |
>         | status matchBlock |
>         status := resolvedPackageAndProjectNames isNil
>             ifTrue: [ version spec isPartiallyCurrent ]
>             ifFalse: [ version spec
>                     isPartiallyCurrentAgainst:
> resolvedPackageAndProjectNames ].
>         matchBlock := [ :matchStatus |
>         cv := version copy.
>         cv versionStatus: matchStatus.
>         ^ cache at: cacheKey put: cv ].
>         status isAllLoadedToSpec: matchBlock.
>         status isLoadedToSpec: matchBlock.
>         status isLoadedMatchConstraints: matchBlock.
>         status
>             isSomethingLoaded: [ :matchStatus |
>                 latestSomethingLoaded isNil
>                     ifTrue: [ cv := version copy.
>                         cv versionStatus: matchStatus.
>                         latestSomethingLoaded := cv ] ] ].
> latestSomethingLoaded
>     ifNotNil: [ ^ cache at: cacheKey put: latestSomethingLoaded ].
> ^ cache at: cacheKey put: nil ] in
> MetacelloMCProject(MetacelloProject)>>currentVersionAgainst: in Block: [
> :version | ...
> Array(SequenceableCollection)>>do:
> [ :cache |
> | cv versions latestSomethingLoaded |
> cv := nil.
> versions := self sortedAndFilteredVersions.
> versions
>     do: [ :version |
>         | status matchBlock |
>         status := resolvedPackageAndProjectNames isNil
>             ifTrue: [ version spec isPartiallyCurrent ]
>             ifFalse: [ version spec
>                     isPartiallyCurrentAgainst:
> resolvedPackageAndProjectNames ].
>         matchBlock := [ :matchStatus |
>         cv := version copy.
>         cv versionStatus: matchStatus.
>         ^ cache at: cacheKey put: cv ].
>         status isAllLoadedToSpec: matchBlock.
>         status isLoadedToSpec: matchBlock.
>         status isLoadedMatchConstraints: matchBlock.
>         status
>             isSomethingLoaded: [ :matchStatus |
>                 latestSomethingLoaded isNil
>                     ifTrue: [ cv := version copy.
>                         cv versionStatus: matchStatus.
>                         latestSomethingLoaded := cv ] ] ].
> latestSomethingLoaded
>     ifNotNil: [ ^ cache at: cacheKey put: latestSomethingLoaded ].
> ^ cache at: cacheKey put: nil ] in
> MetacelloMCProject(MetacelloProject)>>currentVersionAgainst: in Block: [
> :cache | ...
> [ :dict |
> | cache |
> cache := dict at: cacheName ifAbsent: [  ].
> cache ~~ nil
>     ifTrue: [ | value hasEntry |
>         hasEntry := true.
>         value := cache at: key ifAbsent: [ hasEntry := false ].
>         hasEntry
>             ifTrue: [ ^ value ] ]
>     ifFalse: [ cache := cacheClass new.
>         dict at: cacheName put: cache ].
> ^ aBlock value: cache ] in
> IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
> in Block: [ :dict | ...
> [ ^ aBlock value: dict ] in
> IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
> in Block: [ ^ aBlock value: dict ]
> BlockClosure>>on:do:
> IceMetacelloPharoPlatform(MetacelloPlatform)>>useStackCacheDuring:defaultDictionary:
> IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:cacheClass:at:doing:
> IceMetacelloPharoPlatform(MetacelloPlatform)>>stackCacheFor:at:doing:
> MetacelloMCProject(MetacelloProject)>>currentVersionAgainst:
> [ :cache |
> cv := self currentVersionAgainst: nil.
> ^ cache at: cacheKey put: cv ] in
> MetacelloMCProject(MetacelloProject)>>currentVersion in Block: [ :cache |
> ...
>
> --
> Dr. Geo
> http://drgeo.eu
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: How to #currentVersion from a Configuration

HilaireFernandes
May be old ConfigurationOf breaks on some part

I only added a baseline to my configuration:

baseline1801: spec
     <version: '18.01-baseline'>

     spec for: #common do: [
         spec blessing: #baseline;
             repository: repoPath;
             description: 'Dr. Geo, an interactive geometry application.';
             author: 'HilaireFernandes'.

         spec project: 'XML Parser' with: [
             spec className: 'ConfigurationOfXMLSupport';
             version: '1.0.1';
             loads: #('default');
             file: 'ConfigurationOfXMLSupport';
             repository: repoPath].

         spec
repository:'http://smalltalkhub.com/mc/PharoExtras/Gettext/main/';
             package: 'Gettext' with: 'Gettext-EstebanLorenzano.35'.

         spec package: 'DrGeoII-Core' with: [spec requires: #('XML
Parser' 'Gettext')].

         spec group: 'release' with: #('DrGeoII-Core' 'DrGeo-French'
'DrGeoII-Polymorph' 'DrGeoII-User' 'DrGeoII-Installer');
             group: 'default' with: 'release';
             group: 'development' with: #('release' 'DrGeoII-Test').

         ]

And modified its initialize so it looks to the tonel repo:

initialize
     super initialize.
     repoPath := 'tonel://', SmalltalkImage current imageDirectory
pathString, '/src'


Le 02/04/2018 à 19:55, Stephane Ducasse a écrit :

> In my pharo 6.1 image I have
>
> currentVersion
> | cacheKey cv |
> cacheKey := self configuration class.
> ^ MetacelloPlatform current
> stackCacheFor: #currentVersion
> at: cacheKey
> doing: [ :cache |
> cv := self currentVersionAgainst: nil.
> ^ cache at: cacheKey put: cv ]
>
> And we do not change the code that Dale release and he is making sure
> that old code is working so this is strange.
>
> Stef
>

--
Dr. Geo
http://drgeo.eu