-
Notifications
You must be signed in to change notification settings - Fork 27
Update should check version requirements using post-update values instead of what's currently installed #1120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
65f5826
c74ed86
e698520
7c30ac5
545200b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ ClassMethod LoadModuleReference( | |
|
|
||
| // Ensure requested versions match those required by other modules in the namespace, excluding versions currently being installed | ||
| // (the requirements of such modules are already known to be satisfied) | ||
| set tSC = ..GetRequiredVersionExpression(pModuleName,,.tExpression,.tSourceList) | ||
| set tSC = ..GetRequiredVersionExpression(pModuleName,,.pDependencyGraph,.tExpression,.tSourceList) | ||
| if $$$ISERR(tSC) { | ||
| quit | ||
| } | ||
|
|
@@ -349,36 +349,79 @@ ClassMethod GetModuleObjectFromString( | |
|
|
||
| /// Returns a semantic version expression capturing all version requirements for a given module name in the current namespace. | ||
| /// A list of modules to exclude may be provided (for example, if these modules would be updated at the same time). | ||
| /// | ||
| /// If provided a dependency graph, will use versions defined there instead of what the SQL call returns. | ||
| /// This is especially important for the update command, where we want to check requirements with post-update versions as opposed to what's currently installed. | ||
| ClassMethod GetRequiredVersionExpression( | ||
| pModuleName As %String, | ||
| pExcludeModules As %List = "", | ||
| Output pExpression As %IPM.General.SemanticVersionExpression, | ||
| Output pSourceList As %List) As %Status | ||
| moduleName As %String, | ||
| excludeModules As %List = "", | ||
| ByRef dependencyGraph, | ||
| Output expression As %IPM.General.SemanticVersionExpression, | ||
| Output sourceList As %List) As %Status | ||
| { | ||
| set tSC = $$$OK | ||
| set sc = $$$OK | ||
| try { | ||
| set pExpression = ##class(%IPM.General.SemanticVersionExpression).%New() | ||
| set pSourceList = "" | ||
| // Add modules from the dependency graph to the excludeModules list | ||
| if ($data(dependencyGraph)) { | ||
| do ..ConstructInvertedDependencyGraph(.dependencyGraph, .invertedDependencyGraph) | ||
| set flatDepList = ..GetFlatDependencyListFromInvertedDependencyGraph(.invertedDependencyGraph) | ||
| for i = 1:1:flatDepList.Count() { | ||
| set excludeModules = excludeModules _ $listbuild(flatDepList.GetAt(i).Name) | ||
| } | ||
| } | ||
|
|
||
| set tResult = ##class(%IPM.Storage.Module).VersionRequirementsFunc(pModuleName,pExcludeModules) | ||
| if (tResult.%SQLCODE < 0) { | ||
| $$$ThrowStatus($$$ERROR($$$SQLCode,tResult.%SQLCODE,tResult.%Message)) | ||
| set expression = ##class(%IPM.General.SemanticVersionExpression).%New() | ||
| set sourceList = "" | ||
|
|
||
| set result = ##class(%IPM.Storage.Module).VersionRequirementsFunc(moduleName,excludeModules) | ||
| if (result.%SQLCODE < 0) { | ||
| $$$ThrowStatus($$$ERROR($$$SQLCode,result.%SQLCODE,result.%Message)) | ||
| } | ||
|
|
||
| while tResult.%Next(.tSC) { | ||
| $$$ThrowOnError(tSC) | ||
| set tVersion = tResult.%Get("Version") | ||
| $$$ThrowOnError(##class(%IPM.General.SemanticVersionExpression).FromString(tVersion,.tVersionExpr)) | ||
| set pExpression = pExpression.And(tVersionExpr) | ||
| set pSourceList = pSourceList_$listbuild($listtostring(tResult.%Get("ModuleNames"),", ")_": "_tVersion) | ||
| while result.%Next(.sc) { | ||
| $$$ThrowOnError(sc) | ||
| set version = result.%Get("Version") | ||
| $$$ThrowOnError(##class(%IPM.General.SemanticVersionExpression).FromString(version,.versionExpr)) | ||
| set expression = expression.And(versionExpr) | ||
| set sourceList = sourceList_$listbuild($listtostring(result.%Get("ModuleNames"),", ")_": "_version) | ||
| } | ||
| $$$ThrowOnError(sc) | ||
|
|
||
| // Add modules from the dependency graph to the expression and sourceList objects | ||
| if ($data(dependencyGraph)) { | ||
| set key = "" | ||
| for { | ||
| set key = $order(dependencyGraph(moduleName, key)) | ||
| if (key = "") { | ||
| quit | ||
| } | ||
| // Name of module which requires this one + the version expression string it requires | ||
| set requiringModuleName = $piece(key, " ") | ||
| set version = dependencyGraph(moduleName, key) | ||
|
|
||
| // Iterate over sourceList; if the required version expression is equivalent to this one, add this module name to that version | ||
| set newVersion = 1 | ||
| for i=1:1:$listlength(sourceList) { | ||
| if $find($listget(sourceList, i), version) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is is possible that $find is too loose of a search? ie. would there be a case where the version incorrectly matches only a substring?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The syntax of one element in sourceList looks like Could alternatively do |
||
| set $list(sourceList, i) = requiringModuleName _ ", " _ $list(sourceList, i) | ||
| set newVersion = 0 | ||
| quit | ||
| } | ||
| } | ||
| // If this is a new required version expression, add a new item to the list | ||
| if (newVersion) { | ||
| $$$ThrowOnError(##class(%IPM.General.SemanticVersionExpression).FromString(version, .versionExpr)) | ||
| set expression = expression.And(versionExpr) | ||
| set sourceList = sourceList _ $listbuild(requiringModuleName _ ": " _ version) | ||
| } | ||
| } | ||
| } | ||
| $$$ThrowOnError(tSC) | ||
|
isc-jlechtne marked this conversation as resolved.
|
||
| } catch e { | ||
| set pExpression = $$$NULLOREF | ||
| set pSourceList = "" | ||
| set tSC = e.AsStatus() | ||
| set expression = $$$NULLOREF | ||
| set sourceList = "" | ||
| set sc = e.AsStatus() | ||
| } | ||
| quit tSC | ||
| quit sc | ||
| } | ||
|
|
||
| /// Returns a flat list of dependents for a given module name (and optional version) <br /> | ||
|
|
@@ -1278,7 +1321,7 @@ ClassMethod LoadDependencies( | |
| // Ignore modules already installed that do not need to be installed again | ||
| continue | ||
| } | ||
| set sc = ..LoadModuleReference(moduleReference.ServerName, moduleReference.Name, moduleReference.VersionString, moduleReference.Deployed, moduleReference.PlatformVersion, .pParams) | ||
| set sc = ..LoadModuleReference(moduleReference.ServerName, moduleReference.Name, moduleReference.VersionString, moduleReference.Deployed, moduleReference.PlatformVersion, .pParams, .dependencyGraph) | ||
| $$$ThrowOnError(sc) | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleA.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleA.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-a.ZPM"> | ||
| <Module> | ||
| <Name>module-a</Name> | ||
| <Version>2.1.0+snapshot</Version> | ||
| <Resource Name="ModuleA.PKG" /> | ||
| <Dependencies> | ||
| <ModuleReference> | ||
| <Name>module-b</Name> | ||
| <Version>^2.0.0</Version> | ||
| </ModuleReference> | ||
| </Dependencies> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleB.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleB.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-b.ZPM"> | ||
| <Module> | ||
| <Name>module-b</Name> | ||
| <Version>2.0.0+snapshot</Version> | ||
| <Resource Name="ModuleB.PKG" /> | ||
| <Dependencies> | ||
| <ModuleReference> | ||
| <Name>module-c</Name> | ||
| <Version>^6.1.15</Version> | ||
| </ModuleReference> | ||
| </Dependencies> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleC.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleC.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-c.ZPM"> | ||
| <Module> | ||
| <Name>module-c</Name> | ||
| <Version>6.2.0+snapshot</Version> | ||
| <Resource Name="ModuleC.PKG" /> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleA.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleA.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-a.ZPM"> | ||
| <Module> | ||
| <Name>module-a</Name> | ||
| <Version>2.0.0</Version> | ||
| <Resource Name="ModuleA.PKG" /> | ||
| <Dependencies> | ||
| <ModuleReference> | ||
| <Name>module-b</Name> | ||
| <Version>1.0.0</Version> | ||
| </ModuleReference> | ||
| </Dependencies> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleB.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleB.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-b.ZPM"> | ||
| <Module> | ||
| <Name>module-b</Name> | ||
| <Version>1.0.0</Version> | ||
| <Resource Name="ModuleB.PKG" /> | ||
| <Dependencies> | ||
| <ModuleReference> | ||
| <Name>module-c</Name> | ||
| <Version>^5.4.1</Version> | ||
| </ModuleReference> | ||
| </Dependencies> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleC.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleC.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-c.ZPM"> | ||
| <Module> | ||
| <Name>module-c</Name> | ||
| <Version>5.6.45+snapshot</Version> | ||
| <Resource Name="ModuleC.PKG" /> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Class ModuleD.Class1 | ||
| { | ||
|
|
||
| ClassMethod MethodA() | ||
| { | ||
| write !, "This is ##class(ModuleD.Class1).MethodA()" | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <Export generator="Cache" version="25"> | ||
| <Document name="module-d.ZPM"> | ||
| <Module> | ||
| <Name>module-d</Name> | ||
| <Version>1.0.0</Version> | ||
| <Resource Name="ModuleD.PKG" /> | ||
| <Dependencies> | ||
| <ModuleReference> | ||
| <Name>module-c</Name> | ||
| <Version>^5.3.0</Version> | ||
| </ModuleReference> | ||
| </Dependencies> | ||
| </Module> | ||
| </Document> | ||
| </Export> |
Uh oh!
There was an error while loading. Please reload this page.