Skip to content

Commit

Permalink
Issue #679: convert mt.__conflictT table collection of MName object t…
Browse files Browse the repository at this point in the history
…o constructors in mt.conflictT
  • Loading branch information
Robert McLay committed Mar 19, 2024
1 parent b482d09 commit db71a6d
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 17 deletions.
4 changes: 4 additions & 0 deletions rt/conflict/configDir/lmod_config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require("strict")
local cosmic = require("Cosmic"):singleton()

cosmic:assign("LMOD_PERMANENT_CONFLICTS","yes")
9 changes: 8 additions & 1 deletion rt/conflict/conflict.tdesc
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ testdescript = {
runLmod load x/1.5 #12
runLmod load y #13
runLmod purge #14
unsetMT
export MODULEPATH=$(testDir)/mf2/Core
export LMOD_CONFIG_DIR=$(testDir)/configDir
runLmod load base acme #15
runLmod save #16
runLmod restore #17
HOME=$ORIG_HOME
Expand Down
2 changes: 2 additions & 0 deletions rt/conflict/mf2/Core/acme/1.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
conflict(between("D","1.2>","<3.2"))
conflict("E")
1 change: 1 addition & 0 deletions rt/conflict/mf2/Core/base/1.0.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conflict("A","B")
70 changes: 60 additions & 10 deletions src/MT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,14 @@ local function l_new(self, s, restoreFn)
dbg.start{"MT l_new(s,restoreFn:",restoreFn,")"}
local o = {}

o.c_rebuildTime = false
o.c_shortTime = false
o.mT = {}
o.MTversion = l_mt_version()
o.family = {}
o.mpathA = {}
o.depthT = {}
o.c_rebuildTime = false
o.c_shortTime = false
o.mT = {}
o.MTversion = l_mt_version()
o.family = {}
o.mpathA = {}
o.depthT = {}
o.__conflictT = {}
o.__stickyA = {}
o.__loadT = {}
o.__changeMPATH = false
Expand Down Expand Up @@ -151,6 +152,25 @@ local function l_new(self, s, restoreFn)
for k,v in pairs(_ModuleTable_) do
o[k] = v
end
------------------------------------------------------------------
-- Convert the list of MName constructors in to an array of mnames
-- to hold the conflicts.
if (o.conflictT and next(o.conflictT) ~= nil) then
local MName = require("MName")
local cT = {}
local tt = o.conflictT

for sn, vv in pairs(tt) do
local a = {}
for i = 1,#vv do
local t = tt[sn][i]
a[i] = MName:new(t.sType, t.userName, t.action, t.is, t.ie)
end
cT[sn] = a
end
o.__conflictT = cT
end
o.conflict = nil
end

-- remove any mcmdT connected to a mT entry
Expand Down Expand Up @@ -401,6 +421,8 @@ end

function M.serializeTbl(self, state)
local make_pretty = (state == "pretty")


local mt = deepcopy(self)
local rTest = optionTbl().rt
if (rTest) then
Expand All @@ -409,6 +431,21 @@ function M.serializeTbl(self, state)
end
l_setLoadOrder(mt)

if (next(self.__conflictT) ~= nil) then
local cT = mt.__conflictT
local tt = {}

for sn,vv in pairs(cT) do
local a = {}
for i=1,#vv do
local mname = vv[i]
a[i] = mname:print()
end
tt[sn] = a
end
mt.conflictT = tt
end

if (make_pretty) then
local mT = mt.mT
for sn, v in pairs(mT) do
Expand Down Expand Up @@ -1444,7 +1481,20 @@ function M.name_w_possible_alias(self, entry, kind)
return moduleName
end




------------------------------------------------------------------------
-- Register Downstream conflicts
function M.registerConflicts(self, mname, mA)
if (dbg.active()) then
local s = mAList(mA)
dbg.start{"MT:registerConflicts(sn:", mname:sn(),",mA={"..s.."})"}
end
local sn = mname:sn()
local a = deepcopy(mA)
local A = self.__conflictT[sn] or {}
for i = 1,#a do
A[#A+1] = a[i]
end
self.__conflictT[sn] = A
dbg.fini("MT:registerConflicts")
end
return M
18 changes: 12 additions & 6 deletions src/MainControl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1204,12 +1204,13 @@ end
function M.conflict(self, mA)
dbg.start{"MainControl:conflict(mA)"}

local frameStk = FrameStk:singleton()
local mt = frameStk:mt()
local fullName = frameStk:fullName()
local optionTbl = optionTbl()
local a = {}
local permConflicts = cosmic:value("LMOD_PERMANENT_CONFLICTS")

local frameStk = FrameStk:singleton()
local mt = frameStk:mt()
local fullName = frameStk:fullName()
local optionTbl = optionTbl()
local a = {}

for i = 1, #mA do
local mname = mA[i]
Expand All @@ -1220,6 +1221,11 @@ function M.conflict(self, mA)
end
end

if (permConflicts == "yes") then
mt:registerConflicts(frameStk:mname(), mA)
end


if (#a > 0) then
LmodError{msg="e_Conflict", name = fullName, module_list = concatTbl(a," ")}
end
Expand Down Expand Up @@ -1586,7 +1592,7 @@ function M.un_source_sh(self, shellName, script)
dbg.fini("MainControl:un_source_sh")
end

function M.complete(self, shellName, name, args)
function M.ocmplete(self, shellName, name, args)
dbg.start{"MainControl:complete(shellName: \"",shellName,"\", name: \"",name,"\", args: \"",args,"\""}
if (myShellName() ~= shellName) then
dbg.fini("MainControl:complete")
Expand Down

0 comments on commit db71a6d

Please sign in to comment.