zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Cc: Seth House <seth@eseth.com>
Subject: PATCH: (2/3) vcs_info: hg bookmarks support
Date: Tue, 16 Feb 2010 00:52:14 +0100	[thread overview]
Message-ID: <1266277935-18165-3-git-send-email-ft@bewatermyfriend.org> (raw)
In-Reply-To: <1266277935-18165-1-git-send-email-ft@bewatermyfriend.org>

From: Seth House <seth@eseth.com>

---
 Doc/Zsh/contrib.yo                               |    6 ++++--
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg |   19 +++++++++++++++----
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 2c3fc39..6d8d93f 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -602,8 +602,9 @@ If set to true, vcs_info goes the extra mile to figure out the revision of
 a repository's work tree (currently for the tt(git) and tt(hg) backends,
 where this kind of information is not always vital). For tt(git), the
 hash value of the currently checked out commit is available via the tt(%i)
-expansion. With tt(hg), the local revision number is available via tt(%i)
-and the corresponding global hash is available via tt(%m).
+expansion. With tt(hg), the local revision number is available via tt(%i),
+the corresponding global hash is available via tt(%m), and bookmarks are
+available via tt(%k).
 If this style is set in the tt(hg) context, the backend supports the
 branchformat style.
 )
@@ -669,6 +670,7 @@ In tt(branchformat) these replacements are done:
 startsitem()
 sitem(tt(%b))(the branch name)
 sitem(tt(%r))(the current revision number or the var(hgrevformat) style for tt(hg))
+sitem(tt(%k))(any current bookmarks for tt(hg))
 endsitem()
 
 In tt(stgitformat) these replacements are done:
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 6689015..7c854b2 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -4,7 +4,7 @@
 
 setopt localoptions NO_shwordsplit
 local file hgbranch hgbranch_name hgbase hglhash hgshash hglrev hgmisc \
-    r_branch hgchanges revformat
+    r_branch hgchanges revformat bookmarks r_bmhash r_bmname hgbm
 
 VCS_INFO_hg_get_mq_top_patch () {
     local patchdir=$1
@@ -32,6 +32,9 @@ fi
 
 hglhash=''
 hglrev=''
+hgbm=''
+bookmarks="${hgbase}/.hg/bookmarks"
+
 if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
     # Calling the 'hg' program is quite a bit too slow for prompts.
     # If there's a way around that, I'd be interested.
@@ -41,7 +44,7 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
             "check-for-changes" ; then
 
         HGRCPATH="/dev/null" ${vcs_comm[cmd]} id -i -n -b \
-        | read -r hglhash hglrev r_branch
+        | read -r hgshash hglrev r_branch
 
         # Are there uncommitted-changes?
         if [[ $hglrev[-1] == + ]] ; then
@@ -50,18 +53,26 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision ; then
 
         # Remove uncommitted-changes marker, if any
         hglrev=${hglrev/+/}
-        hglhash=${hglhash/+/}
+        hgshash=${hgshash/+/}
     else
         HGRCPATH="/dev/null" ${vcs_comm[cmd]} \
         parents --template="{node} {node|short} {rev} {branches}\n" \
         | read -r hglhash hgshash hglrev r_branch
     fi
 
+    if [[ -r "${bookmarks}" ]] ; then
+        while read -r r_bmhash r_bmname ; do
+            if [[ $hglhash == $r_bmhash || $r_bmhash == $hgshash* ]] ; then
+                hgbm="$r_bmname;${hgbm}"
+            fi
+        done < ${bookmarks}
+    fi
+
     if [[ -n ${hglrev} ]] ; then
         zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" hgrevformat revformat || revformat="%r:%h"
         zformat -f hglrev "${revformat}" "r:${hglrev}" "h:${hglhash}"
         zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat hgbranch || hgbranch="%b:%r"
-        zformat -f hgbranch "${hgbranch}" "b:${hgbranch_name}" "r:${hglrev}"
+        zformat -f hgbranch "${hgbranch}" "b:${hgbranch_name}" "r:${hglrev}" "k:${hgbm}"
     fi
 else
     hgbranch="${hgbranch_name}"
-- 
1.7.0


  parent reply	other threads:[~2010-02-15 23:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-15 23:52 PATCH: (0/3) vcs_info: hg fixes, enhancements and hooks for vcs_info Frank Terbeck
2010-02-15 23:52 ` PATCH: (1/3) vcs_info: hg fixes and enhancements Frank Terbeck
2010-02-15 23:52 ` Frank Terbeck [this message]
2010-02-15 23:52 ` PATCH: (3/3) vcs_info: Introduce the concept of hooks Frank Terbeck

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=1266277935-18165-3-git-send-email-ft@bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --cc=seth@eseth.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).