mirror of
https://github.com/cmderdev/cmder.git
synced 2025-02-11 07:59:07 +08:00
Merge pull request #2660 from vsajip/fix-2659
Fix #2659: Use get_hg_branch() to get Mercurial branch information.
This commit is contained in:
commit
0616ff0a82
18
vendor/clink.lua
vendored
18
vendor/clink.lua
vendored
@ -303,11 +303,18 @@ local function get_git_branch(git_dir)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Find out current branch
|
-- Find out current branch information
|
||||||
-- @return {false|mercurial branch name}
|
-- @return {false|mercurial branch information}
|
||||||
---
|
---
|
||||||
local function get_hg_branch()
|
local function get_hg_branch()
|
||||||
local file = io.popen("hg branch 2>nul")
|
-- Return the branch information. The default is to get just the
|
||||||
|
-- branch name, but you could e.g. use the "hg-prompt" extension to
|
||||||
|
-- get more information, such as any applied mq patches. Here's an
|
||||||
|
-- example of that:
|
||||||
|
-- local cmd = "hg prompt \"{branch}{status}{|{patch}}{update}\""
|
||||||
|
local cmd = "hg branch 2>nul"
|
||||||
|
local file = io.popen(cmd)
|
||||||
|
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
local m = line:match("(.+)$")
|
local m = line:match("(.+)$")
|
||||||
if m then
|
if m then
|
||||||
@ -521,10 +528,7 @@ local function hg_prompt_filter()
|
|||||||
dirty = get_dirty_color(),
|
dirty = get_dirty_color(),
|
||||||
nostatus = get_unknown_color()
|
nostatus = get_unknown_color()
|
||||||
}
|
}
|
||||||
|
local output = get_hg_branch()
|
||||||
local pipe = io.popen("hg branch 2>&1")
|
|
||||||
local output = pipe:read('*all')
|
|
||||||
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user