fix(parser): support for divergent changes

This commit is contained in:
NicolasGB
2026-01-25 19:15:06 +01:00
parent 470bc244e9
commit 463fd0876a
2 changed files with 73 additions and 2 deletions
+12 -2
View File
@@ -162,12 +162,22 @@ function M.get_revset(line)
allowed_prefix = allowed_prefix .. "]+" -- close class, match one or more (not zero)
-- Match first alphanumeric sequence after graph prefix
-- Only match if it's followed by whitespace or end of string (not part of text)
local revset = line:match("^" .. allowed_prefix .. "(%w+)%s")
-- Supports divergent changes: revset\0, revset\1, etc.
-- Only match if it's followed by whitespace, backslash (for divergent), or end of string
-- Try matching with divergent suffix first: revset\N where N is a number
local revset, divergent_num = line:match("^" .. allowed_prefix .. "(%w+)\\(%d+)")
if revset and divergent_num then
return revset .. "\\" .. divergent_num
end
-- Try regular match followed by whitespace
revset = line:match("^" .. allowed_prefix .. "(%w+)%s")
if not revset then
-- Try matching at end of line without trailing whitespace
revset = line:match("^" .. allowed_prefix .. "(%w+)$")
end
return revset
end