# HG changeset patch # User Matthew Wild # Date 1326750151 0 # Node ID 0653a782618cdff51b385b22a5dddf596125ad16 # Parent 149a63bc99067d84f27cc525fd2480b379b66681 yaml-merge: Preserve ordering when merging arrays diff -r 149a63bc9906 -r 0653a782618c yaml-merge --- a/yaml-merge Sat Dec 17 18:25:25 2011 +0000 +++ b/yaml-merge Mon Jan 16 21:42:31 2012 +0000 @@ -7,12 +7,9 @@ if type(t1) == "table" and type(t2) == "table" then local array = {}; if depth < 2 then -- numeric - for i,v in ipairs(t1) do - array[v] = true; - t1[i] = nil; - end for i,v in ipairs(t2) do array[v] = true; + table.insert(t1, v); end end for k,v in pairs(t2) do -- non-numeric @@ -20,9 +17,6 @@ t1[k] = merge_in(t1[k], v, depth + 1); end end - for v in pairs(array) do - table.insert(t1, v); - end elseif t2 ~= nil then t1 = t2; end