--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MCStXPackageLoader.st Mon Nov 29 15:31:54 2021 +0000
@@ -0,0 +1,114 @@
+"
+COPYRIGHT (c) 2021 LabWare
+"
+"{ Package: 'stx:goodies/monticello' }"
+
+"{ NameSpace: Smalltalk }"
+
+MCPackageLoader subclass:#MCStXPackageLoader
+ instanceVariableNames:'manifests'
+ classVariableNames:''
+ poolDictionaries:''
+ category:'SCM-Monticello-St/X support'
+!
+
+!MCStXPackageLoader class methodsFor:'documentation'!
+
+copyright
+"
+COPYRIGHT (c) 2021 LabWare
+
+
+"
+! !
+
+!MCStXPackageLoader methodsFor:'private'!
+
+postLoad
+ manifests do: [:manifest |
+ manifest
+ activityNotification:('Executing post-load actions for %1' bindWith: manifest package);
+ projectIsLoaded:true.
+
+ Smalltalk changed: #packageLoaded with: manifest.
+ ].
+
+ "Created: / 29-11-2021 / 17:28:13 / Jan Vrany <jan.vrany@labware.com>"
+ "Modified: / 29-11-2021 / 19:55:59 / Jan Vrany <jan.vrany@labware.com>"
+!
+
+preLoad
+ | manifestDefinitions manifestNames |
+
+ "/ Collect all manifests (project definitions) classes...
+ manifestDefinitions := additions select: [:e | e isManifestDefinition ].
+ manifestNames := manifestDefinitions collect: [ :e | e className asSymbol ].
+ "/ ...and methods.
+ manifestDefinitions := manifestDefinitions , (additions select: [ :e | e isMethodDefinition and: [ manifestNames includes: e className ]]).
+
+ "/ Load collected manifests.
+ manifests := OrderedCollection new.
+ [
+ manifestDefinitions do: [:e | self tryToLoad: e] displayingProgress: 'Loading package manifests...'.
+ manifests := manifestNames collect: [:name | Smalltalk at: name ].
+ ] on: InMidstOfFileinNotification do: [:ex |
+ ex resume: true
+ ] ensure: [
+ additions removeAll: manifestDefinitions.
+ self flushChangesFile.
+ ].
+ manifests size > 1 ifTrue: [ self error: 'Loading multiple packages at once is not yet supported' mayProceed: true ].
+
+ "/ Load dependencies and execute pre-load actions...
+ "/ (see ProjectDefinition >> #loadAsAutoloaded: )
+ manifests do: [:manifest |
+ Smalltalk changed: #aboutToLoadPackage with: manifest.
+ Smalltalk silentLoading ifFalse:[Logger info:'loading %1...' with:manifest name].
+
+ manifest
+ activityNotification:('Executing pre-load actions for %1' bindWith: manifest package);
+ executeHooks: #preLoad;
+ preLoadAction.
+ "/ Answering 'nil' means use default package name.
+ MCStXPackageQuery answer: nil do: [
+ manifest loadPreRequisitesAsAutoloaded: false.
+ ]
+ ].
+
+ "Created: / 29-11-2021 / 17:27:34 / Jan Vrany <jan.vrany@labware.com>"
+ "Modified (comment): / 29-11-2021 / 22:26:50 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
+!MCStXPackageLoader methodsFor:'public'!
+
+load
+ self preLoad.
+ super load.
+ self postLoad.
+
+ "Created: / 29-11-2021 / 17:28:44 / Jan Vrany <jan.vrany@labware.com>"
+!
+
+loadWithName: baseName
+ self preLoad.
+ super loadWithName: baseName.
+ self postLoad.
+
+ "Created: / 29-11-2021 / 17:28:59 / Jan Vrany <jan.vrany@labware.com>"
+!
+
+loadWithNameLike: baseName
+ self preLoad.
+ super loadWithNameLike: baseName.
+ self postLoad.
+
+ "Created: / 29-11-2021 / 17:29:15 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
+!MCStXPackageLoader class methodsFor:'documentation'!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
+! !
+