zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 0/5] An update for Completion/Unix/Command/_hg
@ 2018-08-06  7:28 Anton Shestakov
  2018-08-06  7:28 ` [PATCH 1/5] _hg: rename _hg_style_opts to _hg_template_opts Anton Shestakov
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06  7:28 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

Hey there zsh folks,

One day I decided to update completion file for hg (Mercurial), even though I
didn't really know how zsh completion system works. A week later, I still don't
know how it works, but I believe I have something that's worth sending. So here
goes.

This update is based on hg 4.0, which is what Debian stable has at the moment.
When comparing it to 4.7, which has been released recently, it lacks some newer
command line flags (e.g. --dry-run and --interactive for more commands), but
let's assume people don't upgrade often and 4.0 is the least they have. I can
update the completion file based on 4.7 later, if people think it's a good
idea.

In general, I can fix errors and things that I missed, but preferably in a
follow-up, because I was staring at these diffs for a whole week. Diffs as in
plural because I have an update to upstream... downstream? sidestream's
completion file: Mercurial's own contrib/zsh_completion, which I'm intending to
base on 4.7. My idea is to run things through people who know zsh completion
better first, and then send patches to Mercurial.

I've split the work into 5 patches for easier reviewing, because they do need
reviewing -- I'd rather not have any errors in a file that gets updated once a
year. Thanks in advance!

Anton Shestakov (5):
  _hg: rename _hg_style_opts to _hg_template_opts
  _hg: declare appropriate local parameters for ->string form
  _hg: add forget, phase, summary
  _hg: update all options
  _hg: drop -w, add -S to _arguments

 Completion/Unix/Command/_hg | 357 ++++++++++++++++++++++++++------------------
 1 file changed, 213 insertions(+), 144 deletions(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5] _hg: rename _hg_style_opts to _hg_template_opts
  2018-08-06  7:28 [PATCH 0/5] An update for Completion/Unix/Command/_hg Anton Shestakov
@ 2018-08-06  7:28 ` Anton Shestakov
  2018-08-06  7:28 ` [PATCH 2/5] _hg: declare appropriate local parameters for ->string form Anton Shestakov
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06  7:28 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

--style is a deprecated alias for --template, and doesn't show up in
help without --verbose.

Let's s/style/template/ this variable to be more consistent with
mercurial/cmdutil.py, which is helpful to look at in parallel next time
someone wants to update the completion rules.
---
 Completion/Unix/Command/_hg | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 8eaa457c8..50ab7132c 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -389,9 +389,9 @@ _hg_diff_opts=(
 _hg_dryrun_opts=(
   '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
 
-_hg_style_opts=(
-  '--style[display using template map file]:'
-  '--template[display with template]:')
+_hg_template_opts=(
+  '--template[display with template]:template'
+)
 
 _hg_commit_opts=(
   '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]'
@@ -565,7 +565,7 @@ _hg_cmd_grep() {
 }
 
 _hg_cmd_heads() {
-  _arguments -s : $_hg_global_opts $_hg_style_opts \
+  _arguments -s : $_hg_global_opts $_hg_template_opts \
   '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags'
 }
 
@@ -592,7 +592,7 @@ _hg_cmd_import() {
 }
 
 _hg_cmd_incoming() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
+  _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_template_opts \
   '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
@@ -616,7 +616,7 @@ _hg_cmd_locate() {
 }
 
 _hg_cmd_log() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \
+  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_template_opts \
   '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
   '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
   '(--copies -C)'{-C,--copies}'[show copied files]' \
@@ -644,7 +644,7 @@ _hg_cmd_merge() {
 }
 
 _hg_cmd_outgoing() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \
+  _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_template_opts \
   '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
@@ -654,7 +654,7 @@ _hg_cmd_outgoing() {
 }
 
 _hg_cmd_parents() {
-  _arguments -s : $_hg_global_opts $_hg_style_opts \
+  _arguments -s : $_hg_global_opts $_hg_template_opts \
   '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_tags' \
   ':last modified file:_hg_files'
 }
@@ -785,7 +785,7 @@ _hg_cmd_tag() {
 }
 
 _hg_cmd_tip() {
-  _arguments -s : $_hg_global_opts $_hg_style_opts \
+  _arguments -s : $_hg_global_opts $_hg_template_opts \
   '(--patch -p)'{-p,--patch}'[show patch]'
 }
 
-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06  7:28 [PATCH 0/5] An update for Completion/Unix/Command/_hg Anton Shestakov
  2018-08-06  7:28 ` [PATCH 1/5] _hg: rename _hg_style_opts to _hg_template_opts Anton Shestakov
@ 2018-08-06  7:28 ` Anton Shestakov
  2018-08-06  9:20   ` Daniel Shahaf
  2018-08-06  7:28 ` [PATCH 3/5] _hg: add forget, phase, summary Anton Shestakov
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06  7:28 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

http://zsh.sourceforge.net/Doc/Release/Completion-System.html says that
when ->string form is used for _arguments, the function that calls it
must declare appropriate local parameters.

&& ret=0 is also needed (not sure why, the help page doesn't explain
it), otherwise completing `hg diff -<TAB>` doesn't look right.
---
 Completion/Unix/Command/_hg | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 50ab7132c..693e0c4bd 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -523,14 +523,16 @@ _hg_cmd_copy() {
 }
 
 _hg_cmd_diff() {
+  local context state state_descr line
   typeset -A opt_args
+
   _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
   '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
   '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
   '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
   '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \
   '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \
-  '*:file:->diff_files'
+  '*:file:->diff_files' && ret=0
 
   if [[ $state == 'diff_files' ]]
   then
@@ -698,14 +700,14 @@ _hg_cmd_rename() {
 }
 
 _hg_cmd_resolve() {
-  local context state line
+  local context state state_descr line
   typeset -A opt_args
 
   _arguments -s : $_hg_global_opts \
   '(--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
@@ -715,14 +717,14 @@ _hg_cmd_resolve() {
 }
 
 _hg_cmd_revert() {
-  local context state line
+  local context state state_descr line
   typeset -A opt_args
 
   _arguments -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_tags' \
   '--no-backup[do not save backup copies of files]' \
-  '*:file:->diff_files'
+  '*:file:->diff_files' && ret=0
 
   if [[ $state == 'diff_files' ]]
   then
-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/5] _hg: add forget, phase, summary
  2018-08-06  7:28 [PATCH 0/5] An update for Completion/Unix/Command/_hg Anton Shestakov
  2018-08-06  7:28 ` [PATCH 1/5] _hg: rename _hg_style_opts to _hg_template_opts Anton Shestakov
  2018-08-06  7:28 ` [PATCH 2/5] _hg: declare appropriate local parameters for ->string form Anton Shestakov
@ 2018-08-06  7:28 ` Anton Shestakov
  2018-08-06  7:28 ` [PATCH 4/5] _hg: update all options Anton Shestakov
  2018-08-06  7:28 ` [PATCH 5/5] _hg: drop -w, add -S to _arguments Anton Shestakov
  4 siblings, 0 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06  7:28 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

---
 Completion/Unix/Command/_hg | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 693e0c4bd..9ae49e3ad 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -552,6 +552,11 @@ _hg_cmd_export() {
   '*:revision:_hg_tags'
 }
 
+_hg_cmd_forget() {
+  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  '*:file:_hg_files'
+}
+
 _hg_cmd_grep() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
   '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
@@ -666,6 +671,16 @@ _hg_cmd_paths() {
   ':path:_hg_paths'
 }
 
+_hg_cmd_phase() {
+  _arguments -s : $_hg_global_opts \
+  '(--public -p --draft -d --secret -s)'{-p,--public}'[set changeset phase to public]' \
+  '(--public -p --draft -d --secret -s)'{-d,--draft}'[set changeset phase to draft]' \
+  '(--public -p --draft -d --secret -s)'{-s,--secret}'[set changeset phase to secret]' \
+  '(--force -f)'{-f,--force}'[allow to move boundary backward]' \
+  '*'{-r+,--rev=}'[target revision]:revision:_hg_tags' \
+  '*:revision:_hg_tags'
+}
+
 _hg_cmd_pull() {
   _arguments -s : $_hg_global_opts $_hg_remote_opts \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
@@ -776,6 +791,11 @@ _hg_cmd_status() {
   '*:files:_files'
 }
 
+_hg_cmd_summary() {
+  _arguments -s : $_hg_global_opts \
+  '--remote[check for push and pull]'
+}
+
 _hg_cmd_tag() {
   _arguments -s : $_hg_global_opts \
   '(--local -l)'{-l,--local}'[make the tag local]' \
-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/5] _hg: update all options
  2018-08-06  7:28 [PATCH 0/5] An update for Completion/Unix/Command/_hg Anton Shestakov
                   ` (2 preceding siblings ...)
  2018-08-06  7:28 ` [PATCH 3/5] _hg: add forget, phase, summary Anton Shestakov
@ 2018-08-06  7:28 ` Anton Shestakov
  2018-08-06  7:28 ` [PATCH 5/5] _hg: drop -w, add -S to _arguments Anton Shestakov
  4 siblings, 0 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06  7:28 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

Sorry to do this in one big lump, but it's just too hard to split this
patch. What it does:

- adds missing flags
- removes flags that are no longer there
- updates flag descriptions and argument names
- adds * where using the same option many times is okay
- adds + and = to options that need arguments
- removes + and = from options that don't take any arguments
- groups with () mutually exclusive flags that can't be used together

Other things to note:

--encoding and --encodingmode do have default values, but they depend on
local setup, so it's better not to hardcode them here.
---
 Completion/Unix/Command/_hg | 187 +++++++++++++++++++++++++++-----------------
 1 file changed, 117 insertions(+), 70 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 9ae49e3ad..5164828e0 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -359,22 +359,22 @@ _hg_clone_dest() {
 
 # Common options
 _hg_global_opts=(
-    '(--repository -R)'{-R+,--repository=}'[repository root directory]:repository:_files -/'
-    '--cwd[change working directory]:new working directory:_files -/'
-    '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]'
+    '(--repository -R)'{-R+,--repository=}'[repository root directory or name of overlay bundle file]:repository:_files -/'
+    '--cwd=[change working directory]:new working directory:_files -/'
+    '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, automatically pick the first choice for all prompts]'
     '(--verbose -v)'{-v,--verbose}'[enable additional output]'
     '*--config[set/override config option]:defined config items:_hg_config'
     '(--quiet -q)'{-q,--quiet}'[suppress output]'
     '(--help -h)'{-h,--help}'[display help and exit]'
-    '--debug[debug mode]'
+    '--debug[enable debugging output]'
     '--debugger[start debugger]'
-    '--encoding[set the charset encoding (default: UTF8)]'
-    '--encodingmode[set the charset encoding mode (default: strict)]'
-    '--lsprof[print improved command execution profile]'
-    '--traceback[print traceback on exception]'
+    '--encoding=[set the charset encoding]:encoding'
+    '--encodingmode=[set the charset encoding mode]:encoding mode'
+    '--traceback[always print a traceback on exception]'
     '--time[time how long the command takes]'
-    '--profile[profile]'
+    '--profile[print command execution profile]'
     '--version[output version information and exit]'
+    '--hidden[consider hidden changesets]'
 )
 
 _hg_pat_opts=(
@@ -384,7 +384,8 @@ _hg_pat_opts=(
 _hg_diff_opts=(
   '(--text -a)'{-a,--text}'[treat all files as text]'
   '(--git -g)'{-g,--git}'[use git extended diff format]'
-  "--nodates[don't include dates in diff headers]")
+  '--nodates[omit dates from diff headers]'
+)
 
 _hg_dryrun_opts=(
   '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]')
@@ -399,8 +400,10 @@ _hg_commit_opts=(
   '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from <file>]:log file:_files')
 
 _hg_remote_opts=(
-  '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:'
-  '--remotecmd[specify hg command to run on the remote side]:')
+  '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:command'
+  '--remotecmd=[specify hg command to run on the remote side]:remote command'
+  '--insecure[do not verify server certificate (ignoring web.cacerts config)]'
+)
 
 _hg_cmd() {
   _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \
@@ -414,26 +417,28 @@ _hg_cmd_add() {
 
 _hg_cmd_addremove() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
-  '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:' \
+  '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \
   '*:unknown or missing files:_hg_addremove'
 }
 
 _hg_cmd_annotate() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
   '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_tags' \
-  '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \
+  "--no-follow[don't follow copies and renames]" \
   '(--text -a)'{-a,--text}'[treat all files as text]' \
-  '(--user -u)'{-u,--user}'[list the author]' \
-  '(--date -d)'{-d,--date}'[list the date]' \
+  '(--user -u)'{-u,--user}'[list the author (long with -v)]' \
+  '(--file -f)'{-f,--file}'[list the filename]' \
+  '(--date -d)'{-d,--date}'[list the date (short with -q)]' \
   '(--number -n)'{-n,--number}'[list the revision number (default)]' \
   '(--changeset -c)'{-c,--changeset}'[list the changeset]' \
+  '(--line-number -l)'{-l,--line-number}'[show line number at the first appearance]' \
   '*:files:_hg_files'
 }
 
 _hg_cmd_archive() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
   '--no-decode[do not pass files through decoders]' \
-  '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:' \
+  '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:prefix' \
   '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_tags' \
   '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \
   '*:destination:_files'
@@ -442,9 +447,9 @@ _hg_cmd_archive() {
 _hg_cmd_backout() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
     '--merge[merge with old dirstate parent after backout]' \
-    '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
+    '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
     '--parent[parent to choose when backing out merge]' \
-    '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
+    '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
     '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
     '(--message -m)'{-m+,--message=}'[specify commit message]:text' \
     '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files'
@@ -453,6 +458,7 @@ _hg_cmd_backout() {
 _hg_cmd_bisect() {
   _arguments -s : $_hg_global_opts \
   '(-)'{-r,--reset}'[reset bisect state]' \
+  '(--extend -e)'{-e,--extend}'[extend the bisect range]' \
   '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \
   '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_tags \
   '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \
@@ -463,9 +469,9 @@ _hg_cmd_bisect() {
 _hg_cmd_bookmarks() {
   _arguments -s : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[force]' \
-  '(--rev -r)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \
-  '(--delete -d)'{-d,--delete}'[delete a given bookmark]' \
-  '(--rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \
+  '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \
+  '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
+  '(--rev -r --delete -d --rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \
   '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \
   ':bookmark:_hg_bookmarks_internal'
 }
@@ -478,21 +484,26 @@ _hg_cmd_branch() {
 
 _hg_cmd_branches() {
   _arguments -s : $_hg_global_opts \
-  '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]'
+  '(--closed -c)'{-c,--closed}'[show normal and closed branches]'
 }
 
 _hg_cmd_bundle() {
   _arguments -s : $_hg_global_opts $_hg_remote_opts \
-  '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \
-  '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \
+  '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \
+  '(2)*--base[a base changeset assumed to be available at the destination]:revision:_hg_tags' \
+  '*'{-b+,--branch=}'[a specific branch you would like to bundle]:branch:_hg_branches_internal' \
+  '*'{-r+,--rev=}'[a changeset intended to be added to the destination]:revision:_hg_tags' \
+  '--all[bundle all changesets in the repository]' \
+  '--type[bundle compression type to use (default: bzip2)]:bundle type' \
   ':output file:_files' \
   ':destination repository:_files -/'
 }
 
 _hg_cmd_cat() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
-  '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:filespec:' \
+  '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \
   '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
+  '--decode[apply any matching decode filter]' \
   '*:file:_hg_files'
 }
 
@@ -510,8 +521,12 @@ _hg_cmd_commit() {
   '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
   '(--message -m)'{-m+,--message=}'[specify commit message]:text' \
   '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' \
-  '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
-  '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
+  '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
+  '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
+  '--amend[amend the parent of the working directory]' \
+  '--close-branch[mark a branch head as closed]' \
+  '(--interactive -i)'{-i,--interactive}'[use interactive mode]' \
+  '(--secret -s)'{-s,--secret}'[use the secret phase for committing]' \
   '*:file:_hg_committable'
 }
 
@@ -547,7 +562,7 @@ _hg_cmd_diff() {
 
 _hg_cmd_export() {
   _arguments -s : $_hg_global_opts $_hg_diff_opts \
-  '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \
+  '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \
   '--switch-parent[diff against the second parent]' \
   '*:revision:_hg_tags'
 }
@@ -573,28 +588,42 @@ _hg_cmd_grep() {
 
 _hg_cmd_heads() {
   _arguments -s : $_hg_global_opts $_hg_template_opts \
+  '(--topo -t)'{-t,--topo}'[show topological heads only]' \
+  '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \
   '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags'
 }
 
 _hg_cmd_help() {
   _arguments -s : $_hg_global_opts \
+  '(--extension -e)'{-e,--extension}'[show only help for extensions]' \
+  '(--command -c)'{-c,--command}'[show only help for commands]' \
+  '(--keyword -k)'{-k,--keyword}'[show topics matching keyword]' \
   '*:mercurial command:_hg_commands'
 }
 
 _hg_cmd_identify() {
   _arguments -s : $_hg_global_opts \
   '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_tags' \
-  '(--num -n)'{-n+,--num=}'[show local revision number]' \
-  '(--id -i)'{-i+,--id=}'[show global revision id]' \
-  '(--branch -b)'{-b+,--branch=}'[show branch]' \
-  '(--tags -t)'{-t+,--tags=}'[show tags]'
+  '(--num -n)'{-n,--num}'[show local revision number]' \
+  '(--id -i)'{-i,--id}'[show global revision id]' \
+  '(--branch -b)'{-b,--branch}'[show branch]' \
+  '(--tags -t)'{-t,--tags}'[show tags]' \
+  '(--bookmarks -B)'{-B,--bookmarks}'[show bookmarks]'
 }
 
 _hg_cmd_import() {
   _arguments -s : $_hg_global_opts \
-  '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count:' \
+  '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count' \
   '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \
   '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
+  '--bypass[apply patch without touching the working directory]' \
+  '--no-commit[do not commit, just update the working directory]' \
+  '--partial[commit even if some hunks fail]' \
+  '--exact[abort if patch would apply lossily]' \
+  '--import-branch[use any branch information in patch (implied by --exact)]' \
+  '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
+  '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
+  '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \
   '*:patch:_files'
 }
 
@@ -603,7 +632,7 @@ _hg_cmd_incoming() {
   '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
-  '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \
+  '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_tags' \
   '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
   '--bundle[file to store the bundles into]:bundle file:_files' \
   ':source:_hg_remote'
@@ -618,7 +647,7 @@ _hg_cmd_locate() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
   '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_tags' \
   '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
-  '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \
+  '(--fullpath -f)'{-f,--fullpath}'[print complete paths from the filesystem root]' \
   '*:search pattern:_hg_files'
 }
 
@@ -627,25 +656,26 @@ _hg_cmd_log() {
   '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
   '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
   '(--copies -C)'{-C,--copies}'[show copied files]' \
-  '(--keyword -k)'{-k+,--keyword=}'[search for a keyword]:' \
-  '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \
-  '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \
+  '*'{-k+,--keyword=}'[search for a keyword]:keyword' \
+  '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \
+  '*'{-r+,--rev=}'[show the specified revision or revset]:revision:_hg_revrange' \
   '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \
   '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
-  '(--prune -P)'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
+  '*'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \
   '*:files:_hg_files'
 }
 
 _hg_cmd_manifest() {
   _arguments -s : $_hg_global_opts \
+  '--all[list files from all revisions]' \
   ':revision:_hg_tags'
 }
 
 _hg_cmd_merge() {
   _arguments -s : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
-  '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \
+  '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \
   '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
   ':revision:_hg_mergerevs'
 }
@@ -655,7 +685,7 @@ _hg_cmd_outgoing() {
   '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
-  '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]' \
+  '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \
   '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
   ':destination:_hg_remote'
 }
@@ -685,25 +715,24 @@ _hg_cmd_pull() {
   _arguments -s : $_hg_global_opts $_hg_remote_opts \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
-  '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:' \
+  '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision' \
   ':source:_hg_remote'
 }
 
 _hg_cmd_push() {
   _arguments -s : $_hg_global_opts $_hg_remote_opts \
   '(--force -f)'{-f,--force}'[force push]' \
-  '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]:revision:_hg_tags' \
+  '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \
   '*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \
   '*'{-b,--branch=}'[branch to push]:branch:_hg_branches_internal' \
-  '--insecure[do not verify server certificate]' \
   '--new-branch[allow pushing a new branch]' \
   ':destination:_hg_remote'
 }
 
 _hg_cmd_remove() {
   _arguments -s : $_hg_global_opts $_hg_pat_opts \
-  '(--after -A)'{-A,--after}'[record remove that has already occurred]' \
-  '(--force -f)'{-f,--force}'[remove file even if modified]' \
+  '(--after -A)'{-A,--after}'[record delete for missing files]' \
+  '(--force -f)'{-f,--force}'[forget added files, delete modified files]' \
   '*:file:_hg_files'
 }
 
@@ -719,9 +748,11 @@ _hg_cmd_resolve() {
   typeset -A opt_args
 
   _arguments -s : $_hg_global_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' \
+  '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[mark files as unresolved]:*:resolved files:_hg_resolved' \
   '*:file:_hg_unresolved' && ret=0
 
   if [[ $state == 'resolve_files' ]]
@@ -738,7 +769,8 @@ _hg_cmd_revert() {
   _arguments -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_tags' \
-  '--no-backup[do not save backup copies of files]' \
+  '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
+  '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \
   '*:file:->diff_files' && ret=0
 
   if [[ $state == 'diff_files' ]]
@@ -756,21 +788,29 @@ _hg_cmd_revert() {
 
 _hg_cmd_serve() {
   _arguments -s : $_hg_global_opts \
-  '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file]:log file:_files' \
-  '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file]:log file:_files' \
+  '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file to write to]:log file:_files' \
+  '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file to write to]:log file:_files' \
   '(--daemon -d)'{-d,--daemon}'[run server in background]' \
-  '(--port -p)'{-p+,--port=}'[listen port]:listen port:' \
-  '(--address -a)'{-a+,--address=}'[interface address]:interface address:' \
-  '(--name -n)'{-n+,--name=}'[name to show in web pages]:repository name:' \
-  '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \
-  '--style[web template style]:style' \
+  '(--port -p)'{-p+,--port=}'[port to listen on (default: 8000)]:listen port' \
+  '(--address -a)'{-a+,--address=}'[address to listen on (default: all interfaces)]:interface address' \
+  '--prefix[prefix path to serve from (default: server root)]:prefix' \
+  '(--name -n)'{-n+,--name=}'[name to show in web pages (default: working directory)]:repository name' \
+  '--web-conf=[name of the hgweb config file]:config file:_files' \
+  '--pid-file=[name of file to write process ID to]:pid file:_files' \
+  '--cmdserver[for remote clients]' \
+  '(--templates -t)'{-t+,--templates=}'[web template directory]:template dir:_files -/' \
+  '--style=[web template style]:style' \
   '--stdio[for remote clients]' \
-  '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]'
+  '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' \
+  '--certificate=[SSL certificate file]:certificate file:_files'
 }
 
 _hg_cmd_showconfig() {
   _arguments -s : $_hg_global_opts \
-  '(--untrusted -u)'{-u+,--untrusted=}'[show untrusted configuration options]' \
+  '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \
+  '(--edit -e)'{-e,--edit}'[edit user config]' \
+  '(--local -l --global -g)'{-l,--local}'[edit repository config]' \
+  '(--local -l --global -g)'{-g,--global}'[edit global config]' \
   ':config item:_hg_config'
 }
 
@@ -782,12 +822,13 @@ _hg_cmd_status() {
   '(--removed -r)'{-r,--removed}'[show only removed files]' \
   '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \
   '(--clean -c)'{-c,--clean}'[show only files without changes]' \
-  '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \
+  '(--unknown -u)'{-u,--unknown}'[show only unknown (not tracked) files]' \
   '(--ignored -i)'{-i,--ignored}'[show ignored files]' \
   '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \
   '(--copies -C)'{-C,--copies}'[show source of copied files]' \
   '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
-  '--rev[show difference from revision]:revision:_hg_tags' \
+  '*--rev=[show difference from revision]:revision:_hg_tags' \
+  '--change=[list the changed files of a revision]:revision:_hg_tags' \
   '*:files:_files'
 }
 
@@ -799,10 +840,12 @@ _hg_cmd_summary() {
 _hg_cmd_tag() {
   _arguments -s : $_hg_global_opts \
   '(--local -l)'{-l,--local}'[make the tag local]' \
-  '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message:' \
-  '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \
-  '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \
+  '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message' \
+  '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
+  '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \
   '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_tags' \
+  '(--force -f)'{-f,--force}'[force tag]' \
+  '--remove[remove a tag]' \
   ':tag name:'
 }
 
@@ -814,12 +857,14 @@ _hg_cmd_tip() {
 _hg_cmd_unbundle() {
   _arguments -s : $_hg_global_opts \
   '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
-  ':files:_files'
+  '*:files:_files'
 }
 
 _hg_cmd_update() {
   _arguments -s : $_hg_global_opts \
-  '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \
+  '(--clean -C)'{-C,--clean}'[discard uncommitted changes (no backup)]' \
+  '(--check -c)'{-c,--check}'[require clean working directory]' \
+  '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \
   '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
   ':revision:_hg_tags'
 }
@@ -827,7 +872,7 @@ _hg_cmd_update() {
 # HGK
 _hg_cmd_view() {
   _arguments -s : $_hg_global_opts \
-  '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \
+  '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \
   ':revision range:_hg_tags'
 }
 
@@ -999,10 +1044,12 @@ _hg_cmd_qtop() {
 
 _hg_cmd_strip() {
   _arguments -s : $_hg_global_opts \
-  '(--force -f)'{-f,--force}'[force multi-head removal]' \
-  '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \
-  '(--nobackup -n)'{-n,--nobackup}'[no backups]' \
-  ':revision:_hg_tags'
+  '*'{-r+,--rev=}'[revision]:revision:_hg_tags' \
+  '(--force -f)'{-f,--force}'[force removal of changesets, discard uncommitted changes (no backup)]' \
+  '--no-backup[no backups]' \
+  '(--keep -k)'{-k,--keep}'[do not modify working directory during strip]' \
+  '*'{-B+,--bookmark=}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks_internal' \
+  '*:revision:_hg_tags'
 }
 
 _hg "$@"
-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/5] _hg: drop -w, add -S to _arguments
  2018-08-06  7:28 [PATCH 0/5] An update for Completion/Unix/Command/_hg Anton Shestakov
                   ` (3 preceding siblings ...)
  2018-08-06  7:28 ` [PATCH 4/5] _hg: update all options Anton Shestakov
@ 2018-08-06  7:28 ` Anton Shestakov
  4 siblings, 0 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06  7:28 UTC (permalink / raw)
  To: zsh-workers; +Cc: Anton Shestakov

-w was already removed in 92584634d3d39e9ca64475ae5af8010e2ccebe24, just
not in these two instances, but looks like it makes sense to disable
"-xy Xarg Yarg" everywhere, Mercurial doesn't even support that.

What it does support is "--" to delimit command line flags and file
names. So let's add -S to all _arguments (all command lines to hg go
through the same parser).
---
 Completion/Unix/Command/_hg | 138 ++++++++++++++++++++++----------------------
 1 file changed, 69 insertions(+), 69 deletions(-)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 5164828e0..66adcbfeb 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -82,7 +82,7 @@ _hg() {
 
   if [[ -z "$cmd" ]]
   then
-    _arguments -s -w : $_hg_global_opts \
+    _arguments -s -S : $_hg_global_opts \
     ':mercurial command:_hg_commands'
     return
   fi
@@ -119,7 +119,7 @@ _hg() {
     _hg_cmd_${cmd}
   else
     # complete unknown commands normally
-    _arguments -s -w : $_hg_global_opts \
+    _arguments -s -S : $_hg_global_opts \
       '*:files:_hg_files'
   fi
 }
@@ -411,18 +411,18 @@ _hg_cmd() {
 }
 
 _hg_cmd_add() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
   '*:unknown files:_hg_unknown'
 }
 
 _hg_cmd_addremove() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
   '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \
   '*:unknown or missing files:_hg_addremove'
 }
 
 _hg_cmd_annotate() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_tags' \
   "--no-follow[don't follow copies and renames]" \
   '(--text -a)'{-a,--text}'[treat all files as text]' \
@@ -436,7 +436,7 @@ _hg_cmd_annotate() {
 }
 
 _hg_cmd_archive() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '--no-decode[do not pass files through decoders]' \
   '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:prefix' \
   '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_tags' \
@@ -445,7 +445,7 @@ _hg_cmd_archive() {
 }
 
 _hg_cmd_backout() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
     '--merge[merge with old dirstate parent after backout]' \
     '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
     '--parent[parent to choose when backing out merge]' \
@@ -456,7 +456,7 @@ _hg_cmd_backout() {
 }
 
 _hg_cmd_bisect() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(-)'{-r,--reset}'[reset bisect state]' \
   '(--extend -e)'{-e,--extend}'[extend the bisect range]' \
   '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \
@@ -467,7 +467,7 @@ _hg_cmd_bisect() {
 }
 
 _hg_cmd_bookmarks() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[force]' \
   '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \
   '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \
@@ -477,18 +477,18 @@ _hg_cmd_bookmarks() {
 }
 
 _hg_cmd_branch() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \
   '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]'
 }
 
 _hg_cmd_branches() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--closed -c)'{-c,--closed}'[show normal and closed branches]'
 }
 
 _hg_cmd_bundle() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
   '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \
   '(2)*--base[a base changeset assumed to be available at the destination]:revision:_hg_tags' \
   '*'{-b+,--branch=}'[a specific branch you would like to bundle]:branch:_hg_branches_internal' \
@@ -500,7 +500,7 @@ _hg_cmd_bundle() {
 }
 
 _hg_cmd_cat() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \
   '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \
   '--decode[apply any matching decode filter]' \
@@ -508,7 +508,7 @@ _hg_cmd_cat() {
 }
 
 _hg_cmd_clone() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
   '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \
   '(--rev -r)'{-r+,--rev=}'[a changeset you would like to have after cloning]:' \
   '--uncompressed[use uncompressed transfer (fast over LAN)]' \
@@ -517,7 +517,7 @@ _hg_cmd_clone() {
 }
 
 _hg_cmd_commit() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \
   '(--message -m)'{-m+,--message=}'[specify commit message]:text' \
   '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' \
@@ -531,7 +531,7 @@ _hg_cmd_commit() {
 }
 
 _hg_cmd_copy() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
   '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \
   '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
   '*:file:_hg_files'
@@ -541,7 +541,7 @@ _hg_cmd_diff() {
   local context state state_descr line
   typeset -A opt_args
 
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \
   '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \
   '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \
   '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \
@@ -561,19 +561,19 @@ _hg_cmd_diff() {
 }
 
 _hg_cmd_export() {
-  _arguments -s : $_hg_global_opts $_hg_diff_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_diff_opts \
   '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \
   '--switch-parent[diff against the second parent]' \
   '*:revision:_hg_tags'
 }
 
 _hg_cmd_forget() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '*:file:_hg_files'
 }
 
 _hg_cmd_grep() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \
   '--all[print all revisions with matches]' \
   '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \
@@ -587,14 +587,14 @@ _hg_cmd_grep() {
 }
 
 _hg_cmd_heads() {
-  _arguments -s : $_hg_global_opts $_hg_template_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_template_opts \
   '(--topo -t)'{-t,--topo}'[show topological heads only]' \
   '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \
   '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags'
 }
 
 _hg_cmd_help() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--extension -e)'{-e,--extension}'[show only help for extensions]' \
   '(--command -c)'{-c,--command}'[show only help for commands]' \
   '(--keyword -k)'{-k,--keyword}'[show topics matching keyword]' \
@@ -602,7 +602,7 @@ _hg_cmd_help() {
 }
 
 _hg_cmd_identify() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_tags' \
   '(--num -n)'{-n,--num}'[show local revision number]' \
   '(--id -i)'{-i,--id}'[show global revision id]' \
@@ -612,7 +612,7 @@ _hg_cmd_identify() {
 }
 
 _hg_cmd_import() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count' \
   '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \
   '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \
@@ -628,7 +628,7 @@ _hg_cmd_import() {
 }
 
 _hg_cmd_incoming() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_template_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts \
   '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
@@ -639,12 +639,12 @@ _hg_cmd_incoming() {
 }
 
 _hg_cmd_init() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
   ':dir:_files -/'
 }
 
 _hg_cmd_locate() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_tags' \
   '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \
   '(--fullpath -f)'{-f,--fullpath}'[print complete paths from the filesystem root]' \
@@ -652,7 +652,7 @@ _hg_cmd_locate() {
 }
 
 _hg_cmd_log() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_template_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_template_opts \
   '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \
   '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \
   '(--copies -C)'{-C,--copies}'[show copied files]' \
@@ -667,13 +667,13 @@ _hg_cmd_log() {
 }
 
 _hg_cmd_manifest() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '--all[list files from all revisions]' \
   ':revision:_hg_tags'
 }
 
 _hg_cmd_merge() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \
   '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \
   '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \
@@ -681,7 +681,7 @@ _hg_cmd_merge() {
 }
 
 _hg_cmd_outgoing() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_template_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts \
   '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--patch -p)'{-p,--patch}'[show patch]' \
@@ -691,18 +691,18 @@ _hg_cmd_outgoing() {
 }
 
 _hg_cmd_parents() {
-  _arguments -s : $_hg_global_opts $_hg_template_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_template_opts \
   '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_tags' \
   ':last modified file:_hg_files'
 }
 
 _hg_cmd_paths() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   ':path:_hg_paths'
 }
 
 _hg_cmd_phase() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--public -p --draft -d --secret -s)'{-p,--public}'[set changeset phase to public]' \
   '(--public -p --draft -d --secret -s)'{-d,--draft}'[set changeset phase to draft]' \
   '(--public -p --draft -d --secret -s)'{-s,--secret}'[set changeset phase to secret]' \
@@ -712,7 +712,7 @@ _hg_cmd_phase() {
 }
 
 _hg_cmd_pull() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
   '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \
   '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \
   '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision' \
@@ -720,7 +720,7 @@ _hg_cmd_pull() {
 }
 
 _hg_cmd_push() {
-  _arguments -s : $_hg_global_opts $_hg_remote_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_remote_opts \
   '(--force -f)'{-f,--force}'[force push]' \
   '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \
   '*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \
@@ -730,14 +730,14 @@ _hg_cmd_push() {
 }
 
 _hg_cmd_remove() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--after -A)'{-A,--after}'[record delete for missing files]' \
   '(--force -f)'{-f,--force}'[forget added files, delete modified files]' \
   '*:file:_hg_files'
 }
 
 _hg_cmd_rename() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
   '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \
   '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \
   '*:file:_hg_files'
@@ -747,7 +747,7 @@ _hg_cmd_resolve() {
   local context state state_descr line
   typeset -A opt_args
 
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_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' \
@@ -766,7 +766,7 @@ _hg_cmd_revert() {
   local context state state_descr line
   typeset -A opt_args
 
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \
+  _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_tags' \
   '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \
@@ -787,7 +787,7 @@ _hg_cmd_revert() {
 }
 
 _hg_cmd_serve() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file to write to]:log file:_files' \
   '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file to write to]:log file:_files' \
   '(--daemon -d)'{-d,--daemon}'[run server in background]' \
@@ -806,7 +806,7 @@ _hg_cmd_serve() {
 }
 
 _hg_cmd_showconfig() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \
   '(--edit -e)'{-e,--edit}'[edit user config]' \
   '(--local -l --global -g)'{-l,--local}'[edit repository config]' \
@@ -815,7 +815,7 @@ _hg_cmd_showconfig() {
 }
 
 _hg_cmd_status() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '(--all -A)'{-A,--all}'[show status of all files]' \
   '(--modified -m)'{-m,--modified}'[show only modified files]' \
   '(--added -a)'{-a,--added}'[show only added files]' \
@@ -833,12 +833,12 @@ _hg_cmd_status() {
 }
 
 _hg_cmd_summary() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '--remote[check for push and pull]'
 }
 
 _hg_cmd_tag() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--local -l)'{-l,--local}'[make the tag local]' \
   '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message' \
   '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \
@@ -850,18 +850,18 @@ _hg_cmd_tag() {
 }
 
 _hg_cmd_tip() {
-  _arguments -s : $_hg_global_opts $_hg_template_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_template_opts \
   '(--patch -p)'{-p,--patch}'[show patch]'
 }
 
 _hg_cmd_unbundle() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \
   '*:files:_files'
 }
 
 _hg_cmd_update() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--clean -C)'{-C,--clean}'[discard uncommitted changes (no backup)]' \
   '(--check -c)'{-c,--check}'[require clean working directory]' \
   '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \
@@ -871,7 +871,7 @@ _hg_cmd_update() {
 
 # HGK
 _hg_cmd_view() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \
   ':revision range:_hg_tags'
 }
@@ -926,35 +926,35 @@ _hg_qseries_opts=(
   '(--summary -s)'{-s,--summary}'[print first line of patch header]')
 
 _hg_cmd_qapplied() {
-  _arguments -s : $_hg_global_opts $_hg_qseries_opts
+  _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
 }
 
 _hg_cmd_qdelete() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--keep -k)'{-k,--keep}'[keep patch file]' \
   '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \
   '*:unapplied patch:_hg_qdeletable'
 }
 
 _hg_cmd_qdiff() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts \
   '*:pattern:_hg_files'
 }
 
 _hg_cmd_qfold() {
-  _arguments -s : $_hg_global_opts $_h_commit_opts \
+  _arguments -s -S : $_hg_global_opts $_h_commit_opts \
   '(--keep -k)'{-k,--keep}'[keep folded patch files]' \
   '*:unapplied patch:_hg_qunapplied'
 }
 
 _hg_cmd_qgoto() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--force -f)'{-f,--force}'[overwrite any local changes]' \
   ':patch:_hg_qseries'
 }
 
 _hg_cmd_qguard() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--list -l)'{-l,--list}'[list all patches and guards]' \
   '(--none -n)'{-n,--none}'[drop all guards]' \
   ':patch:_hg_qseries' \
@@ -962,12 +962,12 @@ _hg_cmd_qguard() {
 }
 
 _hg_cmd_qheader() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   ':patch:_hg_qseries'
 }
 
 _hg_cmd_qimport() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--existing -e)'{-e,--existing}'[import file in patch dir]' \
   '(--name -n 2)'{-n+,--name=}'[patch file name]:name:' \
   '(--force -f)'{-f,--force}'[overwrite existing files]' \
@@ -976,17 +976,17 @@ _hg_cmd_qimport() {
 }
 
 _hg_cmd_qnew() {
-  _arguments -s : $_hg_global_opts $_hg_commit_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_commit_opts \
   '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \
   ':patch:'
 }
 
 _hg_cmd_qnext() {
-  _arguments -s : $_hg_global_opts $_hg_qseries_opts
+  _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
 }
 
 _hg_cmd_qpop() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--all -a :)'{-a,--all}'[pop all patches]' \
   '(--name -n)'{-n+,--name=}'[queue name to pop]:' \
   '(--force -f)'{-f,--force}'[forget any local changes]' \
@@ -994,11 +994,11 @@ _hg_cmd_qpop() {
 }
 
 _hg_cmd_qprev() {
-  _arguments -s : $_hg_global_opts $_hg_qseries_opts
+  _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
 }
 
 _hg_cmd_qpush() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--all -a :)'{-a,--all}'[apply all patches]' \
   '(--list -l)'{-l,--list}'[list patch name in commit text]' \
   '(--merge -m)'{-m+,--merge=}'[merge from another queue]:' \
@@ -1008,20 +1008,20 @@ _hg_cmd_qpush() {
 }
 
 _hg_cmd_qrefresh() {
-  _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \
   '(--git -g)'{-g,--git}'[use git extended diff format]' \
   '(--short -s)'{-s,--short}'[short refresh]' \
   '*:files:_hg_files'
 }
 
 _hg_cmd_qrename() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   ':patch:_hg_qseries' \
   ':destination:'
 }
 
 _hg_cmd_qselect() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '(--none -n :)'{-n,--none}'[disable all guards]' \
   '(--series -s :)'{-s,--series}'[list all guards in series file]' \
   '--pop[pop to before first guarded applied patch]' \
@@ -1030,20 +1030,20 @@ _hg_cmd_qselect() {
 }
 
 _hg_cmd_qseries() {
-  _arguments -s : $_hg_global_opts $_hg_qseries_opts \
+  _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \
   '(--missing -m)'{-m,--missing}'[print patches not in series]'
 }
 
 _hg_cmd_qunapplied() {
-  _arguments -s : $_hg_global_opts $_hg_qseries_opts
+  _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
 }
 
 _hg_cmd_qtop() {
-  _arguments -s : $_hg_global_opts $_hg_qseries_opts
+  _arguments -s -S : $_hg_global_opts $_hg_qseries_opts
 }
 
 _hg_cmd_strip() {
-  _arguments -s : $_hg_global_opts \
+  _arguments -s -S : $_hg_global_opts \
   '*'{-r+,--rev=}'[revision]:revision:_hg_tags' \
   '(--force -f)'{-f,--force}'[force removal of changesets, discard uncommitted changes (no backup)]' \
   '--no-backup[no backups]' \
-- 
2.11.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06  7:28 ` [PATCH 2/5] _hg: declare appropriate local parameters for ->string form Anton Shestakov
@ 2018-08-06  9:20   ` Daniel Shahaf
  2018-08-06  9:29     ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Shahaf @ 2018-08-06  9:20 UTC (permalink / raw)
  To: Anton Shestakov; +Cc: zsh-workers

Anton Shestakov wrote on Mon, Aug 06, 2018 at 15:28:10 +0800:
> && ret=0 is also needed (not sure why, the help page doesn't explain
> it), otherwise completing `hg diff -<TAB>` doesn't look right.

Completion functions are supposed to return 0 if they added at least one match
and non-zero otherwise.  It's common for completion functions to have the
following form:

    local ret=1
    _foo && ret=0
    return ret

(usually with some code before/after the call to _foo)

Simply adding '&&ret=0' without declaring 'ret' local is a bug: it sets the
variable in the caller's scope.  Furthermore, if 'ret' were declared local,
setting it to 0 without using it afterwards would naturally have no effect.

I'm not sure what the correct fix is.

>

To -workers, couldn't we write a wrapper such as the following:

    _added_matches_p() {
        local nmatches=$compstate[nmatches]
        "$@"
        (( nmatches < $compstate[nmatches] ))
    }

to reduce the need to manage $ret in every single layer of the callstack?

>

Cheers,

Daniel

> @@ -715,14 +717,14 @@ _hg_cmd_resolve() {
>  }
>  
>  _hg_cmd_revert() {
> -  local context state line
> +  local context state state_descr line
>    typeset -A opt_args
>  
>    _arguments -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_tags' \
>    '--no-backup[do not save backup copies of files]' \
> -  '*:file:->diff_files'
> +  '*:file:->diff_files' && ret=0
>  
>    if [[ $state == 'diff_files' ]]
>    then


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06  9:20   ` Daniel Shahaf
@ 2018-08-06  9:29     ` Peter Stephenson
  2018-08-06 11:09       ` Anton Shestakov
  2018-08-06 12:06       ` Daniel Shahaf
  0 siblings, 2 replies; 16+ messages in thread
From: Peter Stephenson @ 2018-08-06  9:29 UTC (permalink / raw)
  To: zsh-workers

On Mon, 6 Aug 2018 09:20:32 +0000
Daniel Shahaf <d.s@daniel.shahaf.name> wrote:

> Anton Shestakov wrote on Mon, Aug 06, 2018 at 15:28:10 +0800:
> > && ret=0 is also needed (not sure why, the help page doesn't explain
> > it), otherwise completing `hg diff -<TAB>` doesn't look right.  
> 
> Completion functions are supposed to return 0 if they added at least
> one match and non-zero otherwise.  It's common for completion
> functions to have the following form:
> 
>     local ret=1
>     _foo && ret=0
>     return ret
> 
> (usually with some code before/after the call to _foo)
> 
> Simply adding '&&ret=0' without declaring 'ret' local is a bug: it
> sets the variable in the caller's scope.  Furthermore, if 'ret' were
> declared local, setting it to 0 without using it afterwards would
> naturally have no effect.
> 
> I'm not sure what the correct fix is.

I don't see why it isn't just a local question in _hg_cmd_revert?

It needs to declare ret and combine the effect with the stuff in the
following block, then return ret explicitly.  I wouldn't be surprised if
_hg_cmd_resolve just above needed something similar.

> To -workers, couldn't we write a wrapper such as the following:
> 
>     _added_matches_p() {
>         local nmatches=$compstate[nmatches]
>         "$@"
>         (( nmatches < $compstate[nmatches] ))
>     }
> 
> to reduce the need to manage $ret in every single layer of the
> callstack?

Are you suggesting avoiding looking at the return value, but looking at
what its effect would have been at the point where you would have looked
it?

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06  9:29     ` Peter Stephenson
@ 2018-08-06 11:09       ` Anton Shestakov
  2018-08-06 11:14         ` Peter Stephenson
  2018-08-06 12:04         ` Daniel Shahaf
  2018-08-06 12:06       ` Daniel Shahaf
  1 sibling, 2 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06 11:09 UTC (permalink / raw)
  To: zsh-workers, Peter Stephenson, Daniel Shahaf

Okay, does this look better? (focusing only on _hg_cmd_resolve for now)

diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg
index 50ab7132c..0951ef53a 100644
--- a/Completion/Unix/Command/_hg
+++ b/Completion/Unix/Command/_hg
@@ -698,20 +698,22 @@ _hg_cmd_rename() {
 }
 
 _hg_cmd_resolve() {
-  local context state line
+  local context state state_descr line ret=1
   typeset -A opt_args
 
   _arguments -s : $_hg_global_opts \
   '(--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() {


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06 11:09       ` Anton Shestakov
@ 2018-08-06 11:14         ` Peter Stephenson
  2018-08-06 12:04         ` Daniel Shahaf
  1 sibling, 0 replies; 16+ messages in thread
From: Peter Stephenson @ 2018-08-06 11:14 UTC (permalink / raw)
  To: Anton Shestakov, zsh-workers

On Mon, 6 Aug 2018 19:09:14 +0800
Anton Shestakov <av6@dwimlabs.net> wrote:
> Okay, does this look better? (focusing only on _hg_cmd_resolve for
> now)

That's certainly the sort of thing I had in mind, yes, unless
Daniel's seen something I haven't.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06 11:09       ` Anton Shestakov
  2018-08-06 11:14         ` Peter Stephenson
@ 2018-08-06 12:04         ` Daniel Shahaf
  2018-08-06 15:31           ` Anton Shestakov
  1 sibling, 1 reply; 16+ messages in thread
From: Daniel Shahaf @ 2018-08-06 12:04 UTC (permalink / raw)
  To: Anton Shestakov, zsh-workers

Anton Shestakov wrote on Mon, 06 Aug 2018 19:09 +0800:
> Okay, does this look better? (focusing only on _hg_cmd_resolve for now)

Looks good to me, too.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06  9:29     ` Peter Stephenson
  2018-08-06 11:09       ` Anton Shestakov
@ 2018-08-06 12:06       ` Daniel Shahaf
  2018-08-06 14:00         ` Bart Schaefer
  1 sibling, 1 reply; 16+ messages in thread
From: Daniel Shahaf @ 2018-08-06 12:06 UTC (permalink / raw)
  To: Peter Stephenson, zsh-workers

Peter Stephenson wrote on Mon, 06 Aug 2018 10:29 +0100:
> On Mon, 6 Aug 2018 09:20:32 +0000
> Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
> > To -workers, couldn't we write a wrapper such as the following:
> > 
> >     _added_matches_p() {
> >         local nmatches=$compstate[nmatches]
> >         "$@"
> >         (( nmatches < $compstate[nmatches] ))
> >     }
> > 
> > to reduce the need to manage $ret in every single layer of the
> > callstack?
> 
> Are you suggesting avoiding looking at the return value, but looking at
> what its effect would have been at the point where you would have looked
> it?

Yes.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06 12:06       ` Daniel Shahaf
@ 2018-08-06 14:00         ` Bart Schaefer
  0 siblings, 0 replies; 16+ messages in thread
From: Bart Schaefer @ 2018-08-06 14:00 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 433 bytes --]

On Mon, Aug 6, 2018, 7:06 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:

> Peter Stephenson wrote on Mon, 06 Aug 2018 10:29 +0100:
> >
> > Are you suggesting avoiding looking at the return value, but looking at
> > what its effect would have been at the point where you would have looked
> > it?
>
> Yes.
>

There are a few cases where it is desirable to return nonzero even when
matches have been added, and also the reverse.

>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06 12:04         ` Daniel Shahaf
@ 2018-08-06 15:31           ` Anton Shestakov
  2018-08-06 15:38             ` Peter Stephenson
  0 siblings, 1 reply; 16+ messages in thread
From: Anton Shestakov @ 2018-08-06 15:31 UTC (permalink / raw)
  To: zsh-workers

I've edited the 2/5 patch to manage local return value based on the
feedback, and I'll wait until tomorrow in case there's more feedback,
but for now the question is what people here generally prefer? I can
resend the whole series, or only changed patches, or I can push to a
code hosting site or something.


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06 15:31           ` Anton Shestakov
@ 2018-08-06 15:38             ` Peter Stephenson
  2018-08-07  6:15               ` Anton Shestakov
  0 siblings, 1 reply; 16+ messages in thread
From: Peter Stephenson @ 2018-08-06 15:38 UTC (permalink / raw)
  To: Anton Shestakov, zsh-workers

On Mon, 6 Aug 2018 23:31:55 +0800
Anton Shestakov <av6@dwimlabs.net> wrote:
> I've edited the 2/5 patch to manage local return value based on the
> feedback, and I'll wait until tomorrow in case there's more feedback,
> but for now the question is what people here generally prefer? I can
> resend the whole series, or only changed patches, or I can push to a
> code hosting site or something.

I think we've actually got enough already, though I only use Mercurial
for simple tasks so I don't really know enough to comment on the
user-visible functional aspects.  But if nobody else does we
might just take your word for it and commit them.

pws


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] _hg: declare appropriate local parameters for ->string form
  2018-08-06 15:38             ` Peter Stephenson
@ 2018-08-07  6:15               ` Anton Shestakov
  0 siblings, 0 replies; 16+ messages in thread
From: Anton Shestakov @ 2018-08-07  6:15 UTC (permalink / raw)
  To: zsh-workers

I did a bit more rewording/rewriting and have sent a v2 of the series.
I hope it's not too much noise.


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-08-07  6:15 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-06  7:28 [PATCH 0/5] An update for Completion/Unix/Command/_hg Anton Shestakov
2018-08-06  7:28 ` [PATCH 1/5] _hg: rename _hg_style_opts to _hg_template_opts Anton Shestakov
2018-08-06  7:28 ` [PATCH 2/5] _hg: declare appropriate local parameters for ->string form Anton Shestakov
2018-08-06  9:20   ` Daniel Shahaf
2018-08-06  9:29     ` Peter Stephenson
2018-08-06 11:09       ` Anton Shestakov
2018-08-06 11:14         ` Peter Stephenson
2018-08-06 12:04         ` Daniel Shahaf
2018-08-06 15:31           ` Anton Shestakov
2018-08-06 15:38             ` Peter Stephenson
2018-08-07  6:15               ` Anton Shestakov
2018-08-06 12:06       ` Daniel Shahaf
2018-08-06 14:00         ` Bart Schaefer
2018-08-06  7:28 ` [PATCH 3/5] _hg: add forget, phase, summary Anton Shestakov
2018-08-06  7:28 ` [PATCH 4/5] _hg: update all options Anton Shestakov
2018-08-06  7:28 ` [PATCH 5/5] _hg: drop -w, add -S to _arguments Anton Shestakov

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).