From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15326 invoked by alias); 24 May 2010 17:42:57 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 27969 Received: (qmail 1423 invoked from network); 24 May 2010 17:42:45 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at informatik.uni-leipzig.de does not designate permitted sender hosts) Date: Mon, 24 May 2010 19:42:36 +0200 (CEST) From: Sebastian Tramp X-X-Sender: seebi@soljaris4 To: Richard Hartmann cc: zsh-workers@zsh.org Subject: [PATCH] add: named branches and special revisions for multiple commands In-Reply-To: Message-ID: References: User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) X-FOAF: http://sebastian.tramp.name MIME-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII quote Richard Hartmann (20.5.2010): This patch introduces named branches, tags and local head ids as speciarevision for multiple commands of mercurial ... best regards S.Tramp --- Completion/Unix/Command/_hg | 54 ++++++++++++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 18 deletions(-) diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg index aeb64f6..850215b 100644 --- a/Completion/Unix/Command/_hg +++ b/Completion/Unix/Command/_hg @@ -15,6 +15,7 @@ # # Copyright (C) 2005, 2006 Steve Borho # Copyright (C) 2006-9 Brendan Cully +# Copyright (C) 2010 Sebastian Tramp (special revisions / named branches) # # Permission is hereby granted, without written agreement and without # licence or royalty fees, to use, copy, modify, and distribute this @@ -173,8 +174,20 @@ _hg_tags() { (( $#tags )) && _describe -t tags 'tags' tags } -# likely merge candidates -_hg_mergerevs() { +# named branches as described in http://mercurial.selenic.com/wiki/NamedBranches +_hg_branches() { + typeset -a branches + local branch rev + + _hg_cmd branches 2> /dev/null | cut -f 1 -d ' ' | while read branch + do + branches+=(${branch/ # [0-9]#:*}) + done + (( $#branches )) && _describe -t branches 'named branches' branches +} + +# current heads of the repository +_hg_heads() { typeset -a heads local myrev @@ -186,6 +199,11 @@ _hg_mergerevs() { (( $#heads )) && _describe -t heads 'heads' heads } +# this is an alternative of named branches, tags and heads +_hg_specialrevisions() { + _alternative 'branches:named branches:_hg_branches' 'tags:tags:_hg_tags' 'heads:heads:_hg_heads' +} + _hg_files() { if [[ -n "$_hg_root" ]] then @@ -394,7 +412,7 @@ _hg_cmd_addremove() { _hg_cmd_annotate() { _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ - '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_tags' \ + '(--rev -r)'{-r+,--rev}'[annotate the specified revision]:revision:_hg_specialrevisions' \ '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \ '(--text -a)'{-a,--text}'[treat all files as text]' \ '(--user -u)'{-u,--user}'[list the author]' \ @@ -408,7 +426,7 @@ _hg_cmd_archive() { _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ '--no-decode[do not pass files through decoders]' \ '(--prefix -p)'{-p+,--prefix}'[directory prefix for files in archive]:' \ - '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_tags' \ + '(--rev -r)'{-r+,--rev}'[revision to distribute]:revision:_hg_specialrevisions' \ '(--type -t)'{-t+,--type}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \ '*:destination:_files' } @@ -456,7 +474,7 @@ _hg_cmd_bundle() { _hg_cmd_cat() { _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ '(--output -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ - '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \ + '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_specialrevisions' \ '*:file:_hg_files' } @@ -511,7 +529,7 @@ _hg_cmd_export() { _arguments -s -w : $_hg_global_opts $_hg_diff_opts \ '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ '--switch-parent[diff against the second parent]' \ - '*:revision:_hg_tags' + '*:revision:_hg_specialrevisions' } _hg_cmd_grep() { @@ -540,7 +558,7 @@ _hg_cmd_help() { _hg_cmd_identify() { _arguments -s -w : $_hg_global_opts \ - '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_tags' \ + '(--rev -r)'{-r+,--rev}'[identify the specified rev]:revision:_hg_specialrevisions' \ '(--num -n)'{-n+,--num}'[show local revision number]' \ '(--id -i)'{-i+,--id}'[show global revision id]' \ '(--branch -b)'{-b+,--branch}'[show branch]' \ @@ -560,7 +578,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' \ + '(--rev -r)'{-r+,--rev}'[a specific revision up to which you would like to pull]:revision:_hg_specialrevisions' \ '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ '--bundle[file to store the bundles into]:bundle file:_files' \ ':source:_hg_remote' @@ -573,7 +591,7 @@ _hg_cmd_init() { _hg_cmd_locate() { _arguments -s -w : $_hg_global_opts $_hg_pat_opts \ - '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_tags' \ + '(--rev -r)'{-r+,--rev}'[search repository as it stood at revision]:revision:_hg_specialrevisions' \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \ '*:search pattern:_hg_files' @@ -590,21 +608,21 @@ _hg_cmd_log() { '(--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' \ + '(--prune -P)'{-P+,--prune}'[do not display revision or any of its ancestors]:revision:_hg_specialrevisions' \ '*:files:_hg_files' } _hg_cmd_manifest() { _arguments -s -w : $_hg_global_opts \ - ':revision:_hg_tags' + ':revision:_hg_specialrevisions' } _hg_cmd_merge() { _arguments -s -w : $_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_specialrevisions' \ '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \ - ':revision:_hg_mergerevs' + ':revision:_hg_specialrevisions' } _hg_cmd_outgoing() { @@ -619,7 +637,7 @@ _hg_cmd_outgoing() { _hg_cmd_parents() { _arguments -s -w : $_hg_global_opts $_hg_style_opts \ - '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_tags' \ + '(--rev -r)'{-r+,--rev}'[show parents of the specified rev]:revision:_hg_specialrevisions' \ ':last modified file:_hg_files' } @@ -639,7 +657,7 @@ _hg_cmd_pull() { _hg_cmd_push() { _arguments -s -w : $_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' \ + '(--rev -r)'{-r+,--rev}'[a specific revision you would like to push]:revision:_hg_specialrevisions' \ ':destination:_hg_remote' } @@ -730,7 +748,7 @@ _hg_cmd_status() { '(--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_specialrevisions' \ '*:files:_files' } @@ -758,8 +776,8 @@ _hg_cmd_unbundle() { _hg_cmd_update() { _arguments -s -w : $_hg_global_opts \ '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \ - '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_tags' \ - ':revision:_hg_tags' + '(--rev -r)'{-r+,--rev}'[revision]:revision:_hg_specialrevisions' \ + ':revision:_hg_specialrevisions' } # HGK -- 1.7.0.4