mirror of
https://github.com/cmderdev/cmder.git
synced 2024-11-13 03:09:10 +08:00
Replaced the 'hg -id' command with the 'hg branch' and 'hg status' pair for improved response times.
This commit is contained in:
parent
95e5169476
commit
89499f2a60
32
vendor/clink.lua
vendored
32
vendor/clink.lua
vendored
@ -324,34 +324,26 @@ local function hg_prompt_filter()
|
|||||||
dirty = "\x1b[31;1m",
|
dirty = "\x1b[31;1m",
|
||||||
}
|
}
|
||||||
|
|
||||||
-- 'hg id -ib' gives us BOTH the branch name AND an indicator that there
|
local pipe = io.popen("hg branch 2>&1")
|
||||||
-- are uncommitted changes, in one fast(er) call compared to "hg status"
|
|
||||||
local pipe = io.popen("hg id -ib 2>&1")
|
|
||||||
local output = pipe:read('*all')
|
local output = pipe:read('*all')
|
||||||
local rc = { pipe:close() }
|
local rc = { pipe:close() }
|
||||||
|
|
||||||
-- strip the trailing newline from the branch name
|
-- strip the trailing newline from the branch name
|
||||||
local n = #output
|
local n = #output
|
||||||
while n > 0 and output:find("^%s", n) do n = n - 1 end
|
while n > 0 and output:find("^%s", n) do n = n - 1 end
|
||||||
output = output:sub(1, n)
|
local branch = output:sub(1, n)
|
||||||
|
|
||||||
if output ~= nil and
|
if branch ~= nil and
|
||||||
string.sub(output,1,7) ~= "abort: " and -- not an HG working copy
|
string.sub(branch,1,7) ~= "abort: " and -- not an HG working copy
|
||||||
(not string.find(output, "is not recognized")) then -- 'hg' not in path
|
(not string.find(branch, "is not recognized")) then -- 'hg' not in path
|
||||||
local color = colors.clean
|
local color = colors.clean
|
||||||
-- split elements on space delimiter
|
|
||||||
local items = {}
|
local pipe = io.popen("hg status -amrd 2>&1")
|
||||||
for i in string.gmatch(output, "%S+") do
|
local output = pipe:read('*all')
|
||||||
table.insert(items, i)
|
local rc = { pipe:close() }
|
||||||
end
|
|
||||||
-- if the repo hash ends with '+', the wc has uncommitted changes
|
if output ~= nil and output ~= "" then color = colors.dirty end
|
||||||
if string.sub(items[1], -1, -1) == "+" then color = colors.dirty end
|
result = color .. "(" .. branch .. ")"
|
||||||
-- substitute the branch in directly
|
|
||||||
if items[2] ~= nil then
|
|
||||||
result = color .. "(" .. items[2] .. ")"
|
|
||||||
else
|
|
||||||
result = color .. "*"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user