changeset 39669:3f11cb1aeb90

zsh_completion: add -b/--branch and -B/--bookmark(s) flags properly _hg_branch_bmark_opts used to add these two flags, but had the same descriptions for the flags regardless of what command took them and didn't allow specifying flags more than once (no '*' at the start). Even more importantly, it assumed that -B was always expecting an argument (i.e. --bookmark=foo), but in case of incoming and outgoing it's not so (--bookmarks is self-sufficient). Differential Revision: https://phab.mercurial-scm.org/D4612
author Anton Shestakov <av6@dwimlabs.net>
date Mon, 17 Sep 2018 13:21:46 +0800
parents 24870f1be088
children 9b07ee0a1054
files contrib/zsh_completion
diffstat 1 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/zsh_completion	Fri Sep 14 16:29:51 2018 -0700
+++ b/contrib/zsh_completion	Mon Sep 17 13:21:46 2018 +0800
@@ -464,11 +464,6 @@
   '--insecure[do not verify server certificate (ignoring web.cacerts config)]'
 )
 
-_hg_branch_bmark_opts=(
-  '(--bookmark -B)'{-B+,--bookmark=}'[specify bookmark(s)]:bookmark:_hg_bookmarks'
-  '(--branch -b)'{-b+,--branch=}'[specify branch(es)]:branch:_hg_branches'
-)
-
 _hg_subrepos_opts=(
   '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]')
 
@@ -726,12 +721,13 @@
 }
 
 _hg_cmd_incoming() {
-  _arguments -s -S : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
-                     $_hg_subrepos_opts \
+  _arguments -s -S : $_hg_log_opts $_hg_remote_opts $_hg_subrepos_opts \
   '(--force -f)'{-f,--force}'[run even if remote repository is unrelated]' \
   '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_labels' \
   '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
   '--bundle=[file to store the bundles into]:bundle file:_files' \
+  '(--bookmarks -B)'{-B,--bookmarks}'[compare bookmarks]' \
+  '*'{-b+,--branch=}'[a specific branch you would like to pull]:branch:_hg_branches' \
   ':source:_hg_remote'
 }
 
@@ -779,11 +775,12 @@
 }
 
 _hg_cmd_outgoing() {
-  _arguments -s -S : $_hg_log_opts $_hg_branch_bmark_opts $_hg_remote_opts \
-                     $_hg_subrepos_opts \
+  _arguments -s -S : $_hg_log_opts $_hg_remote_opts $_hg_subrepos_opts \
   '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \
   '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_revrange' \
   '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \
+  '(--bookmarks -B)'{-B,--bookmarks}'[compare bookmarks]' \
+  '*'{-b+,--branch=}'[a specific branch you would like to push]:branch:_hg_branches' \
   ':destination:_hg_remote'
 }
 
@@ -809,17 +806,21 @@
 }
 
 _hg_cmd_pull() {
-  _arguments -s -S : $_hg_global_opts $_hg_branch_bmark_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 branch head if new descendants were pulled]' \
   '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_labels' \
+  '*'{-B+,--bookmark=}'[bookmark to pull]:bookmark:_hg_bookmarks' \
+  '*'{-b+,--branch=}'[a specific branch you would like to pull]:branch:_hg_branches' \
   ':source:_hg_remote'
 }
 
 _hg_cmd_push() {
-  _arguments -s -S : $_hg_global_opts $_hg_branch_bmark_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_labels' \
+  '*'{-B+,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks' \
+  '*'{-b+,--branch=}'[a specific branch you would like to push]:branch:_hg_branches' \
   '--new-branch[allow pushing a new branch]' \
   ':destination:_hg_remote'
 }