From: Sebastian Tramp <tramp@informatik.uni-leipzig.de>
To: Richard Hartmann <richih.mailinglist@gmail.com>
Cc: zsh-workers@zsh.org
Subject: [PATCH] add: named branches and special revisions for multiple commands
Date: Mon, 24 May 2010 19:42:36 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.00.1005241939180.16057@fbywnevf4> (raw)
In-Reply-To: <AANLkTikBrzf4UfqES459u6zDamY8PSgeCTxCDl4AbVFq@mail.gmail.com>
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 <steve@borho.org>
# Copyright (C) 2006-9 Brendan Cully <brendan@kublai.com>
+# Copyright (C) 2010 Sebastian Tramp <mail@sebastian.tramp.name> (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
next prev parent reply other threads:[~2010-05-24 17:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-19 14:16 mercurial completion patch Sebastian Tramp
2010-05-20 16:23 ` Richard Hartmann
2010-05-24 17:42 ` Sebastian Tramp [this message]
2010-05-25 19:50 ` [PATCH] add: named branches and special revisions for multiple commands Richard Hartmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.DEB.2.00.1005241939180.16057@fbywnevf4 \
--to=tramp@informatik.uni-leipzig.de \
--cc=richih.mailinglist@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).