Skip to content
This repository

nested `version:imports:` cause trouble #111

Closed
dalehenrich opened this Issue August 29, 2012 · 0 comments

1 participant

Dale Henrichs
Dale Henrichs
Owner

The ConfigurationOfSeaside30 for version 3.1 started using nested imports quite extensively:

baseline310welcome: spec
    <version: '3.1.0-welcome-baseline' imports: #('3.1.0-common-baseline' '3.1.0-adaptors-baseline' '3.1.0-rss-baseline' '3.1.0-jqueryui-baseline' '3.1.0-ob-baseline' '3.1.0-comet-baseline')>
baseline310adaptors: spec
    <version: '3.1.0-adaptors-baseline' imports: #('3.1.0-pharo-baseline')>
baseline310common: spec
    <version: '3.1.0-common-baseline'>

The algorithm for resolving imports was terminating early...and the following fixes the bug:

collectAllVersionsFromVersionImportPragmasInto: versionMap using: executionBlock satisfiedPragmas: pragmaDict
    | defined done completed count |
    done := false.
    completed := IdentitySet new.
    count := 0.
    [ 
    count := count + 1.
    count > 10000
        ifTrue: [ self error: 'Apparent loop in import expansion' ].
    done ]
        whileFalse: [ 
            done := true.
            pragmaDict
                keysAndValuesDo: [ :versionString :pragmaColl | 
                    | versionSpec |
                    versionSpec := nil.
                    defined := false.
                    [ 
                    pragmaColl
                        do: [ :pragma | 
                            (completed includes: pragma)
                                ifFalse: [ 
                                    | imports |
                                    done := false.
                                    imports := pragma argumentAt: 2.
                                    imports
                                        detect: [ :importedVersion | (versionMap includesKey: importedVersion) not ]
                                        ifNone: [ 
                                            imports
                                                do: [ :importedVersion | 
                                                    | version |
                                                    (version := versionMap at: importedVersion ifAbsent: [  ]) ~~ nil
                                                        ifTrue: [ 
                                                            defined := true.
                                                            completed add: pragma.
                                                            versionSpec == nil
                                                                ifTrue: [ versionSpec := version spec copy ]
                                                                ifFalse: [ versionSpec := versionSpec mergeSpec: version spec copy ].
                                                            versionSpec versionString: versionString.
                                                            executionBlock value: versionSpec value: pragma ] ] ] ] ] ]
                        on: Error
                        do: [ :ex | 
                            (MetacelloErrorInProjectConstructionNotification versionString: versionSpec versionString exception: ex)
                                ifTrue: [ ^ ex pass ]
                                ifFalse: [ 
                                    self errorMap at: versionSpec versionString put: ex.
                                    done := true.
                                    defined := false ] ].
                    defined
                        ifTrue: [ 
                            | version importedVersions |
                            importedVersions := OrderedCollection new.
                            version := versionSpec createVersion.
                            pragmaColl do: [ :pragma | importedVersions addAll: (pragma argumentAt: 2) ].
                            version importedVersions: importedVersions.
                            self validateVersionString: versionString againstSpec: versionSpec.
                            versionMap at: versionSpec versionString put: version ].
                    self reset ] ]
Dale Henrichs dalehenrich referenced this issue from a commit September 05, 2012
Issue #111: add test case bc46403
Dale Henrichs dalehenrich referenced this issue from a commit September 06, 2012
Issue #111: proposed bugfix
correctly process nested import statements
  original algorithm would only process one of the imports in the list
  before marking the version as complete ... can't process a version
  until all imports are defined ...
  implemented rudimentary loop detection
remove a Grease Core Reference in test configuration
66ba1b4
Dale Henrichs dalehenrich closed this September 06, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.