Add some Mercurial informations : nb of lines inserted, deleted and nb of changes to commit

This commit is contained in:
Stéphane Pajot 2013-03-13 18:31:26 +01:00
parent f23bac5325
commit a00944c490

View File

@ -754,10 +754,37 @@ _lp_hg_branch_color()
local ret
branch=$(_lp_hg_branch)
if [[ ! -z "$branch" ]] ; then
if [[ $(( $(hg status --quiet -n | wc -l) )) = 0 ]] ; then
ret="${LP_COLOR_UP}${branch}${NO_COL}"
local has_untracked
has_untracked=$(hg status 2>/dev/null | grep '\(^\?\)' | wc -l)
if [[ -z "$has_untracked" ]] ; then
has_untracked=""
else
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}" # changes to commit
has_untracked="$LP_COLOR_CHANGES$LP_MARK_UNTRACKED"
fi
local has_commit
has_commit=$(hg outgoing --no-merges ${branch} 2>/dev/null | grep '\(^changeset\:\)' | wc -l)
if [[ -z "$has_commit" ]] ; then
has_commit=0
fi
if [[ $(( $(hg status --quiet -n | wc -l) )) = 0 ]] ; then
if [[ "$has_commit" -gt "0" ]] ; then
# some commit(s) to push
ret="${LP_COLOR_COMMITS}${branch}${NO_COL}(${LP_COLOR_COMMITS}$has_commit${NO_COL})${has_untracked}${NO_COL}"
else
ret="${LP_COLOR_UP}${branch}${has_untracked}${NO_COL}" # nothing to commit or push
fi
else
local has_line
has_lines=$(hg diff --stat 2>/dev/null | tail -n 1 | awk 'FS=" " {printf("+%s/-%s\n", $4, $6)}')
if [[ "$has_commit" -gt "0" ]] ; then
# Changes to commit and commits to push
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL},${LP_COLOR_COMMITS}$has_commit${NO_COL})${has_untracked}${NO_COL}"
else
ret="${LP_COLOR_CHANGES}${branch}${NO_COL}(${LP_COLOR_DIFF}$has_lines${NO_COL})${has_untracked}${NO_COL}" # changes to commit
fi
fi
echo -ne "$ret"
fi