~ubuntu-branches/ubuntu/karmic/zsh/karmic

« back to all changes in this revision

Viewing changes to Functions/VCS_Info/VCS_INFO_formats

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2009-06-02 10:40:25 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20090602104025-lg6wynxpzqi08k2i
Tags: 4.3.10-1ubuntu1
* Resynchronise with Debian. Remaining changes:
  + debian/zshrc: Enable completions by default, unless
    skip_global_compinit is set

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
## Distributed under the same BSD-ish license as zsh itself.
4
4
 
5
5
setopt localoptions noksharrays NO_shwordsplit
6
 
local action=$1 branch=$2 base=$3
 
6
local action=$1 branch=$2 base=$3 staged=$4 unstaged=$5 rev=$6 misc=$7
 
7
 
 
8
## description:
 
9
#   action:   a string that signals a certain non-default condition in the
 
10
#             repository (like 'rebase-i' in git). If this in non-empty,
 
11
#             the actionformats will be used, too.
 
12
#   branch:   the name of the currently checked out branch.
 
13
#   base:     the full name of the repository's root directory.
 
14
#   staged:   non-empty if the repository contains staged changes.
 
15
#   unstaged: non-empty if the repository contains unstaged changes.
 
16
#   rev:      an identifier of the currently checked out revision.
 
17
#   misc:     a string that may contain anything the author likes.
 
18
#             the backends should document what they put in it and when.
 
19
#
 
20
# If an argument has no valid value for a given backend, an empty value
 
21
# should be provided. eg:
 
22
#   VCS_INFO_formats '' "${foobranch}" "${foobase}" '' '' '' "${foomisc}"
 
23
 
7
24
local msg
8
25
local -i i j
9
26
 
15
32
    (( ${#msgs} < 1 )) && msgs[1]=' (%s)-[%b]-'
16
33
fi
17
34
 
 
35
if [[ -n ${staged} ]] ; then
 
36
    zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" stagedstr staged
 
37
    [[ -z ${staged} ]] && staged='S'
 
38
fi
 
39
 
 
40
if [[ -n ${unstaged} ]] ; then
 
41
    zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" unstagedstr unstaged
 
42
    [[ -z ${unstaged} ]] && unstaged='U'
 
43
fi
 
44
 
18
45
(( ${#msgs} > maxexports )) && msgs[$(( maxexports + 1 )),-1]=()
19
46
for i in {1..${#msgs}} ; do
20
 
    zformat -f msg ${msgs[$i]} a:${action} b:${branch} s:${vcs} r:${base:t} R:${base} S:"$(VCS_INFO_reposub ${base})"
 
47
    zformat -f msg ${msgs[$i]}                      \
 
48
                    a:${action}                     \
 
49
                    b:${branch}                     \
 
50
                    c:${staged}                     \
 
51
                    i:${rev}                        \
 
52
                    m:${misc}                       \
 
53
                    r:${base:t}                     \
 
54
                    s:${vcs}                        \
 
55
                    u:${unstaged}                   \
 
56
                    R:${base}                       \
 
57
                    S:"$(VCS_INFO_reposub ${base})"
21
58
    msgs[$i]=${msg}
22
59
done
23
60
return 0