From f1aa5676a074b918e144405a03917ae0b5f1a1d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Deparis?= Date: Mon, 20 May 2013 16:29:13 +0200 Subject: [PATCH 1/2] Display modifications in fossil repository as for git (by line and not by file) --- liquidprompt | 53 +++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/liquidprompt b/liquidprompt index 9cc75a7..de2406b 100755 --- a/liquidprompt +++ b/liquidprompt @@ -29,7 +29,7 @@ # Brendan Fahy # postfix variable # Clément Mathieu # Bazaar support # David Loureiro # small portability fix -# Étienne Deparis # Fossil support +# Étienne Deparis # Fossil support # Florian Le Frioux # Use ± mark when root in VCS dir. # François Schmidts # small code fix, _lp_get_dirtrim # Frédéric Lepied # Python virtual env @@ -914,23 +914,54 @@ _lp_fossil_branch_color() local C2E # Modified files (added or edited) local C2D # Deleted files local C2A # Extras files + local C2AA # Added files + local PLUSLINE # Added lines + local MINUSLINE # Deleted lines local ret C2E=$(fossil changes | wc -l) - C2D=$(fossil changes | grep DELETED | wc -l) - let "C2E = $C2E - $C2D" C2A=$(fossil extras | wc -l) + PLUSLINE=$(fossil diff | egrep '^\+[^+].+$' | wc -l) + MINUSLINE=$(fossil diff | egrep '^-[^-].+$' | wc -l) ret="" - if [[ "$C2E" -gt 0 ]] ; then - ret+="+$C2E" + C2AA=`fossil changes | grep ADDED | wc -l` + 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 + + if [[ $PLUSLINE -gt 0 ]] ; then + ret+="+$PLUSLINE" + 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 [[ "$C2D" -gt 0 ]] ; then - if [[ "$ret" = "" ]] ; then - ret+="-$C2D" - else - ret+="/-$C2D" - fi + if [[ "$C2E" -gt 0 ]] ; then + ret+=" in $C2E" fi if [[ "$C2A" -gt 0 ]] ; then From 7ffd524d6edf2fc5d52a07ab3f51e290ef1d95bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Deparis?= Date: Mon, 20 May 2013 16:47:31 +0200 Subject: [PATCH 2/2] Fix doc regarding the last change in fossil repository management --- README.md | 5 ++--- liquidprompt | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9420a6e..e37b349 100644 --- a/README.md +++ b/README.md @@ -61,8 +61,8 @@ preserving the first two directories; (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 commits to push; -* the number of added/deleted lines (git) or files (fossil), if -changes have been made and the number of pending commits, if any; +* the number of added/deleted lines if changes have been made and the +number of pending commits, if any; * a yellow plus if there is stashed modifications; * 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; @@ -335,4 +335,3 @@ limitation of the Subversion versionning model. (like xterm-256) * The analog clock necessitate a unicode-aware terminal and a sufficiently complete font. - diff --git a/liquidprompt b/liquidprompt index de2406b..e2dd1c3 100755 --- a/liquidprompt +++ b/liquidprompt @@ -29,7 +29,7 @@ # Brendan Fahy # postfix variable # Clément Mathieu # Bazaar support # David Loureiro # small portability fix -# Étienne Deparis # Fossil support +# Étienne Deparis # Fossil support # Florian Le Frioux # Use ± mark when root in VCS dir. # François Schmidts # small code fix, _lp_get_dirtrim # Frédéric Lepied # Python virtual env