From 2e8718f1d06a6cbedd1beeb912e9acfd28f3fe0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Deparis?= Date: Sat, 5 Jan 2013 23:03:26 +0100 Subject: [PATCH] Changege the untracked behavior to the same as git. Fix branch display bug while browsing deep fossil repositories --- README.md | 14 ++++++++------ liquidprompt | 23 ++++++++++++----------- liquidpromptrc-dist | 4 ++++ 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 5e4481c..98d3edd 100644 --- a/README.md +++ b/README.md @@ -58,12 +58,12 @@ preserving the first two directories; * the name of the current branch if you are in a version control repository (git, mercurial or subversion), in green if everything is up to date, in red if there is changes, in yellow if there is pending commits to push; -* the number of added/deleted lines, if changes have been made and the number -of pending commits, if any; +* the number of added/deleted lines (git) or files (fossil), if +changes have been made and the number of pending commits, if any; * a star if there is some untracked files in the repository; * the error code of the last command, if it has failed in some way; -* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, $ for simple -user, a red # for root. +* a smart mark: ± for git directories, ☿ for mercurial, ‡ for svn, ⌘ +for fossil, $ for simple user, a red # for root. You can temporarily deactivate the liquid prompt and come back to your previous one by typing `prompt_off`. Use `prompt_on` to bring it back. You can deactivate @@ -122,6 +122,7 @@ building: * `LP_ENABLE_GIT`, if you want to have git informations * `LP_ENABLE_SVN`, if you want to have subversion informations * `LP_ENABLE_HG`, if you want to have mercurial informations +* `LP_ENABLE_FOSSIL`, if you want to have fossil informations * `LP_ENABLE_VCS_ROOT`, if you want to show VCS informations with root account Note that if required commands are not installed, enabling the @@ -160,6 +161,7 @@ Available features: * `LP_GIT` git * `LP_HG` mercurial * `LP_SVN` subversion +* `LP_FOSSIL` fossil * `LP_ERR` last error code * `LP_MARK` prompt mark @@ -221,7 +223,7 @@ Set to a null string "" if you do not want color. * `LP_COLOR_UP` repository is up to date / a push have been made * `LP_COLOR_COMMITS` some commits have not been pushed * `LP_COLOR_CHANGES` there is some changes to commit - * `LP_COLOR_DIFF` number of lines impacted by current changes + * `LP_COLOR_DIFF` number of lines or files impacted by current changes * Battery * `LP_COLOR_CHARGING_ABOVE` charging and above threshold * `LP_COLOR_CHARGING_UNDER` charging but under threshold @@ -239,6 +241,7 @@ Special characters: * `LP_MARK_HG` (default: "☿") prompt mark in hg repositories * `LP_MARK_SVN` (default: "‡") prompt mark in svn repositories * `LP_MARK_GIT` (default: "±") prompt mark in git repositories +* `LP_MARK_FOSSIL` (default: "⌘") prompt mark in fossil repositories * `LP_MARK_UNTRACKED` (default: "*") if git has untracked files @@ -254,4 +257,3 @@ the display of the liquid prompt. * Subversion repository cannot display commits to be pushed, this is a limitation of the Subversion versionning model. * The proxy detection only uses the `$http_proxy` environment variable. - diff --git a/liquidprompt b/liquidprompt index 0997587..7a49b22 100755 --- a/liquidprompt +++ b/liquidprompt @@ -742,7 +742,7 @@ _lp_fossil_branch() [[ "$LP_ENABLE_FOSSIL" != 1 ]] && return # first, are we in an open fossil repository? - if [[ -e _FOSSIL_ || -e .fslckout ]] ; then + if fossil info &>/dev/null ; then local branch branch=$(fossil status 2>/dev/null | grep tags: | cut -c17-) if [[ -n "$branch" ]] ; then @@ -756,11 +756,11 @@ _lp_fossil_branch() # Set a color depending on the branch state: # - green if the repository is clean # - red if there is changes to commit +# - yellow if the branch has no tag name # # Add the number of impacted files with a # + when files are ADDED or EDITED # - when files are DELETED -# ? when files are not part of the current checkout _lp_fossil_branch_color() { [[ "$LP_ENABLE_FOSSIL" != 1 ]] && return @@ -792,11 +792,9 @@ _lp_fossil_branch_color() fi if [[ "$C2A" -gt 0 ]] ; then - if [[ "$ret" = "" ]] ; then - ret+="?$C2A" - else - ret+="/?$C2A" - fi + C2A="$LP_MARK_UNTRACKED" + else + C2A="" fi if [[ "$ret" != "" ]] ; then @@ -805,15 +803,18 @@ _lp_fossil_branch_color() if [[ "$branch" = "no-tag" ]] ; then - branch="${LP_COLOR_COMMITS}$branch${NO_COL}" + # Warning, your branch has no tag name ! + branch="${LP_COLOR_COMMITS}$branch${NO_COL}$ret${LP_COLOR_COMMITS}$C2A${NO_COL}" else if [[ "$C2E" -eq 0 && "$C2D" -eq 0 ]] ; then - branch="${LP_COLOR_UP}$branch${NO_COL}" + # All is up-to-date + branch="${LP_COLOR_UP}$branch$C2A${NO_COL}" else - branch="${LP_COLOR_CHANGES}$branch${NO_COL}" # changes to commit + # There're some changes to commit + branch="${LP_COLOR_CHANGES}$branch${NO_COL}$ret${LP_COLOR_CHANGES}$C2A${NO_COL}" fi fi - echo -ne "$branch$ret${NO_COL}" + echo -ne "$branch" fi } diff --git a/liquidpromptrc-dist b/liquidpromptrc-dist index 51df55c..c386068 100644 --- a/liquidpromptrc-dist +++ b/liquidpromptrc-dist @@ -73,6 +73,10 @@ LP_ENABLE_SVN=1 # Recommended value is 1 LP_ENABLE_HG=1 +# Do you want to use the fossil special features ? +# Recommended value is 1 +LP_ENABLE_FOSSIL=1 + # Show time of the last prompt display # Recommended value is 0 LP_ENABLE_TIME=0