run git/hg only if we can locate binary

This commit is contained in:
laerus 2016-11-08 23:00:00 +02:00
parent a797a9d804
commit 0f10c774cd

View file

@ -140,9 +140,9 @@ def current_branch(pad=NotImplemented):
"and will be removed in the future")
branch = None
cmds = builtins.__xonsh_commands_cache__
if cmds.lazy_locate_binary('git') or cmds.is_empty():
if cmds.lazy_locate_binary('git'):
branch = get_git_branch()
if (cmds.lazy_locate_binary('hg') or cmds.is_empty()) and not branch:
if cmds.lazy_locate_binary('hg') and not branch:
branch = get_hg_branch()
if isinstance(branch, subprocess.TimeoutExpired):
branch = '<branch-timeout>'
@ -209,9 +209,9 @@ def dirty_working_directory():
"""
dwd = None
cmds = builtins.__xonsh_commands_cache__
if cmds.lazy_locate_binary('git') or cmds.is_empty():
if cmds.lazy_locate_binary('git'):
dwd = git_dirty_working_directory()
if (cmds.lazy_locate_binary('hg') or cmds.is_empty()) and (dwd is None):
if cmds.lazy_locate_binary('hg') and dwd is None:
dwd = hg_dirty_working_directory()
return dwd