From: Pierre-Elliott Bécue Date: Mon, 7 Apr 2014 18:41:04 +0000 (+0200) Subject: [.bashrc] Removing svk vcs, improving performances, and disabled option X-Git-Url: http://gitweb.pimeys.fr/?a=commitdiff_plain;h=ab34617c4c4c817b55a76fe24c503263eab94629;p=config-20-100.git [.bashrc] Removing svk vcs, improving performances, and disabled option * One can disable some vcs. By default, only git, darcs, mercurial and svn are active --- diff --git a/.bashrc b/.bashrc index 154bac0..968474a 100644 --- a/.bashrc +++ b/.bashrc @@ -147,45 +147,8 @@ git_detect(){ # Mercurial isn't hg_detect(){ check_command hg || return 1 - vcs_comm[detect_need_file]=store - detect_by_dir '.hg' - return $? -} - -# Neither is svk -# TODO - Not working : imported from zsh but not post treated -svk_detect(){ - local -a info - local -i fhash - fhash=0 - - check_command svk || return 1 - [[ -f ~/.svk/config ]] || return 1 - - # This detection function is a bit different from the others. - # We need to read svk's config file to detect a svk repository - # in the first place. Therefore, we'll just proceed and read - # the other information, too. This is more then any of the - # other detections do but this takes only one file open for - # svk at most. VCS_INFO_svk_get_data() get simpler, too. :-) - while IFS= read -r line ; do - if [[ -n ${vcs_comm[basedir]} ]] ; then - line=${line## ##} - [[ ${line} == depotpath:* ]] && vcs_comm[branch]=${line##*/} - [[ ${line} == revision:* ]] && vcs_comm[revision]=${line##*[[:space:]]##} - [[ -n ${vcs_comm[branch]} ]] && [[ -n ${vcs_comm[revision]} ]] && break - continue - fi - (( fhash > 0 )) && [[ ${line} == ' '[^[:space:]]*:* ]] && break - [[ ${line} == ' hash:'* ]] && fhash=1 && continue - (( fhash == 0 )) && continue - [[ ${PWD}/ == ${${line## ##}%:*}/* ]] && vcs_comm[basedir]=${${line## ##}%:*} - done < ~/.svk/config - - [[ -n ${vcs_comm[basedir]} ]] && \ - [[ -n ${vcs_comm[branch]} ]] && \ - [[ -n ${vcs_comm[revision]} ]] && return 0 - return 1 + vcs_comm[basedir]="$(hg root 2> /dev/null)" || return 1 + return 0 } # .svn in each directories @@ -197,6 +160,7 @@ svn_detect() { bzr_detect(){ check_command bzr || return 1 +# vcs_comm[basedir]=$(bzr root 2>/dev/null) || return 1 vcs_comm[detect_need_file]=branch/format detect_by_dir '.bzr' return $? @@ -217,9 +181,11 @@ cvs_detect(){ darcs_detect(){ check_command darcs || return 1 - vcs_comm[detect_need_file]=format - detect_by_dir '_darcs' - return $? + # darcs diff seems a good choice since big diff is not the + # common state + darcs diff 2> /dev/null || return 1 + vcs_comm[basedir]=$(darcs show repo |awk '{if($1 == "Root:") print $2}') + return 0 } # Find git's branch @@ -348,27 +314,13 @@ hg_get_data(){ hgbase=${vcs_comm[basedir]} - file="${hgbase}/.hg/branch" - if [[ -r ${file} ]] ; then - hgbranch=$(< ${file}) - else - hgbranch='default' - fi + # Check if hg branch is efficient + hgbranch=$(hg branch) vcs_formats '' "${hgbranch}" "${hgbase}" '' return 0 } -svk_get_data(){ - local svkbranch svkbase - - svkbase=${vcs_comm[basedir]} - svkbranch=${vcs_comm[branch]} - svkrevision=${vcs_comm[revision]} - vcs_formats '' "${svkbranch}" "${svkbase}" "${svkrevision}" - return 0 -} - svn_get_data(){ local svnbase svnbranch local -a svninfo @@ -386,16 +338,15 @@ svn_get_data(){ } bzr_get_data(){ - local bzrbase bzrbr - local -a bzrinfo + local bzrbase bzrrev bzrbranch bzrinfo bzrbase=$(bzr info|awk '{if ($1 == "branch" && $2 == "root:") print $3}') - bzrbranch=$(bzr version-info|awk '{if ($1 == "branch-nick:") print $2}') - bzrrev=$(bzr version-info|awk '{if ($1 == "revno:") print $2}') bzrbase="$(vcs_realpath ${bzrbase})" - bzrbr="${bzrbranch}" + bzrinfo=$(bzr version-info|awk '{if ($1 == "branch-nick:"||$1 == "revno:") print $2}') + bzrrev=$(echo $bzrinfo|awk '{print $1}') + bzrbranch=$(echo $bzrinfo|awk '{print $2}') - vcs_formats '' "${bzrbr}" "${bzrbase}" "${bzrrev}" + vcs_formats '' "${bzrbranch}" "${bzrbase}" "${bzrrev}" return 0 } @@ -438,15 +389,25 @@ vcs_info(){ local -Ax vcs_comm commands local -x vcs local -a vcss + local -A disabled vcs="init" - vcss=(git hg bzr darcs svk svn cvs cdv) + vcss=(git hg darcs svn bzr cvs cdv) + disabled[cdv]=1 + disabled[cvs]=1 + disabled[bzr]=1 for i in $(seq 0 $(( ${#vcss[*]} - 1 ))); do + if [[ disabled[${vcss[$i]}] -eq 1 ]]; then + continue + fi commands[${vcss[$i]}]=$(which ${vcss[$i]}); done; found=0 for vcs in ${vcss[*]}; do + if [[ disabled[${vcs}] -eq 1 ]]; then + continue + fi ${vcs}_detect && found=1 && break done @@ -634,7 +595,7 @@ else TITLE='' fi -# On régénère le prompt après chaque commande +# On regénére le prompt après chaque commande PROMPT_COMMAND=prompt_command # +-------------------+