10

The context is this one:
A package had several branches developped in several repositories

  • squeaksource
  • source.squeak.org/trunk

Development stopped in source.squeak.org, and the goal is to transfer the branch back to squeaksource in order to have all versions published in a single repository.
But to ease human browsing and fast identification of the branch, I wish to add a standard branch identification to the name of squeaksource copy.
Is there a way to automate this operation? With Gofer maybe?

MartinW
  • 4,966
  • 2
  • 24
  • 60
aka.nice
  • 9,100
  • 1
  • 28
  • 40
  • Would you add a pseudocode example of the transformation/copy operation... – Sean DeNigris Jun 05 '12 at 23:44
  • My intention was something like:
    Utility copyEveryVersionAfter: 'Universes-ls.39' fromRepository: 'source.squeak.org/trunk' toRepository: 'www.squeaksource.com/universes' withBranchSuffix: 'squeaktrunk'
    – aka.nice Jun 06 '12 at 20:49

2 Answers2

7

Monticello packages are immutable. You can easily move the versions around, but you should not rename the files. If you do, you break the history and loose the ability to merge the versions within your version tree and with other people's contributions.

To move all versions of package A from source url to target url you can use:

Gofer new
   repository: 'source url';
   package: 'A';
   fetch

" If you understand the concequences you could rename/rebranch the version files in your package-cache at this point. "

Gofer new
   repository: 'target url';
   package: 'A';
   push
Lukas Renggli
  • 8,754
  • 23
  • 46
  • Ah, of course, I forgot this feature... The UUID is used only like a checksum, but not for identification purposes, only the name counts. I could of course use versionInfo surgery, or black magic superpower like a oldName becomeForward: newName... – aka.nice Jun 06 '12 at 07:15
  • Yes, that could work if you control all the existing branches of your project. Again keep in mind that any operation (loading, comparing, merging, ...) involving versions not stemming from your branch will require separate black magic again. – Lukas Renggli Jun 06 '12 at 15:28
3

A more arcane solution which avoids subsequent serialization and deserialization of Monticello packages. This is useful for very big repositories and speeds up the copying quite a bit:

| sourceRepositoryUrl destinationRepositoryUrl files |

repositoryUrl := 'http://www.squeaksource.com/PROJECT'.
destinationRepositoryUrl := 'http://smalltalkhub.com/mc/USER/PROJECT/main'.

files := (MCHttpRepository new 
    parseFileNamesFromStream: (ZnClient new get: repositoryUrl; entity) readStream)
    select: [ :each | ZnMonticelloServerDelegate new isValidMczName: each ].

files do: [ :fileName ||entity stream|

    Transcript show: fileName; cr.
    "download version"
    entity := ZnClient new
    beOneShot;
        url: repositoryUrl;
        addPath: fileName;
        get;
        entity.

    "upload the version to gemstone"
    ZnClient new
        beOneShot;
        ifFail: [ :exception | Transcript show: fileName; show: ' '; print: exception ];
        username: 'USER' password: 'PASSWORD';
        entity: entity;
        url: destinationRepositoryUrl;
        addPath: fileName;
        put ]
displayingProgress: [ :fileName| 'Copying ', fileName]
camillobruni
  • 2,298
  • 16
  • 26