[squeak-dev] Squeak 4.6: MonticelloConfigurations-dtl.140.mcz

commits at source.squeak.org commits at source.squeak.org
Sat Oct 17 16:42:44 UTC 2015


David T. Lewis uploaded a new version of MonticelloConfigurations to project Squeak 4.6:
http://source.squeak.org/squeak46/MonticelloConfigurations-dtl.140.mcz

==================== Summary ====================

Name: MonticelloConfigurations-dtl.140
Author: dtl
Time: 12 October 2015, 7:46:53.2 pm
UUID: f0c437d3-fe3c-439e-a59c-632bf1a8eab2
Ancestors: MonticelloConfigurations-dtl.139

Allow mutliple update streams per repository. Register a different updater for each repository / update map name, such that each instance can keep track of its own lastUpdateMap. An updater knows how to register and unregister itself. The default updater for the system is specified by preferences, and new updaters are created as needed by a preference change.

=============== Diff against MonticelloConfigurations-dtl.139 ===============

Item was changed:
  Object subclass: #MCMcmUpdater
+ 	instanceVariableNames: 'repository updateMapName lastUpdateMap'
+ 	classVariableNames: 'DefaultUpdateMap DefaultUpdateURL Registry SkipPackages UpdateFromServerAtStartup UpdateMissingPackages Updaters'
- 	instanceVariableNames: 'updateMapName lastUpdateMap'
- 	classVariableNames: 'DefaultUpdateURL SkipPackages UpdateFromServerAtStartup UpdateMissingPackages Updaters'
  	poolDictionaries: ''
  	category: 'MonticelloConfigurations'!
  
+ !MCMcmUpdater commentStamp: 'dtl 10/12/2015 19:45' prior: 0!
- !MCMcmUpdater commentStamp: 'dtl 8/28/2015 22:07' prior: 0!
  MCMcmUpdater provides utility methods for updating Monticello packages from Monticello configurations.
  
  When Monticello configurations are stored in a repository (or repositories), MCMcmUpdater acts as an update stream. It first ensures that each configuration map has been loaded in sequence, then updates the last configuration map to the most recent version for each specified package, and finally loads these versions to produce a fully updated configuration.
  
  Currently if a set of packages are unloaded from the image, using this class to reload them may cause problems, depending on what dependencies those classes have.  Success is not assured.  Removing packages via SmalltalkImage>>unloadAllKnownPackages will be successful, it flags the packages removed so that they are not loaded by this utility.
  
  If you wish to not have MCMcmUpdater update packages, there are two ways to handle this:
  
  1) To have MCMcmUpdater not update any packages not currently in the image set the UpdateMissingPackages preference to false:
  		MCMcmUpdater updateMissingPackages: false
  	Note that any new packages added to the repositories will not be picked up when this is turned off.
  2) To have MCMcmUpdater not update a specific package, evaluate
  		MCMcmUpdater disableUpdatesOfPackage: <packageName>
  
  Class Variables definitions:
  
  DefaultUpdateURL - String: the URL that will be checked by default for updates.  This would be set for a common standard location to check.
  
+ Repository - A registry of known MCMcmUpdater instances identified by repository URL and update map name.
- Updaters - A dictionary of MCMcmUpdater instances keyed by repository URL.
  
  SkipPackages - Set of Strings: names of packages to not update in MCMcmUpdater (empty by default).
  
  UpdateMissingPackages - Boolean: if true (default), new packages in the update config map will be loaded unless they are in SkipPackages.  If false, packages not currently loaded in the image will not be loaded by MCMcmUpdater.  (This can be dangerous if packages are split - use at your own risk).
  
  Instance Variables:
  
  updateMapName - Base name of the files used for this updater, typically a name such as 'update' or 'update.spur'.
  
+ repository - URL of the repository in which the update maps are located.
+ 
  lastUpdateMap - Dictionary of Integer: version number of the last loaded update map per repository.  Keeps track of the last configuration map, so that the utility will not have to run through the full history in the repositories each time you ask to update.
  !

Item was added:
+ ----- Method: MCMcmUpdater class>>clearRegistry (in category 'class initialization') -----
+ clearRegistry
+ 	"Save the current default updater, clear the registry, and re-register the current updater.
+ 	This is intended for cleaning up an image prior to public release. Assumes that the
+ 	current updater is the one intended for ongoing use in this image."
+ 
+ 	"MCMcmUpdater clearRegistry"
+ 
+ 	| current |
+ 	current := self default.
+ 	Registry := nil.
+ 	current register.
+ 	^Registry!

Item was changed:
  ----- Method: MCMcmUpdater class>>default (in category 'instance creation') -----
  default
+ 	"The default instance for system updates. Uses a default repository and update map
+ 	name that may be set as preferences."
- 	"The default instance for system updates. Uses a default update map
- 	name that may be set as a preference to enable a specific update stream
- 	for a repository."
  
+ 	^self updateMapNamed: self updateMapName repository: self defaultUpdateURL
+ !
- 	^ self updaters
- 		at: self defaultUpdateURL
- 		ifAbsentPut: [self updateMapNamed: 'update' ]!

Item was added:
+ ----- Method: MCMcmUpdater class>>forRepository:updateMap: (in category 'registry') -----
+ forRepository: repository updateMap: basename
+ 	"Answer the requested updater from the repository, or nil of not found"
+ 
+ 	"MCMcmUpdater forRepository: 'http://source.squeak.org/trunk' updateMap: 'update'"
+ 	"MCMcmUpdater forRepository: 'foo' updateMap: 'bar'"
+ 
+ 	^ ((Registry ifNil: [Registry := Dictionary new])
+ 		at: repository
+ 		ifAbsent: [^nil])
+ 			at: basename
+ 			ifAbsent: [^nil]!

Item was changed:
  ----- Method: MCMcmUpdater class>>initialize (in category 'class initialization') -----
  initialize
  	"MCMcmUpdater initialize"
+ 
+ 	self flag: #TODO. "remove Updaters class var after transition to Registry"
+ 
  	DefaultUpdateURL ifNil:[
  		DefaultUpdateURL := MCHttpRepository trunkUrlString.
+ 		DefaultUpdateMap := self defaultBaseName.
  	].
+ 
+ 	Registry ifNil: [ "Migrate from Updaters class var to Registry"
+ 		"Set new repository ivar in all existing instances"
+ 		Updaters keysAndValuesDo: [ :k :v | v repository: k].
+ 		"Populate the new registry"
+ 		Updaters do: [:e | e register].
+ 		"Set the default update map name to its prior value"
+ 		self updateMapName:
+ 			((Updaters at: MCMcmUpdater defaultUpdateURL) updateMapName) ].
+ !
- 	"Call
- 		MCMcmUpdater resetUpdaters
- 	manually if necessary"!

Item was added:
+ ----- Method: MCMcmUpdater class>>repository:updateMap: (in category 'instance creation') -----
+ repository: url updateMap: baseName
+ 	"Answer a new instance with empty last update map, not yet registered"
+ 
+ 	^ self repository: url updateMap: baseName lastUpdateMap: Dictionary new!

Item was added:
+ ----- Method: MCMcmUpdater class>>repository:updateMap:lastUpdateMap: (in category 'instance creation') -----
+ repository: url updateMap: baseName lastUpdateMap: dictionary
+ 	"Answer a new instance, not yet registered"
+ 
+ 	^ self new
+ 		repository: url;
+ 		updateMapName: baseName;
+ 		lastUpdateMap: dictionary!

Item was removed:
- ----- Method: MCMcmUpdater class>>resetUpdaters (in category 'class initialization') -----
- resetUpdaters
- 
- 	Updaters := nil.!

Item was removed:
- ----- Method: MCMcmUpdater class>>updateFromDefaultRepository (in category 'updating') -----
- updateFromDefaultRepository
- 	"Update from the default repository only"
- 
- 	^ self default updateFromDefaultRepository
- !

Item was removed:
- ----- Method: MCMcmUpdater class>>updateFromRepositories:using:baseName: (in category 'updating') -----
- updateFromRepositories: repositoryUrls using: updaterUrlKey baseName: baseName
- 	"Update all repositoryUrls using an MCMcmUpdater identified by updaterUrlKey, and
- 	using update map baseName"
- 
- 	^ (self updateMapNamed: baseName repository: updaterUrlKey)
- 		updateFromRepositories: repositoryUrls!

Item was changed:
  ----- Method: MCMcmUpdater class>>updateFromRepository:baseName: (in category 'updating') -----
  updateFromRepository: updaterUrlKey baseName: baseName
  	"Update using an MCMcmUpdater identified by updaterUrlKey, and using
  	update map baseName"
  
  	^ (self updateMapNamed: baseName repository: updaterUrlKey)
+ 		doUpdate!
- 		updateFrom: updaterUrlKey!

Item was changed:
  ----- Method: MCMcmUpdater class>>updateFromServer (in category 'updating') -----
  updateFromServer
  	"Update the image by loading all pending updates from the server."
  
+ 	^self default doUpdate
- 	^self default updateFrom: self defaultUpdateURL
  !

Item was changed:
  ----- Method: MCMcmUpdater class>>updateMapName (in category 'preferences') -----
  updateMapName
  	"The default update map name"
  
  	<preference: 'Update map name'
  		category: 'updates'
  		description: 'Base name for the update maps'
  		type: #String>
  
+ 	^DefaultUpdateMap ifNil:['']!
- 	^ self default updateMapName
- !

Item was changed:
  ----- Method: MCMcmUpdater class>>updateMapName: (in category 'preferences') -----
  updateMapName: mapName 
+ 	"The default update map name for the default updater."
- 	"The default update map name for the default updater. If this is changed,
- 	then the default updater must be replaced because its remembered position
- 	in the update map sequence will not be valid for the new update map."
  
+ 	DefaultUpdateMap := mapName!
- 	self default updateMapName = mapName
- 		ifFalse: [(self confirm: 'Initializing updater for ' , DefaultUpdateURL , ' to use new update stream ' , mapName)
- 				ifTrue: [self updaters
- 						at: self defaultUpdateURL
- 						put: (self updateMapNamed: mapName)]]!

Item was removed:
- ----- Method: MCMcmUpdater class>>updateMapNamed: (in category 'instance creation') -----
- updateMapNamed: baseName
- 	"Answer a new instance with a base update name baseName such as
- 	'update' or 'update.oscog' "
- 
- 	^ self new
- 		updateMapName: baseName;
- 		lastUpdateMap: Dictionary new!

Item was changed:
  ----- Method: MCMcmUpdater class>>updateMapNamed:repository: (in category 'instance creation') -----
  updateMapNamed: baseName repository: url
+ 	"Answer an instance for the given repository URL with a base update name baseName,
+ 	Register a new instance if not present in the registry."
- 	"Answer an instance for the given repository URL with a base update name
- 	baseName. The instance will be updated in the Updaters dictionary if baseName
- 	has changed."
  
+ 	" | updater1 updater2 |
+ 	updater1 := self updateMapNamed: 'BAR' repository: 'FOO'.
+ 	updater2 := self updateMapNamed: 'BAZ' repository: 'FOO'.
+ 	updater1 unregister.
+ 	updater2 unregister.
+ 	Registry"
+ 
+ 	^(self forRepository: url updateMap: baseName)
+ 		ifNil: [ "register a new updater"
+ 			(self repository: url updateMap: baseName) register].
+ 
- 	| updater |
- 	updater := self updaters at: url ifAbsentPut: [ self updateMapNamed: baseName ].
- 	updater updateMapName = baseName
- 		ifFalse: [ ^ self updaters at: url put: (self updateMapNamed: baseName )].
- 	^ updater
  !

Item was removed:
- ----- Method: MCMcmUpdater class>>updaters (in category 'accessing') -----
- updaters
- 	"A dictionary of updaters, including the system default, indexed by repository URL"
- 
- 	^ Updaters ifNil: [ Updaters := Dictionary new ]!

Item was added:
+ ----- Method: MCMcmUpdater>>doUpdate (in category 'updating') -----
+ doUpdate
+ 	"Update the image by loading all pending updates from the server. If this is
+ 	the default updater for the system, update the system version when complete."
+ 	| config |
+ 	"Flush all caches. If a previous download failed this is often helpful"
+ 	MCFileBasedRepository flushAllCaches.
+ 	config := self updateFromRepositories: { self repository }.
+ 	config ifNil: [^self inform: 'Unable to retrieve updates from remote repository.' translated].
+ 	MCMcmUpdater default == self
+ 		ifTrue: [	config setSystemVersion.
+ 			self inform: ('Update completed.
+ Current update number: ' translated, SystemVersion current highestUpdate).]
+ 		ifFalse: [self inform: 'Update completed.']
+ 	!

Item was added:
+ ----- Method: MCMcmUpdater>>isRegistered (in category 'registry') -----
+ isRegistered
+ 	"True if this instance is registered. False if another instance with the same
+ 	repository and updateNameName is registered."
+ 	
+ 	^self == ((Registry
+ 		at: repository
+ 		ifAbsent: [^false])
+ 			at: updateMapName
+ 			ifAbsent: [^false]).
+ 
+ !

Item was added:
+ ----- Method: MCMcmUpdater>>printOn: (in category 'printing') -----
+ printOn: aStream
+ 
+ 	super printOn: aStream.
+ 	aStream nextPutAll: ' on ''';
+ 		nextPutAll: updateMapName asString;
+ 		nextPutAll:  ''' at ';
+ 		nextPutAll: repository asString!

Item was added:
+ ----- Method: MCMcmUpdater>>register (in category 'registry') -----
+ register
+ 	"Register this instance, keyed by repository and update map name. Each update
+ 	 maintains its own lastUpdateMap. The registry permits multilple updaters to be
+ 	maintained, with each updater keeping track of its own last update map."
+ 	
+ 	repository ifNil: [self error: 'repository is ', repository asString].
+ 	updateMapName ifNil: [self error: 'updateMapName is ', updateMapName asString].
+ 	updateMapName isEmpty ifTrue:  [self error: 'updateMapName must be specified'].
+ 	((Registry ifNil: [Registry := Dictionary new])
+ 		at: repository
+ 		ifAbsentPut: [Dictionary new])
+ 			at: updateMapName put: self
+ 
+ !

Item was added:
+ ----- Method: MCMcmUpdater>>repository (in category 'accessing') -----
+ repository
+ 	"URL string of the repository for the update maps"
+ 
+ 	^ repository!

Item was added:
+ ----- Method: MCMcmUpdater>>repository: (in category 'accessing') -----
+ repository: repositoryURLString
+ 
+ 	repository := repositoryURLString!

Item was added:
+ ----- Method: MCMcmUpdater>>unregister (in category 'registry') -----
+ unregister
+ 	"If this instance is registered, remove it frorm the registry."
+ 	
+ 	self isRegistered
+ 		ifTrue: [(Registry at: repository) removeKey: updateMapName.
+ 				(Registry at: repository) isEmpty
+ 					ifTrue: [Registry removeKey: repository]]
+ !

Item was removed:
- ----- Method: MCMcmUpdater>>updateFrom: (in category 'updating') -----
- updateFrom: url
- 	"Update the image by loading all pending updates from the server. If this is
- 	the default updater for the system, update the system version when complete."
- 	| config |
- 	"Flush all caches. If a previous download failed this is often helpful"
- 	MCFileBasedRepository flushAllCaches.
- 	config := self updateFromRepositories: { url }.
- 	config ifNil: [^self inform: 'Unable to retrieve updates from remote repository.' translated].
- 	MCMcmUpdater default == self
- 		ifTrue: [	config setSystemVersion.
- 			self inform: ('Update completed.
- Current update number: ' translated, SystemVersion current highestUpdate).]
- 		ifFalse: [self inform: 'Update completed.']
- 	!

Item was removed:
- ----- Method: MCMcmUpdater>>updateFromDefaultRepository (in category 'updating') -----
- updateFromDefaultRepository
- 	"Update from the default repository only"
- 	^self updateFromRepositories: {self class defaultUpdateURL}!



More information about the Squeak-dev mailing list