Skip to content

Commit 7d6cc4a

Browse files
committed
fix(hg): Remove wrong diffstat values from output
fixes sindrets#366
1 parent 2cc3303 commit 7d6cc4a

File tree

1 file changed

+10
-43
lines changed

1 file changed

+10
-43
lines changed

lua/diffview/vcs/adapters/hg/init.lua

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -742,8 +742,10 @@ function HgAdapter:parse_fh_data(data, commit, state)
742742
end
743743

744744

745-
local stats = {}
746-
local name, changes, diffstats = data.numstat[i]:match("(.*)|%s+(%d+)%s*([+-]*)")
745+
-- TODO(zegervdv): Cannot get diffstats from mercurial reliably
746+
-- see https://github.com/sindrets/diffview.nvim/issues/366
747+
local stats = nil
748+
local name, _ = data.numstat[i]:match("(.*)|.*")
747749
name = vim.trim(name)
748750

749751
local oldname
@@ -755,19 +757,6 @@ function HgAdapter:parse_fh_data(data, commit, state)
755757
status = 'R'
756758
end
757759

758-
if changes and diffstats then
759-
local _, adds = diffstats:gsub("+", "")
760-
761-
stats = {
762-
additions = tonumber(adds),
763-
deletions = tonumber(changes) - tonumber(adds),
764-
}
765-
end
766-
767-
if not stats.additions or not stats.deletions then
768-
stats = nil
769-
end
770-
771760
table.insert(
772761
files,
773762
FileEntry.with_layout(
@@ -1056,51 +1045,29 @@ HgAdapter.tracked_files = async.wrap(function (self, left, right, args, kind, op
10561045
retry = 2,
10571046
log_opt = log_opt,
10581047
})
1059-
local numstat_job = Job({
1060-
command = self:bin(),
1061-
args = utils.vec_join(self:args(), "diff", "--stat", args),
1062-
cwd = self.ctx.toplevel,
1063-
retry = 2,
1064-
log_opt = log_opt,
1065-
})
10661048

1067-
local ok = await(Job.join({ namestat_job, mergestate_job, numstat_job }))
1049+
local ok = await(Job.join({ namestat_job, mergestate_job }))
10681050

10691051
if not ok then
1070-
callback(utils.vec_join(namestat_job.stderr, numstat_job.stderr, mergestate_job.stderr), nil)
1052+
callback(utils.vec_join(namestat_job.stderr, mergestate_job.stderr), nil)
10711053
return
10721054
end
10731055

1074-
local numstat_out = numstat_job.stdout
10751056
local namestat_out = namestat_job.stdout
10761057
local mergestate_out = mergestate_job.stdout
10771058

10781059
local data = {}
10791060
local conflict_map = {}
10801061
local file_info = {}
10811062

1082-
-- Last line in numstat is a summary and should not be used
1083-
table.remove(numstat_out, #numstat_out)
1084-
1085-
local numstat_info = {}
1086-
for _, s in ipairs(numstat_out) do
1087-
local name, changes, diffstats = s:match("%s*([^|]*)%s+|%s+(%d+)%s+([+-]+)")
1088-
if changes and diffstats then
1089-
local _, adds = diffstats:gsub("+", "")
1090-
1091-
numstat_info[name] = {
1092-
additions = tonumber(adds),
1093-
deletions = tonumber(changes) - tonumber(adds),
1094-
}
1095-
end
1096-
end
1097-
10981063
for _, s in ipairs(namestat_out) do
10991064
if s ~= " " then
11001065
local status = s:sub(1, 1):gsub("%s", " ")
11011066
local name = vim.trim(s:match("[%a%s]%s*(.*)"))
1102-
1103-
local stats = numstat_info[name] or {}
1067+
1068+
-- TODO(zegervdv): Cannot get correct values from mercurial
1069+
-- see https://github.com/sindrets/diffview.nvim/issues/366
1070+
local stats = {}
11041071

11051072
if not (kind == "staged") then
11061073
file_info[name] = {

0 commit comments

Comments
 (0)