links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Magma as a code-repository
Last updated at 6:11 pm UTC on 3 January 2013
Any Magma repository can automatically serve as a Monticello repository, independent of its own persistent domain model. Typically, the code needed to operate on a domain-model should be colocated in the same repository so it is totally self-contained.

Magma as a Monticello Repository

In Magma 1.3 or later, to use the standard Monticello UI with Magma, do the following steps:

  1. In the Monticello window, click the +Repository button.
  2. Select "Magma" from the menu.
  3. Specify the host and port the Magma server is running on.
  4. Save packages to that repository, or click the "Open" button to browse and load from the repository.

Canonicalized Model

One of the problems with traditional file-based Monticello repositories is the redundancy. Even if only one method of a package is changed, a new copy of every method in the package is stored in the new resulting .mcz file. Monticello does support "Diffy" versions in .mcd files as a way to address this, just make sure all ancestors back to the last .mcz are present in the repository or it won't work.

Diffy versions are not needed in a Magma-based repository because the entire code-model is canonicalized. If you only change one method of a package, there is only one new method added to the repository. For all of the other methods, the new package Version maintains pointers to the original MCMethodDefinition instances.

Tool Benefits

Besides the benefits of the canonicalization, and the safety and redundancy afforded by Magma, any methods (or classes) which have definitions in a Magma repository will show two new items on the IDE menus:


"Browse mc versions" instantly shows all versions of that method (or class-definition) available in the repository, regardless of which package Versions they are in.

"Browse mc origin" will open the Version-Inspector of the earliest-known MC Version known to contain that method (or class). If all versions (from 1) are loaded into the Magma repository, it will, in that case be the "origin" of that method, and the comments associated with that Version can often provide useful information about why a change was made.

Optimization Choices

By default, Magma will employ a MagmaPreallocatedDictionary to store the canonicalized Monticello objects (MCDefinitions, MCPackages, etc.). this affords the fastest performance however, because MagmaPreallocatedDictionary's are preallocated, there is an immediate consumption of several hundred megabytes of disk space after just the first version is stored. If this is a problem, Magma can be instructed to use a standard MagmaDictionary instead. To do this:
    mySession mcModelFavorDiskSpaceIfPossible

This can only be done before the McModel inside that Magma repository is established; e.g., before the first version is stored there.

Bulk Loading the Magma-based repository

Loading all versions of packages will allow the full history to be easily browsed.

Use the MCRepository>>#copyAllFrom: method to transfer all package Versions from a source repository to a Magma-based repository. For example:
  (MCMagmaRepository host: 'dev1' port: 32501) 
    copyAllFrom: (MCRepository location: '/path/to/your/file-based/mc/repository')


The following code-snippets show how to store, list, browse, and install changesets to and from a Magma repository.

  "file-out a ChangeSet"
  mySession commit: [ mySession codeBase fileOutChangeSet: (ChangeSorter changeSetNamed: 'myChangeSet') ]

  "Load a ChangeSet"
  mySession codeBase fileInChangeSetNamed: 'myChangeSet'

  "browse a change-set before filing it in"
  mySession codeBase browseChangeSetNamed: 'myChangeSet'

  "Answer a collectioon of all changeSet names in the codeBase."
  mySession codeBase changeSetNames

  "Install all the changeSets in the codeBase immediately."
  mySession codeBase installChangeSets

Individual classes and patches

  "File-out a Class"
  mySession commit: [ mySession codeBase fileOutClass: MyClass ]

  "load a class"
  mySession codeBase fileInClassNamed: #MyClass

  "browse a class in a code-file browser before filing it in"
  mySession codeBase browseClassNamed: #MyClass

  "Answer a collection of all class names in the codeBase"
  mySession codeBase classNames

  "Install all the classes into my image immediately."
  mySession codeBase installClasses