D4264: zsh_completion: declare appropriate local parameters for ->string form

2018-08-20 Thread av6 (Anton Shestakov)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG69876534caf2: zsh_completion: declare appropriate local 
parameters for -string form (authored by av6, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4264?vs=10330=10466

REVISION DETAIL
  https://phab.mercurial-scm.org/D4264

AFFECTED FILES
  contrib/zsh_completion

CHANGE DETAILS

diff --git a/contrib/zsh_completion b/contrib/zsh_completion
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -581,7 +581,9 @@
 }
 
 _hg_cmd_diff() {
+  local context state state_descr line ret=1
   typeset -A opt_args
+
   _arguments -s -S : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \
  $_hg_pat_opts $_hg_subrepos_opts \
   '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
@@ -591,17 +593,19 @@
   '--reverse[produce a diff that undoes the changes]' \
   '(--unified -U)'{-U+,--unified=}'[number of lines of context to show]:' \
   '--stat[output diffstat-style summary of changes]' \
-  '*:file:->diff_files'
+  '*:file:->diff_files' && ret=0
 
   if [[ $state == 'diff_files' ]]
   then
 if [[ -n $opt_args[-r] ]]
 then
-  _hg_files
+  _hg_files && ret=0
 else
-  _hg_committable
+  _hg_committable && ret=0
 fi
   fi
+
+  return ret
 }
 
 _hg_cmd_export() {
@@ -796,46 +800,50 @@
 }
 
 _hg_cmd_resolve() {
-  local context state line
+  local context state state_descr line ret=1
   typeset -A opt_args
 
   _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
   '(--all -a)'{-a,--all}'[select all unresolved files]' \
   '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
   '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing 
merge]:*:merged files:->resolve_files' \
   '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as 
resolved]:*:unresolved files:_hg_unresolved' \
   '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as 
resolved]:*:resolved files:_hg_resolved' \
-  '*:file:_hg_unresolved'
+  '*:file:_hg_unresolved' && ret=0
 
   if [[ $state == 'resolve_files' ]]
   then
 _alternative 'files:resolved files:_hg_resolved' \
-  'files:unresolved files:_hg_unresolved'
+  'files:unresolved files:_hg_unresolved' && ret=0
   fi
+
+  return ret
 }
 
 _hg_cmd_revert() {
-  local context state line
+  local context state state_descr line ret=1
   typeset -A opt_args
 
   _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
   '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
   '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_labels' \
   '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
   '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date code:' \
-  '*:file:->diff_files'
+  '*:file:->revert_files' && ret=0
 
-  if [[ $state == 'diff_files' ]]
+  if [[ $state == 'revert_files' ]]
   then
 if [[ -n $opt_args[-r] ]]
 then
-  _hg_files
+  _hg_files && ret=0
 else
   typeset -a status_files
   _hg_status mard
-  _wanted files expl 'modified, added, removed or deleted file' 
_multi_parts / status_files
+  _wanted files expl 'modified, added, removed or deleted file' 
_multi_parts / status_files && ret=0
 fi
   fi
+
+  return ret
 }
 
 _hg_cmd_rollback() {



To: av6, #hg-reviewers, spectral
Cc: spectral, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4264: zsh_completion: declare appropriate local parameters for ->string form

2018-08-13 Thread spectral (Kyle Lippincott)
spectral accepted this revision.
spectral added a comment.


  I don't understand this aspect super well, I admit I haven't read the docs 
you linked to, but I can see why this would be more correct :)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4264

To: av6, #hg-reviewers, spectral
Cc: spectral, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


D4264: zsh_completion: declare appropriate local parameters for ->string form

2018-08-10 Thread av6 (Anton Shestakov)
av6 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When ->string form is used for _arguments, the function that calls it must
  declare appropriate local parameters.
  
  Managing local return value is needed to tell the completion system if our
  function succeeded in suggesting something or not, plus without that `hg diff
  -` doesn't look right.
  
  While at it, fix a copypaste error (s/diff_files/revert_files/).
  
  Docs: http://zsh.sourceforge.net/Doc/Release/Completion-System.html

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D4264

AFFECTED FILES
  contrib/zsh_completion

CHANGE DETAILS

diff --git a/contrib/zsh_completion b/contrib/zsh_completion
--- a/contrib/zsh_completion
+++ b/contrib/zsh_completion
@@ -581,7 +581,9 @@
 }
 
 _hg_cmd_diff() {
+  local context state state_descr line ret=1
   typeset -A opt_args
+
   _arguments -s -S : $_hg_global_opts $_hg_diff_opts $_hg_ignore_space_opts \
  $_hg_pat_opts $_hg_subrepos_opts \
   '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
@@ -591,17 +593,19 @@
   '--reverse[produce a diff that undoes the changes]' \
   '(--unified -U)'{-U+,--unified=}'[number of lines of context to show]:' \
   '--stat[output diffstat-style summary of changes]' \
-  '*:file:->diff_files'
+  '*:file:->diff_files' && ret=0
 
   if [[ $state == 'diff_files' ]]
   then
 if [[ -n $opt_args[-r] ]]
 then
-  _hg_files
+  _hg_files && ret=0
 else
-  _hg_committable
+  _hg_committable && ret=0
 fi
   fi
+
+  return ret
 }
 
 _hg_cmd_export() {
@@ -796,46 +800,50 @@
 }
 
 _hg_cmd_resolve() {
-  local context state line
+  local context state state_descr line ret=1
   typeset -A opt_args
 
   _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \
   '(--all -a)'{-a,--all}'[select all unresolved files]' \
   '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
   '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing 
merge]:*:merged files:->resolve_files' \
   '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as 
resolved]:*:unresolved files:_hg_unresolved' \
   '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as 
resolved]:*:resolved files:_hg_resolved' \
-  '*:file:_hg_unresolved'
+  '*:file:_hg_unresolved' && ret=0
 
   if [[ $state == 'resolve_files' ]]
   then
 _alternative 'files:resolved files:_hg_resolved' \
-  'files:unresolved files:_hg_unresolved'
+  'files:unresolved files:_hg_unresolved' && ret=0
   fi
+
+  return ret
 }
 
 _hg_cmd_revert() {
-  local context state line
+  local context state state_descr line ret=1
   typeset -A opt_args
 
   _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
   '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \
   '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_labels' \
   '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
   '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date code:' \
-  '*:file:->diff_files'
+  '*:file:->revert_files' && ret=0
 
-  if [[ $state == 'diff_files' ]]
+  if [[ $state == 'revert_files' ]]
   then
 if [[ -n $opt_args[-r] ]]
 then
-  _hg_files
+  _hg_files && ret=0
 else
   typeset -a status_files
   _hg_status mard
-  _wanted files expl 'modified, added, removed or deleted file' 
_multi_parts / status_files
+  _wanted files expl 'modified, added, removed or deleted file' 
_multi_parts / status_files && ret=0
 fi
   fi
+
+  return ret
 }
 
 _hg_cmd_rollback() {



To: av6, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel