Usman,

Well I don't have an official bugfix yet, but if you filein the attached method and run the following, PetitParser will downgrade and get loaded correctly (at least it worked for me)...The fist two statements are intended to replace GTMetacelloPlatform with MetacelloPharo30Platform and initialize the registry correctly ... not sure what impact on Moose these changes will have) :

MetacelloPharo30Platform initialize.
  [
  MetacelloProjectRegistration
    resetRegistry;
    primeRegistryFromImage ]
    on: Warning
    do: [ :ex |
      Transcript
        cr;
        show: 'Warning resumed: ' , ex description.
      ex resume ].
Metacello new
    configuration: 'DummyParser';
    version: '1.0';
    repository: '???';
    onDowngrade: [:ex :existing :new |
        existing projectName = 'PetitParser'
            ifTrue: [
                new projectSpec operator: #=.
                ex allow ]
            ifFalse: [ ex disallow ] ]  ;
    load.

The new method will be part of the next Metacello release and has been tested[1], but I may take a slightly different approach with the official bugfix. Setting the operator achieves the desired result, but is not quite how I would like to address the issue.

HTH,

Dale

[1] https://travis-ci.org/dalehenrich/metacello-work/builds/46640819
On 1/8/15 12:32 AM, Usman Bhatti wrote:


On Wed, Jan 7, 2015 at 8:25 PM, Dale Henrichs <dale.henri...@gemtalksystems.com <mailto:dale.henri...@gemtalksystems.com>> wrote:

    Usman,

    No, I appreciate your patience:) If creating your own
    configuration works for you then that is a good route to go...


    Sharing your image will make it much easier for me to get the
    bottom of this (on my own schedule:), so please send me a link for
    accessing your image and I'll dig into this in more detail when I
    have time ...


Here is the image.
https://dl.dropboxusercontent.com/u/11804892/downgrade-with-metacello.zip

You just need to execute the script in the workspace/playground to reproduce the problem (i.e. launching the directive to load PP 1.51 and that not happening).


    If you find yourself stuck and needing the `downgrade directive`
    again, I'll bump up the priority ...


I can still wait till next week. If you could have a look by then, it'll be great.
tx.
Usman



    Dale


    On 01/07/2015 09:19 AM, Usman Bhatti wrote:


    On Tue, Jan 6, 2015 at 6:56 PM, Dale Henrichs
    <dale.henri...@gemtalksystems.com
    <mailto:dale.henri...@gemtalksystems.com>> wrote:


        On 1/6/15 7:16 AM, Usman Bhatti wrote:
        Dale,

        I couldn't make it work with the upgraded Metacello and the
        script you provided.

        Steps I did:

        1. Download moose image:
        https://ci.inria.fr/moose/job/moose-5.0/

        2. Update my Metacello to the 'full' version:
        Metacello new
          baseline: 'Metacello';
          repository:
        'github://dalehenrich/metacello-work:master/repository';
          get.
        Metacello new
          baseline: 'Metacello';
          repository:
        'github://dalehenrich/metacello-work:master/repository';
          onConflict: [:ex | ex allow];
          load

        3. File in the ConfigurationOfDummyParser (see the first
        message in the thread).

        4.  Run this script to downgrade to PetitParser version 1.51

        Metacello new
        configuration: 'DummyParser';
        version: '1.0';
        repository: '???';
        onDowngradeUseIncoming: #('PetitParser');
        load.

        The desired version is still not loaded, am I missing
        something here?
        Good question, I don't have a lot of time today to spend time
        trying to reproduce your problem, but if you send me a copy
        of the Transcript produced while doing the load I might be
        able to spot the problem ...


    It looks to me that the downgrade command is not working.
    Whenever I point to the version preceding the one loaded, the
    packages are not fetched.

    I am attaching here two files.

    The first (Transcript-PP151) is the output of the transcript as
    you asked. You can see that PetitParser packages as defined by
    the version 1.51 are not fetched. All that is loaded is Glamour
    because the version 1.51 of PetitParser loads the latest packages
    of Glamour. The load works because it is an upgrade from the
    current version of Glamour which is a stable.

    When I saw that only Glamour packages are loaded, I thought of
    testing Glamour downgrade too to see if the problem is specific
    to PetitParser. You can see the result in the second file
    (Transcript-downgrade-glamour). No packages of Glamour are
    fetched because the configuration tries to downgrade it (stable
    is more recent than 3.0.0 which I try to load).

    In my opinion, downgrade is not working as required. If you want
    I can share my image thru dropbox so that you can have a look to
    see what might be wrong.



        regards,

        A question: I always use Metacello with ConfigOf and have
        never used the scripting API myself or saw it being used
        elsewhere.
        Can you provide a link that describes the use cases for
        both: ConfigOf vs. Scripting API?
        I've noticed the same thing:)

        My "elevator pitch" for the script api goes like this:
          1. The scripting api maintains a registry of the actual
        project versions loaded into the image,
              making #currentVersion obsolete. #currentVersion is bad
        because it does a calculation of
              the current version that can be very slow and sometimes
        completely incorrect.
           2. The old api has rules that it follows when loading
        projects (i.e., newer projects always win) and
               there is no mechanism for altering those rules. The
        scripting api provides mechanisms for
               for bending those rules to fit your needs ... like
        allowing a downgrade of a project.

        Part of the reason that people haven't changed has to do with
        how incredibly difficult it is to change the existing
        inertia. Another part of it is that I continue to support the
        old way of doing things, so there is no explicit motivation
        to change.

        If you look back 2-3 years in the archives of the Metacello
        mailing list[1] you should be able to find a number of posts
        where I make a more detailed cases for the scripting api:)

        At the end of the day, it isn't important to me to "get
        people to use the scripting api," as I said, I continue to
        support using the old api. I figure that when enough people
        start asking questions about how to "bend the Metacello
        rules" that folks will begin to use the "new" scripting api:)


    So, what I learn is that I am trying to bend the rules of
    Metacello which is a rare use case :). I am thinking of avoiding
    this downgrading altogether by forking to create my own ConfigOf
    that loads the correct versions. Downgrading might be an
    anti-pattern.

    Thank you for your patient so far :)

    regards.


        Dale
        [1] https://groups.google.com/forum/#!forum/metacello
        <https://groups.google.com/forum/#%21forum/metacello>





'From Pharo3.0 of 18 March 2013 [Latest update: #30862] on 11 January 2015 at 
10:01:20.462243 am'!

!MetacelloProjectSpecForLoad methodsFor: 'operations' stamp: 'dkh 1/11/2015 
08:30'!
performCurrentVersionTestAgainst: vrsn operator: anOperator 
targetVersionStatus: targetVersionStatus using: anMCLoader
  "answer true if the current state of image is to be left as is"

  | currentVersion existing new |
  vrsn ifNil: [ ^ false ].
  self useDetermineVersionForLoad
    ifTrue: [ 
      | prjct cv |
      self hasOverride
        ifTrue: [ 
          self
            error:
              'unexpected logic combination: useDeterminVersionForLoad & 
hasOverride' ].
      prjct := self projectSpec projectClassProject.
      prjct loader: anMCLoader.
      (cv := prjct currentVersion) == nil
        ifTrue: [ ^ false ].
      (targetVersionStatus includes: cv versionStatus)
        ifTrue: [ ^ cv perform: anOperator with: vrsn ].
      ^ false ].
  (self hasOverride not or: [ targetVersionStatus ~= #(#'allLoadedToSpec') ])
    ifTrue: [ ^ false ].
  (self overrideProjectSpec allPackagesLoaded: anMCLoader)
    ifFalse: [ 
      "roughly equivalent to versionStatus test above (#'allLoadedToSpec')"
      ^ false ].
  (self overrideProjectSpec
    isPartiallyLoaded: self overrideProjectSpec copy loader)
    ifFalse: [ 
      "if the project is not loaded at all"
      ^ false ].
  (currentVersion := self overrideProjectSpec versionOrNil) ifNil: [ ^ false ].
  currentVersion = vrsn
    ifTrue: [ 
      "same version but are they equal"
      ^ self projectSpec compareEqual: self overrideProjectSpec ].
  existing := self overrideProjectSpec asProjectRegistration.
  new := self projectSpec asProjectRegistration.
  ^ currentVersion > vrsn
    ifTrue: [ 
      "answer false if downgrade allowed"
      (MetacelloAllowProjectDowngrade new
        existingProjectRegistration: existing;
        newProjectRegistration: new;
        signal) == existing ]
    ifFalse: [ 
      "answer false if upgrade allowed"
      (MetacelloAllowProjectUpgrade new
        existingProjectRegistration: existing;
        newProjectRegistration: new;
        signal) == existing ]! !

Reply via email to