027189b294d14a7d313cdbf611982843f921555d
- Author
- Michał Duszyk <mdevel@protonmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
perf(mercurial): speed up mercurial plugin (#4591)
* speed up mercurial plugin
* removed unnecesay limit to current dir from hg status
Diff
1diff --git a/plugins/mercurial/mercurial.plugin.zsh b/plugins/mercurial/mercurial.plugin.zsh
2index a50dcb523f814e74eacabeb392e744e676cb2893..f4efc2b4aabe54a6746b7107f568200489fa017a 100644
3--- a/plugins/mercurial/mercurial.plugin.zsh
4+++ b/plugins/mercurial/mercurial.plugin.zsh
5@@ -19,37 +19,38 @@ alias hglr='hg pull --rebase'
6 alias hgo='hg outgoing'
7
8 function in_hg() {
9- if [[ -d .hg ]] || $(hg summary > /dev/null 2>&1); then
10+ if $(hg branch > /dev/null 2>&1); then
11 echo 1
12 fi
13 }
14
15 function hg_get_branch_name() {
16- if [ $(in_hg) ]; then
17- echo $(hg branch)
18+ branch=`hg branch 2>/dev/null`
19+ if [ $? -eq 0 ]; then
20+ echo $branch
21 fi
22+ unset branch
23 }
24
25 function hg_prompt_info {
26- if [ $(in_hg) ]; then
27- _DISPLAY=$(hg_get_branch_name)
28+ _DISPLAY=`hg branch 2>/dev/null`
29+ if [ $? -eq 0 ]; then
30 echo "$ZSH_PROMPT_BASE_COLOR$ZSH_THEME_HG_PROMPT_PREFIX\
31 $ZSH_THEME_REPO_NAME_COLOR$_DISPLAY$ZSH_PROMPT_BASE_COLOR$ZSH_PROMPT_BASE_COLOR$(hg_dirty)$ZSH_THEME_HG_PROMPT_SUFFIX$ZSH_PROMPT_BASE_COLOR"
32- unset _DISPLAY
33 fi
34+ unset _DISPLAY
35 }
36
37 function hg_dirty_choose {
38- if [ $(in_hg) ]; then
39- hg status 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
40+ hg status -mar 2> /dev/null | command grep -Eq '^\s*[ACDIM!?L]'
41+ if [ $? -eq 0 ]; then
42 if [ $pipestatus[-1] -eq 0 ]; then
43 # Grep exits with 0 when "One or more lines were selected", return "dirty".
44 echo $1
45- else
46- # Otherwise, no lines were found, or an error occurred. Return clean.
47- echo $2
48+ return
49 fi
50 fi
51+ echo $2
52 }
53
54 function hg_dirty {
55@@ -57,11 +58,11 @@ function hg_dirty {
56 }
57
58 function hgic() {
59- hg incoming "$@" | grep "changeset" | wc -l
60+ hg incoming "$@" | grep "changeset" | wc -l
61 }
62
63 function hgoc() {
64- hg outgoing "$@" | grep "changeset" | wc -l
65+ hg outgoing "$@" | grep "changeset" | wc -l
66 }
67
68 function hg_get_bookmark_name() {