From 361671870e145d0feb8e6e200e5f59a9e0fc9b83 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 17 Nov 2025 03:05:05 -0500 Subject: feat(vim-patch.sh): -M lists all ported patches Start from current "v:version". Exclude reverted patches. Normalize left-zero-pad patch numbers to avoid grep inverse pattern file like scripts/vim_na_regexp.txt. Track reverted patches in vimpatch_token_reverts.txt because no convention in git-log. TODO: Track patch numbers per v:version in version.c. --- scripts/vimpatch.lua | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) (limited to 'scripts/vimpatch.lua') diff --git a/scripts/vimpatch.lua b/scripts/vimpatch.lua index 5d8bea6a98..5575783d5f 100755 --- a/scripts/vimpatch.lua +++ b/scripts/vimpatch.lua @@ -15,31 +15,45 @@ local function systemlist(...) return rv end -local function vimpatch_sh_list_numbers() +local function vimpatch_sh_list_tokens() return systemlist({ { 'bash', '-c', 'scripts/vim-patch.sh -M' } }) end --- Generates the lines to be inserted into the src/version.c +-- Generates the lines to be inserted into the src/nvim/version.c -- `included_patches[]` definition. local function gen_version_c_lines() - -- Set of merged Vim 8.1.zzzz patch numbers. - local merged_patch_numbers = {} - local highest = 0 - for _, n in ipairs(vimpatch_sh_list_numbers()) do - n = tonumber(n) - if n then - merged_patch_numbers[n] = true - highest = math.max(highest, n) + -- Sets of merged Vim x.y.zzzz patch numbers. + local merged_patch_sets = {} + for _, token in ipairs(vimpatch_sh_list_tokens()) do + local major_version, minor_version, patch_num = string.match(token, '^(%d+).(%d+).(%d+)$') + local n = tonumber(patch_num) + -- TODO(@janlazo): Allow multiple Vim versions + -- if n then + if n and major_version == '8' and minor_version == '1' then + local major_minor_version = major_version * 100 + minor_version + merged_patch_sets[major_minor_version] = merged_patch_sets[major_minor_version] or {} + table.insert(merged_patch_sets[major_minor_version], n) end end + local sorted_versions = {} + for k, _ in pairs(merged_patch_sets) do + table.insert(sorted_versions, k) + end + table.sort(sorted_versions) local lines = {} - for i = highest, 0, -1 do - local is_merged = (nil ~= merged_patch_numbers[i]) - if is_merged then - table.insert(lines, string.format(' %s,', i)) - else - table.insert(lines, string.format(' // %s,', i)) + for _, major_minor_version in ipairs(sorted_versions) do + -- table.insert(lines, string.format(' // major minor version: %s', major_minor_version)) + local patch_set = merged_patch_sets[major_minor_version] + for i = #patch_set, 1, -1 do + local patch = patch_set[i] + table.insert(lines, string.format(' %s,', patch)) + if patch > 0 then + local oldest_unmerged_patch = patch_set[i - 1] and (patch_set[i - 1] + 1) or 0 + for unmerged_patch = patch -1, oldest_unmerged_patch, -1 do + table.insert(lines, string.format(' // %s,', unmerged_patch)) + end + end end end -- cgit