Commit ab34617c authored by Pierre-Elliott Bécue's avatar Pierre-Elliott Bécue

[.bashrc] Removing svk vcs, improving performances, and disabled option

 * One can disable some vcs. By default, only git, darcs, mercurial and
  svn are active
parent b6933be1
......@@ -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
# +-------------------+
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment