D4612: zsh_completion: add -b/--branch and -B/--bookmark(s) flags properly

av6 (Anton Shestakov) phabricator at mercurial-scm.org
Mon Sep 17 06:08:57 UTC 2018


av6 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  _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).

REPOSITORY
  rHG Mercurial

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

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
@@ -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'
 }



To: av6, #hg-reviewers
Cc: mercurial-devel, spectral


More information about the Mercurial-devel mailing list