Patchwork bashcompletion: allow skipping completion for 'hg status'

login
register
mail settings
Submitter Mathias De Maré
Date Oct. 5, 2016, 2:01 p.m.
Message ID <1ad8d68d6e495200969a.1475676111@waste.org>
Download mbox | patch
Permalink /patch/16864/
State Changes Requested
Headers show

Comments

Mathias De Maré - Oct. 5, 2016, 2:01 p.m.
# HG changeset patch
# User Mathias De Maré <mathias.de_mare@nokia.com>
# Date 1474879657 -7200
#      Mon Sep 26 10:47:37 2016 +0200
# Node ID 1ad8d68d6e495200969a650992f9cf7ff3f934d1
# Parent  1779dde4c9ef97cb242f8d501655f236f66e5439
bashcompletion: allow skipping completion for 'hg status'
Yuya Nishihara - Oct. 13, 2016, 1:08 p.m.
On Wed, 05 Oct 2016 09:01:51 -0500, Mathias De Maré wrote:
> # HG changeset patch
> # User Mathias De Maré <mathias.de_mare@nokia.com>
> # Date 1474879657 -7200
> #      Mon Sep 26 10:47:37 2016 +0200
> # Node ID 1ad8d68d6e495200969a650992f9cf7ff3f934d1
> # Parent  1779dde4c9ef97cb242f8d501655f236f66e5439
> bashcompletion: allow skipping completion for 'hg status'

because 'hg status' might be slow? Can you add more details to the commit
message?

> --- a/contrib/bash_completion
> +++ b/contrib/bash_completion
> @@ -89,9 +89,11 @@
>  
>  _hg_status()
>  {
> -    local files="$(_hg_cmd status -n$1 "glob:$cur**")"
> -    local IFS=$'\n'
> -    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
> +    if [ -z "$HGCOMPLETE_NOSTATUS" ]; then
> +        local files="$(_hg_cmd status -n$1 "glob:$cur**")"
> +        local IFS=$'\n'
> +        COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
> +    fi

Using shell variables seems okay. I found several examples in bash-completion
directory.

$ grep COMP * | grep -v COMPREPLY | grep -v 'COMP_.*WORD' | head -10
ciptool:    if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then
colormake:        if (( COMP_TYPE != 9 )); then
configure:    # if $COMP_CONFIGURE_HINTS is not null, then completions of the form
configure:    if [[ -n $COMP_CONFIGURE_HINTS ]]; then
cvs:                # if $COMP_CVS_REMOTE is not null, 'cvs commit' will
cvs:                if [[ -n ${COMP_CVS_REMOTE:-} ]]; then
dfutool:    if [[ -n ${COMP_BLUETOOTH_SCAN:-} ]]; then
docker:# DOCKER_COMPLETION_SHOW_NETWORK_IDS
docker:# DOCKER_COMPLETION_SHOW_IMAGE_IDS
docker:# DOCKER_COMPLETION_SHOW_TAGS
Mathias De Maré - Oct. 17, 2016, 7:14 a.m.
> -----Original Message-----

> From: Yuya Nishihara [mailto:youjah@gmail.com] On Behalf Of Yuya

> Nishihara

> Sent: donderdag 13 oktober 2016 15:09

> To: De Mare, Mathias (Nokia - BE) <mathias.de_mare@nokia.com>

> Cc: mercurial-devel@mercurial-scm.org

> Subject: Re: [PATCH] bashcompletion: allow skipping completion for 'hg

> status'

> 

> On Wed, 05 Oct 2016 09:01:51 -0500, Mathias De Maré wrote:

> > # HG changeset patch

> > # User Mathias De Maré <mathias.de_mare@nokia.com> # Date

> 1474879657

> > -7200

> > #      Mon Sep 26 10:47:37 2016 +0200

> > # Node ID 1ad8d68d6e495200969a650992f9cf7ff3f934d1

> > # Parent  1779dde4c9ef97cb242f8d501655f236f66e5439

> > bashcompletion: allow skipping completion for 'hg status'

> 

> because 'hg status' might be slow? Can you add more details to the commit

> message?


That's indeed the reason, it has a lot of impact on autocomplete (slowness for large repos on slow disks).
I've pushed a V2 now.
Sean Farley - Oct. 17, 2016, 6:43 p.m.
"De Mare, Mathias (Nokia - BE)" <mathias.de_mare@nokia.com> writes:

>> -----Original Message-----
>> From: Yuya Nishihara [mailto:youjah@gmail.com] On Behalf Of Yuya
>> Nishihara
>> Sent: donderdag 13 oktober 2016 15:09
>> To: De Mare, Mathias (Nokia - BE) <mathias.de_mare@nokia.com>
>> Cc: mercurial-devel@mercurial-scm.org
>> Subject: Re: [PATCH] bashcompletion: allow skipping completion for 'hg
>> status'
>> 
>> On Wed, 05 Oct 2016 09:01:51 -0500, Mathias De Maré wrote:
>> > # HG changeset patch
>> > # User Mathias De Maré <mathias.de_mare@nokia.com> # Date
>> 1474879657
>> > -7200
>> > #      Mon Sep 26 10:47:37 2016 +0200
>> > # Node ID 1ad8d68d6e495200969a650992f9cf7ff3f934d1
>> > # Parent  1779dde4c9ef97cb242f8d501655f236f66e5439
>> > bashcompletion: allow skipping completion for 'hg status'
>> 
>> because 'hg status' might be slow? Can you add more details to the commit
>> message?
>
> That's indeed the reason, it has a lot of impact on autocomplete (slowness for large repos on slow disks).

I had that problem, too, until I started to use watchman :-/
Mathias De Maré - Oct. 18, 2016, 5:45 a.m.
> -----Original Message-----

> From: Sean Farley [mailto:sean@farley.io]

> Sent: maandag 17 oktober 2016 20:44

> To: De Mare, Mathias (Nokia - BE) <mathias.de_mare@nokia.com>; Yuya

> Nishihara <yuya@tcha.org>

> Cc: mercurial-devel@mercurial-scm.org

> Subject: RE: [PATCH] bashcompletion: allow skipping completion for 'hg

> status'

> 

> "De Mare, Mathias (Nokia - BE)" <mathias.de_mare@nokia.com> writes:

> 

> >> -----Original Message-----

> >> From: Yuya Nishihara [mailto:youjah@gmail.com] On Behalf Of Yuya

> >> Nishihara

> >> Sent: donderdag 13 oktober 2016 15:09

> >> To: De Mare, Mathias (Nokia - BE) <mathias.de_mare@nokia.com>

> >> Cc: mercurial-devel@mercurial-scm.org

> >> Subject: Re: [PATCH] bashcompletion: allow skipping completion for

> >> 'hg status'

> >>

> >> On Wed, 05 Oct 2016 09:01:51 -0500, Mathias De Maré wrote:

> >> > # HG changeset patch

> >> > # User Mathias De Maré <mathias.de_mare@nokia.com> # Date

> >> 1474879657

> >> > -7200

> >> > #      Mon Sep 26 10:47:37 2016 +0200

> >> > # Node ID 1ad8d68d6e495200969a650992f9cf7ff3f934d1

> >> > # Parent  1779dde4c9ef97cb242f8d501655f236f66e5439

> >> > bashcompletion: allow skipping completion for 'hg status'

> >>

> >> because 'hg status' might be slow? Can you add more details to the

> >> commit message?

> >

> > That's indeed the reason, it has a lot of impact on autocomplete (slowness

> for large repos on slow disks).

> 

> I had that problem, too, until I started to use watchman :-/


That is what we want to move to, but we have some problems in our current system (discussed with Wez at the sprint) that add slowness even when Watchman is in use. I'm hoping we can resolve this eventually (until then, we at least have a workaround ;-)).

Greetings,
Mathias

Patch

diff --git a/contrib/bash_completion b/contrib/bash_completion
--- a/contrib/bash_completion
+++ b/contrib/bash_completion
@@ -89,9 +89,11 @@ 
 
 _hg_status()
 {
-    local files="$(_hg_cmd status -n$1 "glob:$cur**")"
-    local IFS=$'\n'
-    COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
+    if [ -z "$HGCOMPLETE_NOSTATUS" ]; then
+        local files="$(_hg_cmd status -n$1 "glob:$cur**")"
+        local IFS=$'\n'
+        COMPREPLY=(${COMPREPLY[@]:-} $(compgen -W '$files' -- "$cur"))
+    fi
 }
 
 _hg_branches()