zsh-workers
 help / color / mirror / code / Atom feed
From: Frank Terbeck <ft@bewatermyfriend.org>
To: zsh-workers@zsh.org
Subject: PATCH: (0/3) vcs_info: hg fixes, enhancements and hooks for vcs_info
Date: Tue, 16 Feb 2010 00:52:12 +0100	[thread overview]
Message-ID: <1266277935-18165-1-git-send-email-ft@bewatermyfriend.org> (raw)

This is a series of three patches (two by Seth House, one by myself),
which fixes bugs in the `hg' backend, adds a new feature to it and adds
the concept of `hooks' to vcs_info.

Seth is the author of all the purely mercurial (hg) related changes.
Including a bug fix: if you're on a mercurial branch, but check out an
older commit, the hash returned by the `get-revision' style if still
the one of the branch's top commit.

The other change Seth made, is support for mercurial's "bookmarks",
which - according to Seth - are mercurial's way of cheap branches. They
are similar to a tag, but they move along as commits are made.

The changes I made, introduce "hooks" into vcs_info. I did that, because
Seth told me, that at the same time more than one bookmark could be
active. So, when you're on a commit that has 123 bookmarks on it, you're
getting an awfully long string in return.

Vcs_info's formats could only strim entries to a certain size. E.g.: if
you'd want the %m item to be eight characters wide, you'd use "%8.8m".
With that bookmarks business, I didn't feel that was quite enough.

Also up to now, a backend could only hand over *one* "misc" parameter to
VCS_INFO_formats(). And with the support for bookmarks, the hg backend
needed more, because the misc parameter is already in use by the
mq-top-patch support. Now, every backend may hand over one or more
misc parameters to VCS_INFO_formats(). The default is, to insert a
comma separated list of all misc parameters as the `%m' item. (Fine-
grained access to what is really inserted is possible through the
`set-message' hook.)

A short example of a hook to control how the hg-bookmarks string is
generated could look like this (included in the documentation too):

Register a function:

% zstyle ':vcs_info:hg+gen-hg-bookmark-string:*' hooks hgbookmarks

Define the function (the `+vi-' prefix is to avoid namespace issues,
the manual describes this, too):

function +vi-hgbookmarks() {
    # The default is to connect all bookmark names by semicolons. This
    # mixes things up a little.
    # Imagine, there's one type of bookmarks that is special to you.
    # Say, because it's *your* work. Those bookmarks look always like
    # this: "sh/*". And you only want to see those.
    local s i

    # The bookmarks returned by `hg' are available in the functions
    # positional parameters.
    (( $# == 0 )) && return 0
    for i in "$@"; do
        if [[ $i == sh/* ]]; then
            [[ -n $s ]] && s=$s,
            s=${s}$i
        fi
    done

    # Now, the communication with the code that calls the hook functions
    # is done via the hook_com[] hash. The key, at which the
    # `gen-hg-bookmark-string' hook looks at is `hg-bookmark-string'.
    # So:
    hook_com[hg-bookmark-string]=$s

    # And to signal, that we want to use the sting we just generated,
    # set the special variable `ret' to something other than the default
    # zero:
    ret=1
    return 0
}

There are currently five hooks available:
    set-message
    set-branch-format
    set-hgrev-format
    gen-hg-bookmark-string
    gen-mq-patch-string
    gen-stgit-patch-string
    gen-stgit-unapplied-string
    set-stgit-format

Those give the user full control over what is being output. Adding hooks
is trivial, but I didn't come up with useful cases yet. :)

Regards, Frank

Frank Terbeck (1):
  vcs_info: Introduce the concept of hooks

Seth House (2):
  vcs_info: hg fixes and enhancements
  vcs_info: hg bookmarks support

 Doc/Zsh/contrib.yo                                |  290 ++++++++++++++++++++-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_bzr |    9 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |   65 +++---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_hg  |  117 ++++++---
 Functions/VCS_Info/Backends/VCS_INFO_get_data_p4  |   15 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_svk |    9 +-
 Functions/VCS_Info/Backends/VCS_INFO_get_data_svn |    9 +-
 Functions/VCS_Info/VCS_INFO_formats               |   83 ++++--
 Functions/VCS_Info/VCS_INFO_hook                  |   42 +++
 Functions/VCS_Info/vcs_info                       |    1 +
 10 files changed, 530 insertions(+), 110 deletions(-)


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

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-15 23:52 Frank Terbeck [this message]
2010-02-15 23:52 ` PATCH: (1/3) vcs_info: hg fixes and enhancements Frank Terbeck
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-1-git-send-email-ft@bewatermyfriend.org \
    --to=ft@bewatermyfriend.org \
    --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).