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: (1/3) vcs_info: hg fixes and enhancements
Date: Tue, 16 Feb 2010 00:52:13 +0100	[thread overview]
Message-ID: <1266277935-18165-2-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                               |   13 +++++---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg |   36 ++++++++++++++--------
 2 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index b815e01..2c3fc39 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -532,14 +532,17 @@ example(zstyle ':vcs_info:*' disable-patterns "$HOME/.zsh+LPAR()|/*+RPAR()")
 )
 kindex(check-for-changes)
 item(tt(check-for-changes))(
-If enabled, this style (currently only used by the tt(git) backend) causes the
-tt(%c) and tt(%u) format escapes to be filled with information. The strings
-filled into these escapes can be controlled via the var(stagedstr) and
-var(unstagedstr) styles.
+If enabled, this style causes the tt(%c) and tt(%u) format escapes to be filled
+with information. The strings filled into these escapes can be controlled via
+the var(stagedstr) and var(unstagedstr) styles. The only backends that
+currently support this option are tt(git) and tt(hg) (tt(hg) only supports
+unstaged).
 
 Note, that the actions taken if this style is enabled are potentially expensive
 (read: they take time, depending on how big the current repository is).
-Therefore, it is disabled by default.
+Therefore, it is disabled by default. In order to use this style with
+the tt(hg) backend you must also use the var(get-revision) style to avoid
+having to start the interpretrer more than once.
 )
 kindex(stagedstr)
 item(tt(stagedstr))(
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
index 0b66463..6689015 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg
@@ -3,7 +3,8 @@
 ## Distributed under the same BSD-ish license as zsh itself.
 
 setopt localoptions NO_shwordsplit
-local file hgbranch hgbranch_name hgbase hghash hglrev hgmisc r_branch r_info revformat
+local file hgbranch hgbranch_name hgbase hglhash hgshash hglrev hgmisc \
+    r_branch hgchanges revformat
 
 VCS_INFO_hg_get_mq_top_patch () {
     local patchdir=$1
@@ -29,27 +30,36 @@ else
     hgbranch_name="default"
 fi
 
-hghash=''
+hglhash=''
 hglrev=''
 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.
     # Disabled by default anyway, so no harm done.
 
-    HGRCPATH="/dev/null" ${vcs_comm[cmd]} branches \
-    | while read -r r_branch r_info ; do
-        if [[ ${r_branch} == ${hgbranch_name} ]] ; then
-            match=()
-            : ${r_info/(#b)([^:]##):(*)}
-            hglrev=${match[1]}
-            hghash=${match[2]}
-            break
+    if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" \
+            "check-for-changes" ; then
+
+        HGRCPATH="/dev/null" ${vcs_comm[cmd]} id -i -n -b \
+        | read -r hglhash hglrev r_branch
+
+        # Are there uncommitted-changes?
+        if [[ $hglrev[-1] == + ]] ; then
+            hgchanges=1
         fi
-    done
+
+        # Remove uncommitted-changes marker, if any
+        hglrev=${hglrev/+/}
+        hglhash=${hglhash/+/}
+    else
+        HGRCPATH="/dev/null" ${vcs_comm[cmd]} \
+        parents --template="{node} {node|short} {rev} {branches}\n" \
+        | read -r hglhash hgshash hglrev r_branch
+    fi
 
     if [[ -n ${hglrev} ]] ; then
         zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" hgrevformat revformat || revformat="%r:%h"
-        zformat -f hglrev "${revformat}" "r:${hglrev}" "h:${hghash}"
+        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}"
     fi
@@ -67,5 +77,5 @@ else
     hgmisc=''
 fi
 
-VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' '' "${hglrev}" "${hgmisc}"
+VCS_INFO_formats '' "${hgbranch}" "${hgbase}" '' "${hgchanges}" "${hglrev}" "${hgmisc}"
 return 0
-- 
1.7.0


  reply	other threads:[~2010-02-15 23:58 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 ` Frank Terbeck [this message]
2010-02-15 23:52 ` PATCH: (2/3) vcs_info: hg bookmarks support Frank Terbeck
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-2-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).