[Monticello2] Loading from a repository
cputney at wiresong.ca
Mon Jul 16 18:13:04 UTC 2007
On Jul 16, 2007, at 8:40 AM, Damien Cassou wrote:
> Hi Colin and Avi,
> I'm not sure how to load data from a repository into the image.
> Currently, I have something like:
> | snapshot versions |
> snapshot := selectedMemo getSnapshotFrom: repository.
> versions := snapshot getVersionsFrom: repository.
> versions do: [:version | MDWorkingCopy default loadVersion: version]
> Is that the right way of loading?
No, you need to have a slice do the loading. Here's some code to save
and then reload a snapshot:
"Create a working copy and repository"
wc := MDWorkingCopy forImageProxy: MDWorkingCopy defaultImageProxy.
memory := MDMemoryRepository new.
"Create a slice"
slice := MDPackageInfoSlice named: 'Refactory'.
snapshot := slice saveFrom: wc to: memory.
slice load: snapshot from: memory to: wc.
> The problem with this approach is when a class A contain a method m1
> in the image, but you are loading a version which does not contain
> this method because it has been removed. Then, the method is not
> removed from the image.
Right. That's why you need the slice. It knows what elements in the
image belong to the slice, so it can compare with the snapshot to see
what should be removed.
More information about the Squeak-dev