Merge pull request #186 from milouse/develop

Display changes in fossil repository the same way as for git
This commit is contained in:
nojhan 2013-05-22 11:54:05 -07:00
commit 6ef3fd0c9d
2 changed files with 44 additions and 14 deletions

View File

@ -61,8 +61,8 @@ preserving the first two directories;
(git, mercurial, subversion, bazaar or fossil), in green if everything is up (git, mercurial, subversion, bazaar or fossil), in green if everything is up
to date, in red if there are changes, in yellow if there are pending to date, in red if there are changes, in yellow if there are pending
commits to push; commits to push;
* the number of added/deleted lines (git) or files (fossil), if * the number of added/deleted lines if changes have been made and the
changes have been made and the number of pending commits, if any; number of pending commits, if any;
* a yellow plus if there is stashed modifications; * a yellow plus if there is stashed modifications;
* a red star if there is some untracked files in the repository; * a red star if there is some untracked files in the repository;
* the error code of the last command, if it has failed in some way; * the error code of the last command, if it has failed in some way;
@ -338,4 +338,3 @@ limitation of the Subversion versionning model.
(like xterm-256) (like xterm-256)
* The analog clock necessitate a unicode-aware terminal and a sufficiently * The analog clock necessitate a unicode-aware terminal and a sufficiently
complete font. complete font.

View File

@ -29,7 +29,7 @@
# Brendan Fahy <bmfahy@gmail.com> # postfix variable # Brendan Fahy <bmfahy@gmail.com> # postfix variable
# Clément Mathieu <clement@unportant.info> # Bazaar support # Clément Mathieu <clement@unportant.info> # Bazaar support
# David Loureiro <david.loureiro@sysfera.com> # small portability fix # David Loureiro <david.loureiro@sysfera.com> # small portability fix
# Étienne Deparis <etienne.deparis@umaneti.net> # Fossil support # Étienne Deparis <etienne@depar.is> # Fossil support
# Florian Le Frioux <florian@lefrioux.fr> # Use ± mark when root in VCS dir. # Florian Le Frioux <florian@lefrioux.fr> # Use ± mark when root in VCS dir.
# François Schmidts <francois.schmidts@gmail.com> # small code fix, _lp_get_dirtrim # François Schmidts <francois.schmidts@gmail.com> # small code fix, _lp_get_dirtrim
# Frédéric Lepied <flepied@gmail.com> # Python virtual env # Frédéric Lepied <flepied@gmail.com> # Python virtual env
@ -908,23 +908,54 @@ _lp_fossil_branch_color()
local C2E # Modified files (added or edited) local C2E # Modified files (added or edited)
local C2D # Deleted files local C2D # Deleted files
local C2A # Extras files local C2A # Extras files
local C2AA # Added files
local PLUSLINE # Added lines
local MINUSLINE # Deleted lines
local ret local ret
C2E=$(fossil changes | wc -l) C2E=$(fossil changes | wc -l)
C2D=$(fossil changes | grep DELETED | wc -l)
let "C2E = $C2E - $C2D"
C2A=$(fossil extras | wc -l) C2A=$(fossil extras | wc -l)
PLUSLINE=$(fossil diff | egrep '^\+[^+].+$' | wc -l)
MINUSLINE=$(fossil diff | egrep '^-[^-].+$' | wc -l)
ret="" ret=""
if [[ "$C2E" -gt 0 ]] ; then C2AA=`fossil changes | grep ADDED | wc -l`
ret+="+$C2E" if [[ $C2AA -gt 0 ]] ; then
# We count the line "à la" git
local ADDFILE
local FILE
ADDFILE=`fossil changes | grep ADDED | sed -e 's/\s\{2,\}/ /g' | cut -d" " -f2`
for FILE in $ADDFILE ; do
PLULI=$(wc -l $FILE | cut -d" " -f1)
let PLUSLINE=$PLUSLINE+$PLULI
done
fi fi
if [[ "$C2D" -gt 0 ]] ; then if [[ $PLUSLINE -gt 0 ]] ; then
if [[ "$ret" = "" ]] ; then ret+="+$PLUSLINE"
ret+="-$C2D"
else
ret+="/-$C2D"
fi fi
C2D=`fossil changes | grep DELETED | wc -l`
if [[ $C2D -gt 0 ]] ; then
# We count the line "à la" git
local DELFILE
local FILE
DELFILE=`fossil changes | grep DELETED | sed -e 's/\s\{2,\}/ /g' | cut -d" " -f2`
for FILE in $DELFILE ; do
MINLI=$(wc -l $FILE | cut -d" " -f1)
let MINUSLINE=$MINUSLINE+$MINLI
done
fi
if [[ $MINUSLINE -gt 0 ]] ; then
if [[ "$ret" = "" ]] ; then
ret+="-$MINUSLINE"
else
ret+="/-$MINUSLINE"
fi
fi
if [[ "$C2E" -gt 0 ]] ; then
ret+=" in $C2E"
fi fi
if [[ "$C2A" -gt 0 ]] ; then if [[ "$C2A" -gt 0 ]] ; then