Add utility method to export St/X package to Monticello repository jv
authorJan Vrany <jan.vrany@labware.com>
Mon, 29 Jun 2020 13:44:49 +0100
branchjv
changeset 1102 60e2741ec859
parent 1101 7bde46284ee7
child 1103 57970b950ba4
Add utility method to export St/X package to Monticello repository
extensions.st
stx_goodies_monticello.st
--- a/extensions.st	Mon Jun 29 13:43:38 2020 +0100
+++ b/extensions.st	Mon Jun 29 13:44:49 2020 +0100
@@ -1,5 +1,21 @@
 "{ Package: 'stx:goodies/monticello' }"!
 
+!AbstractSourceCodeManager class methodsFor:'accessing'!
+
+monticelloVersionInfoForPackage: package
+    "Return Monticello version info (a kind og MCVersionInfo)
+     for given package. 
+
+     If this source code manager does not support exporting
+     to Monticello, throw an error.
+    "
+    self error: ('%1 does not know how to create Monticello version info for %2'
+                    bindWith: self name
+                        with: package)
+
+    "Created: / 29-06-2020 / 13:04:15 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
 !Annotation class methodsFor:'instance creation'!
 
 mctimestamp: aString
@@ -134,6 +150,36 @@
     "Created: / 29-05-2013 / 01:08:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!ProjectDefinition class methodsFor:'exporting'!
+
+exportToMonticello:anMCRepository 
+    "Export currently loaded revision of this package 
+     to given Monticello repository."
+    
+    | mcpkg mcwc mcvi mcversion |
+
+    Class tryLocalSourceFirst:true.
+    mcpkg := MCPackage named:self package.
+    mcwc := mcpkg workingCopy.
+    mcvi := self monticelloVersionInfo.
+    [
+        mcversion := mcwc newVersion.
+        mcversion snapshot options includeExtrasForSTX:true.
+    ] on:MCVersionNameAndMessageRequest
+            do:[:ex | ex resume:(Array with:mcvi name with:mcvi message) ].
+    mcversion info:mcvi.
+    anMCRepository storeVersion:mcversion.
+    ^ mcversion
+
+    "
+    jv_libgdbs exportToMonticello: (MCDirectoryRepository directory:'/tmp/mc')
+    labware_machinearithmetic exportToMonticello: (MCDirectoryRepository directory:'/tmp/mc')
+    "
+
+    "Created: / 24-06-2020 / 22:45:34 / Jan Vrany <jan.vrany@labware.com>"
+    "Modified (comment): / 29-06-2020 / 13:24:04 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
 !ProjectDefinition class methodsFor:'code generation'!
 
 monticelloAncestry_code
@@ -200,11 +246,13 @@
 
 monticelloNameForMCZ
     "Return the name of package used to build .mcz file.
-     Defaults to sanitized monticelloName"
+
+     Override if needed. Defaults to sanitized monticelloName"
 
     ^self monticelloName asString copy replaceAll: $/ with: $_; replaceAll: $: with: $_
 
     "Created: / 07-06-2013 / 01:48:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 29-06-2020 / 13:11:52 / Jan Vrany <jan.vrany@labware.com>"
 ! !
 
 !ProjectDefinition class methodsFor:'accessing - monticello'!
@@ -221,10 +269,14 @@
 
      The format of splicemap is a flat array of pairs 
      (commit id, MCVersionInfo to splice) as literal encoding.
+
+     Override if needed and append an entry each time a 'foreign'
+     Monticello version is merged in.
     "
     ^#()
 
     "Created: / 07-09-2015 / 18:11:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified (comment): / 29-06-2020 / 13:13:13 / Jan Vrany <jan.vrany@labware.com>"
 ! !
 
 !ProjectDefinition class methodsFor:'code generation'!
@@ -328,6 +380,26 @@
     "Created: / 09-11-2010 / 18:27:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!ProjectDefinition class methodsFor:'accessing - monticello'!
+
+monticelloVersionInfo
+    "Return Monticello version info (a kind og MCVersionInfo)
+     for this package.
+
+     This method is used by #exportToMonticello: Do not override.
+    "
+    | scm |
+
+    scm := AbstractSourceCodeManager managerForPackage: self package.
+    ^ scm monticelloVersionInfoForPackage: self package.
+
+    "
+    jv_libgdbs monticelloVersionInfo
+    "
+
+    "Created: / 29-06-2020 / 12:56:46 / Jan Vrany <jan.vrany@labware.com>"
+! !
+
 !SequenceableCollection methodsFor:'*monticello-squeakCompatibility'!
 
 copyReplaceAll: oldSubstring with: newSubstring asTokens: ifTokens
--- a/stx_goodies_monticello.st	Mon Jun 29 13:43:38 2020 +0100
+++ b/stx_goodies_monticello.st	Mon Jun 29 13:44:49 2020 +0100
@@ -1,3 +1,6 @@
+"
+COPYRIGHT (c) 2020 LabWare
+"
 "{ Package: 'stx:goodies/monticello' }"
 
 "{ NameSpace: Smalltalk }"
@@ -11,6 +14,13 @@
 
 !stx_goodies_monticello class methodsFor:'documentation'!
 
+copyright
+"
+COPYRIGHT (c) 2020 LabWare
+
+"
+!
+
 documentation
 "
     Package documentation:
@@ -38,12 +48,13 @@
      are extended by myself.
      They are mandatory, because we need these packages as a prerequisite for loading and compiling.
      This method is generated automatically,
-     by searching along the inheritance chain of all of my classes."
+     by searching along the inheritance chain of all of my classes.
+     Please take a look at the #referencedPreRequisites method as well."
 
     ^ #(
         #'stx:libbasic'    "AbstractTime - extended"
-        #'stx:libbasic3'    "AbstractSourceCodeManager - superclass of MCSourceCodeManager"
-        #'stx:libcompat'    "ListItemWrapper - superclass of MCDependentsWrapper"
+        #'stx:libbasic3'    "AbstractSourceCodeManager - extended"
+        #'stx:libcompat'    "PackageInfo - extended"
         #'stx:libtool'    "AbstractSettingsApplication - superclass of MCSettingsApp"
         #'stx:libview2'    "ApplicationModel - extended"
         #'stx:libwidg2'    "AbstractHierarchicalItem - superclass of MCPackageEntry"
@@ -53,12 +64,13 @@
 referencedPreRequisites
     "list packages which are a prerequisite, because they contain
      classes which are referenced by my classes.
-     We do not need these packages as a prerequisite for compiling or loading,
+     These packages are NOT needed as a prerequisite for compiling or loading,
      however, a class from it may be referenced during execution and having it
      unloaded then may lead to a runtime doesNotUnderstand error, unless the caller
      includes explicit checks for the package being present.
      This method is generated automatically,
-     by searching all classes (and their packages) which are referenced by my classes."
+     by searching all classes (and their packages) which are referenced by my classes.
+     Please also take a look at the #mandatoryPreRequisites method"
 
     ^ #(
         #'stx:goodies/communication'    "FTPClient - referenced by MCFtpRepository>>clientDo:"
@@ -99,7 +111,6 @@
         MCDefinition
         MCDefinitionIndex
         MCDependencySorter
-        (MCDependentsWrapper autoload)
         MCDialog
         MCDirtyPackageInfo
         MCDoItParser
@@ -140,7 +151,6 @@
         MCStxVersionInfo
         MCTimestampAnnotation
         MCTool
-        (MCToolWindowBuilder autoload)
         MCVariableDefinition
         MCVersion
         MCVersionDependency
@@ -181,7 +191,6 @@
         MCRemoval
         MCRepositoryDialog
         MCRepositoryList
-        (MCSaveVersionDialog autoload)
         MCScriptDefinition
         MCSnapshotReader
         MCStWriter
@@ -198,10 +207,8 @@
         MCVersionReader
         MCWorkingAncestry
         MCWorkingCopy
-        (MCWorkingCopyBrowser autoload)
         MCWriteOnlyRepository
         MCDirectoryRepository
-        (MCFileRepositoryInspector autoload)
         MCFtpRepository
         MCHttpRepository
         MCLazyVersionInfo
@@ -212,28 +219,35 @@
         MCPreambleDefinition
         MCRemovalPostscriptDefinition
         MCRemovalPreambleDefinition
-        (MCRepositoryInspector autoload)
-        (MCSMCacheRepository autoload)
         MCSMReleaseRepository
         MCSmtpRepository
-        (MCSnapshotBrowser autoload)
         MCStReader
         MCStxMczWriter
         MCStxStWriter
         MCTraitDefinition
-        (MCWorkingHistoryBrowser autoload)
         MCCacheRepository
-        (MCChangeSelector autoload)
         MCMcdReader
-        (MCMergeBrowser autoload)
         MCStXMczReader
         MCSubDirectoryRepository
+        (MCDependentsWrapper autoload)
+        (MCToolWindowBuilder autoload)
+        (MCSaveVersionDialog autoload)
+        (MCWorkingCopyBrowser autoload)
+        (MCFileRepositoryInspector autoload)
+        (MCRepositoryInspector autoload)
+        (MCSMCacheRepository autoload)
+        (MCSnapshotBrowser autoload)
+        (MCWorkingHistoryBrowser autoload)
+        (MCChangeSelector autoload)
+        (MCMergeBrowser autoload)
     )
 !
 
 extensionMethodNames
-    "list class/selector pairs of extensions.
-     A correponding method with real names must be present in my concrete subclasses"
+    "lists the extension methods which are to be included in the project.
+     Entries are 2-element array literals, consisting of class-name and selector.
+     A correponding method with real names must be present in my concrete subclasses
+     if it has extensions."
 
     ^ #(
         Behavior traitCompositionString
@@ -272,6 +286,9 @@
         'ProjectDefinition class' monticelloSplicemap
         'ProjectDefinition class' #'monticelloSplicemap_code'
         'ProjectDefinition class' #'monticelloSplicemap_codeFor:'
+        'AbstractSourceCodeManager class' monticelloVersionInfoForPackage:
+        'ProjectDefinition class' exportToMonticello:
+        'ProjectDefinition class' monticelloVersionInfo
     )
 ! !