Module:Protection banner/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
inline toTableEnd since it's only called from one place
Jackmcbarn (talk | contribs)
rename walkHierarchy and explain more clearly what it does
Line 57:
end
 
-- Given a directed graph formatted as node -> table of direct successors,
local function walkHierarchy(hierarchy, start)
-- get a table of all nodes reachable from a given node (though always
-- including the given node).
local function walkHierarchygetReachableNodes(hierarchygraph, start)
local toWalk, retval = {[start] = true}, {}
while true do
-- Can't use pairs() since we're adding and removing things as we're iterating
local k = next(toWalk) -- This always gets the "first" key
if k == nil then break end
return retval
end
toWalk[k] = nil
retval[k] = true
for _,v in ipairs(hierarchygraph[k]) do
if not retval[v] then
toWalk[v] = true
Line 71 ⟶ 76:
end
end
return retval
end
 
Line 862 ⟶ 866:
if protectionObj.action == 'edit' or
args.demolevel or
not walkHierarchygetReachableNodes(
cfg.hierarchy,
protectionObj.level