From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19329 invoked by alias); 24 Jan 2015 15:25:44 -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: 34366 Received: (qmail 24786 invoked from network); 24 Jan 2015 15:25:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=x-sasl-enc:date:from:to:subject:message-id :mime-version:content-type; s=mesmtp; bh=OPltruUlS8mOFJrRg31dvVw f8D4=; b=oCHaCfCEvVVWeI13G9ZI1Tx0ATjDo0/G18Ckb44dLFtAwkbMMRwo4Ht s8ORgFaMNVeXgLAlkbAwLmrIgntyC8MwVAiEo3lHUHoCIXdNUP7H9VjQbvpUiUZ4 AHe48gGx6ytnH2O7KuhdLy1c19kfBJj6WemAQ3AcuLGg8hVQFohw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=x-sasl-enc:date:from:to:subject :message-id:mime-version:content-type; s=smtpout; bh=OPltruUlS8m OFJrRg31dvVwf8D4=; b=FUUscb3DZPiOnLfixYWZ9WZhmuk8QJf7yfMUY/DHJTM qrGsYpBn3XWnonm+mGt1oG1x70hSu7wdnyqGmhuTZL+G2cwQYRbIHzTjvZq26prV 9kjvRG/YLoEz6sRked9pUyG0wX3k7Y59sonJ9siKpOAPKQQWG9zrTKgQ3VYb8iHc = X-Sasl-enc: ygifEnQz6VnDTtmhrYZ1wEjfZjXTv64xi7PnOXq3qyuM 1422113139 Date: Sat, 24 Jan 2015 15:25:37 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] vcs_info hg: Support inactive bookmarks Message-ID: <20150124152537.GB20359@tarsus.local2> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="k+w/mQv8wyuph6w0" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) --k+w/mQv8wyuph6w0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline After running 'hg bookmark foo -r bar', there is a difference between 'hg checkout foo' and 'hg checkout bar'. (The difference is similar to git detached heads.) vcs_info is not aware of this difference. The attached patch adds that feature. Daniel --k+w/mQv8wyuph6w0 Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-vcs_info-hg-Support-inactive-bookmarks.patch" >>From d83abba2622936e9e5b7822bed5a399a0b5834ce Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Sat, 24 Jan 2015 06:41:42 +0000 Subject: [PATCH] vcs_info hg: Support inactive bookmarks (Similar to git detached heads) --- Doc/Zsh/contrib.yo | 7 +++++++ Functions/VCS_Info/Backends/VCS_INFO_get_data_hg | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo index 00ede52..80a7997 100644 --- a/Doc/Zsh/contrib.yo +++ b/Doc/Zsh/contrib.yo @@ -927,6 +927,10 @@ kindex(get-bookmarks) item(tt(get-bookmarks))( If set to true, the tt(hg) backend will try to get a list of current bookmarks. They will be available via the `tt(%m)' replacement. + +The default is to generate a comma-separated list of all bookmark names +that refer to the currently checked out revision. If a bookmark is active, +its name is suffixed an asterisk and placed first in the list. ) kindex(use-prompt-escapes) item(tt(use-prompt-escapes))( @@ -1290,6 +1294,9 @@ tt(get-revision) and tt(get-bookmarks) styles must be true. This hook gets the names of the Mercurial bookmarks that tt(vcs_info) collected from `hg'. +If a bookmark is active, the key tt(${hook_com[hg-active-bookmark]}) is +set to its name. The key is otherwise unset. + When setting tt(ret) to non-zero, the string in tt(${hook_com[hg-bookmark-string]}) will be used in the tt(%m) escape in tt(formats) and tt(actionformats) and will be available in the global diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg index cedaf56..1274ca3 100644 --- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_hg @@ -6,6 +6,7 @@ setopt localoptions extendedglob NO_shwordsplit local hgbase bmfile branchfile rebasefile dirstatefile mqseriesfile \ + curbmfile curbm \ mqstatusfile mqguardsfile patchdir mergedir \ r_csetid r_lrev r_branch i_bmhash i_bmname \ revformat branchformat hgactionstring hgchanges \ @@ -24,6 +25,7 @@ r_lrev='' # local revision patchdir="${hgbase}/.hg/patches" mergedir="${hgbase}/.hg/merge/" bmfile="${hgbase}/.hg/bookmarks" +curbmfile="${hgbase}/.hg/bookmarks.current" branchfile="${hgbase}/.hg/branch" rebasefile="${hgbase}/.hg/rebasestate" dirstatefile="${hgbase}/.hg/dirstate" @@ -125,8 +127,23 @@ if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-bookmarks \ [[ $i_bmhash == $r_csetid* ]] && hgbmarks+=( $i_bmname ) done < ${bmfile} + if [[ -r "$curbmfile" ]] ; then + curbm=$(<"${curbmfile}") + hook_com[hg-active-bookmark]=$curbm + else + # leave curbm empty and [hg-active-bookmark] undefined. + fi + if VCS_INFO_hook 'gen-hg-bookmark-string' "${hgbmarks[@]}"; then + # If there is an active bookmark, annotate it and put it first. + if [[ -n $curbm ]] ; then + hgbmarks[(i)$curbm]=() + hgbmarks[1,0]="${curbm}*" + fi hgbmstring=${(j:, :)hgbmarks} + # Deannotate the array, in case later code expects it to be valid. + # (The order is not restored.) + [[ -n $curbm ]] && hgbmarks[1]=${${hgbmarks[1]}[1,-2]} else hgbmstring=${hook_com[hg-bookmark-string]} fi -- 1.9.1 --k+w/mQv8wyuph6w0--