--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MCVersionLoader.st Wed Nov 22 14:13:01 2006 +0100
@@ -0,0 +1,95 @@
+"{ Package: 'stx:goodies/monticello' }"
+
+Object subclass:#MCVersionLoader
+ instanceVariableNames:'versions'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'Monticello-Loading'
+!
+
+
+!MCVersionLoader class methodsFor:'as yet unclassified'!
+
+loadVersion: aVersion
+ self new
+ addVersion: aVersion;
+ load
+!
+
+new
+ ^ self basicNew initialize
+! !
+
+!MCVersionLoader methodsFor:'checking'!
+
+checkForModifications
+ | modifications |
+ modifications _ versions select: [:ea | ea package workingCopy modified].
+ modifications isEmpty ifFalse: [self warnAboutLosingChangesTo: modifications].
+!
+
+checkIfDepIsOlder: aDependency
+ ^ aDependency isOlder not
+ or: [self confirm: 'load older dependency ', aDependency versionInfo name , '?']
+!
+
+confirmMissingDependency: aDependency
+ | name |
+ name := aDependency versionInfo name.
+ (self confirm: 'Can''t find dependency ', name, '. ignore?')
+ ifFalse: [self error: 'Can''t find dependency ', name]
+!
+
+depAgeIsOk: aDependency
+ ^ aDependency isOlder not
+ or: [self confirm: 'load older dependency ', aDependency versionInfo name , '?']
+!
+
+warnAboutLosingChangesTo: versionCollection
+ self notify: (String streamContents: [:s |
+ s nextPutAll: 'You are about to load new versions of the following packages that have unsaved changes in the image. If you continue, you will lose these changes.'; cr.
+ versionCollection do:
+ [:ea |
+ s cr; space; space; nextPutAll: ea package name]])
+! !
+
+!MCVersionLoader methodsFor:'initialize-release'!
+
+initialize
+ versions _ OrderedCollection new
+! !
+
+!MCVersionLoader methodsFor:'loading'!
+
+addDependency: aDependency
+ | dep |
+ aDependency isCurrent ifTrue: [^ self].
+ (self depAgeIsOk: aDependency) ifFalse: [^ self].
+ dep := aDependency resolve.
+ dep
+ ifNil: [self confirmMissingDependency: aDependency]
+ ifNotNil: [(versions includes: dep) ifFalse: [self addVersion: dep]]
+!
+
+addVersion: aVersion
+ aVersion dependencies do: [ :ea | self addDependency: ea].
+ versions add: aVersion.
+!
+
+load
+ | loader |
+ self checkForModifications.
+ loader _ MCPackageLoader new.
+ versions do: [:ea |
+ ea canOptimizeLoading
+ ifTrue: [ea patch applyTo: loader]
+ ifFalse: [loader updatePackage: ea package withSnapshot: ea snapshot]].
+ loader loadWithNameLike: versions first info name.
+ versions do: [:ea | ea workingCopy loaded: ea]
+! !
+
+!MCVersionLoader class methodsFor:'documentation'!
+
+version
+ ^ '$Header: /cvs/stx/stx/goodies/monticello/MCVersionLoader.st,v 1.1 2006-11-22 13:13:01 cg Exp $'
+! !