* PATCH: add support for stgit in VCS_Info
@ 2009-05-22 15:45 Julien Langer
2009-05-22 16:17 ` Frank Terbeck
0 siblings, 1 reply; 4+ messages in thread
From: Julien Langer @ 2009-05-22 15:45 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1.1: Type: text/plain, Size: 315 bytes --]
This patch adds some support for stgit to VCS_Info. It displays the
currently active patch and the number of unapplied patches.
The additional info is configured via a new "stgitformat" style and is put
into the "misc" part of the prompt. I don't know if this is the best idea,
what do you (Frank?) think?
-Julien
[-- Attachment #1.2: Type: text/html, Size: 359 bytes --]
[-- Attachment #2: vcs_info_stgit_support.patch --]
[-- Type: text/x-patch, Size: 2081 bytes --]
add support for stgit
From: Julien Langer <julien.langer@gmail.com>
---
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 47 +++++++++++++++++++++
1 files changed, 46 insertions(+), 1 deletions(-)
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index faab2b8..d30938d 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -89,6 +89,36 @@ VCS_INFO_git_getbranch () {
return 0
}
+VCS_INFO_git_get_stgit_top_patch () {
+ local patchdir=$1
+
+ if [[ -d "$patchdir" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/applied")"})
+ printf '%s' $patches[-1]
+ return 0
+ fi
+
+ return 1
+}
+
+VCS_INFO_git_get_stgit_unapplied() {
+ local patchdir=$1
+
+ if [[ -d "$patchdir" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/unapplied")"})
+ if [[ -z $patches[@] ]]; then
+ printf 0
+ else
+ printf '%d' $#patches
+ fi
+ return 0
+ fi
+
+ return 1
+}
+
gitdir=${vcs_comm[gitdir]}
gitbranch="$(VCS_INFO_git_getbranch ${gitdir})"
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision && \
@@ -117,5 +147,20 @@ VCS_INFO_adjust
gitaction="$(VCS_INFO_git_getaction ${gitdir})"
gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
rrn=${gitbase:t}
-VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" ''
+
+local patchdir=${gitdir}/patches/${gitbranch}
+if [[ -d $patchdir ]] ; then
+ stgitpatch=$(VCS_INFO_git_get_stgit_top_patch "${patchdir}")
+ stgitunapplied=$(VCS_INFO_git_get_stgit_unapplied "${patchdir}")
+
+ stgitpatch=${stgitpatch:-"no patch applied"}
+
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" stgitformat stgitmsg || stgitmsg=" %p (%c)"
+ zformat -f stgitmsg "${stgitmsg}" "p:${stgitpatch}" "c:${stgitunapplied}"
+ gitmisc=${stgitmsg}
+else
+ gitmisc=''
+fi
+
+VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${gitmisc}"
return 0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: add support for stgit in VCS_Info
2009-05-22 15:45 PATCH: add support for stgit in VCS_Info Julien Langer
@ 2009-05-22 16:17 ` Frank Terbeck
2009-05-22 17:24 ` Julien Langer
0 siblings, 1 reply; 4+ messages in thread
From: Frank Terbeck @ 2009-05-22 16:17 UTC (permalink / raw)
To: zsh-workers
Julien Langer <julien.langer@googlemail.com>:
> This patch adds some support for stgit to VCS_Info. It displays the
> currently active patch and the number of unapplied patches.
> The additional info is configured via a new "stgitformat" style and is put
> into the "misc" part of the prompt. I don't know if this is the best idea,
> what do you (Frank?) think?
One thing, the rest of VCS_INFO_get_data_git() uses four spaces for
indenting and the patch mixes tabs into that.
Also when introducing a new style, a documentation update would be
nice. :)
Apart from that, technically the patch itself looks fine, IMO.
However, I don't use stgit myself, so I can't give it a test drive.
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: add support for stgit in VCS_Info
2009-05-22 16:17 ` Frank Terbeck
@ 2009-05-22 17:24 ` Julien Langer
2009-05-22 17:42 ` Frank Terbeck
0 siblings, 1 reply; 4+ messages in thread
From: Julien Langer @ 2009-05-22 17:24 UTC (permalink / raw)
To: zsh-workers
[-- Attachment #1.1: Type: text/plain, Size: 672 bytes --]
2009/5/22 Frank Terbeck <ft@bewatermyfriend.org>
> Julien Langer <julien.langer@googlemail.com>:
> > This patch adds some support for stgit to VCS_Info. It displays the
> > currently active patch and the number of unapplied patches.
> > The additional info is configured via a new "stgitformat" style and is
> put
> > into the "misc" part of the prompt. I don't know if this is the best
> idea,
> > what do you (Frank?) think?
>
> One thing, the rest of VCS_INFO_get_data_git() uses four spaces for
> indenting and the patch mixes tabs into that.
>
> Also when introducing a new style, a documentation update would be
> nice. :)
Ok, here's the updated patch.
- Julien
[-- Attachment #1.2: Type: text/html, Size: 1129 bytes --]
[-- Attachment #2: vcs_info_stgit_support.patch --]
[-- Type: text/x-patch, Size: 4428 bytes --]
add support for stgit
From: Julien Langer <julien.langer@gmail.com>
---
Doc/Zsh/contrib.yo | 22 ++++++++--
Functions/VCS_Info/Backends/VCS_INFO_get_data_git | 47 +++++++++++++++++++++
2 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/Doc/Zsh/contrib.yo b/Doc/Zsh/contrib.yo
index 620aaea..4131d66 100644
--- a/Doc/Zsh/contrib.yo
+++ b/Doc/Zsh/contrib.yo
@@ -486,6 +486,13 @@ want var(vcs_info) to completely take over the generation of your prompt.
You would do something like tt(PS1='${vcs_info_msg_0_}') to accomplish
that.
)
+kindex(stgitformat)
+item(tt(stgitformat))(
+The tt(git) backend replaces var(%m) in the formats and
+actionformats styles with tt(stgit)-specific information for
+tt(stgit)-initialized branches. This style let's you modify how that string
+should look like.
+)
kindex(max-exports)
item(tt(max-exports))(
Defines the maximum number if
@@ -605,6 +612,7 @@ sitem(tt(formats))(" (%s)-[%b|%a]-")
sitem(tt(actionformats))(" (%s)-[%b]-")
sitem(tt(branchformat))("%b:%r" (for bzr, svn and svk))
sitem(tt(nvcsformats))("")
+sitem(tt(stgitformat))(" %p (%c)")
sitem(tt(max-exports))(2)
sitem(tt(enable))(ALL)
sitem(tt(disable))((empty list))
@@ -638,9 +646,10 @@ var(repoXY).)
sitem(tt(%S))(subdirectory within a repository. If tt($PWD) is
var(/foo/bar/reposXY/beer/tasty), tt(%S) is var(beer/tasty).)
sitem(tt(%m))(A "misc" replacement. It is at the discretion of the backend
-to decide what this replacement expands to. It is currently used only by
-the tt(hg) backend. The hg backend replaces tt(%m) with the global hash
-value of the current revision.)
+to decide what this replacement expands to. It is currently used by
+the tt(hg) and tt(git) backends. The tt(hg) backend replaces tt(%m) with the
+global hash value of the current revision and the tt(git) backend replaces it
+with the string from the var(stgitformat) style.)
endsitem()
In tt(branchformat) these replacements are done:
@@ -650,6 +659,13 @@ sitem(tt(%b))(the branch name)
sitem(tt(%r))(the current revision number)
endsitem()
+In tt(stgitformat) these replacements are done:
+
+startsitem()
+sitem(tt(%p))(the name of the patch currently on top of the stack)
+sitem(tt(%c))(the number of unapplied patches)
+endsitem()
+
Not all vcs backends have to support all replacements. For tt(nvcsformats)
no replacements are performed at all. It is just a string.
diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
index faab2b8..a536165 100644
--- a/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
+++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_git
@@ -89,6 +89,36 @@ VCS_INFO_git_getbranch () {
return 0
}
+VCS_INFO_git_get_stgit_top_patch () {
+ local patchdir=$1
+
+ if [[ -d "$patchdir" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/applied")"})
+ printf '%s' $patches[-1]
+ return 0
+ fi
+
+ return 1
+}
+
+VCS_INFO_git_get_stgit_unapplied() {
+ local patchdir=$1
+
+ if [[ -d "$patchdir" ]]; then
+ local -a patches
+ patches=(${(f)"$(< "${patchdir}/unapplied")"})
+ if [[ -z $patches[@] ]]; then
+ printf 0
+ else
+ printf '%d' $#patches
+ fi
+ return 0
+ fi
+
+ return 1
+}
+
gitdir=${vcs_comm[gitdir]}
gitbranch="$(VCS_INFO_git_getbranch ${gitdir})"
if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" get-revision && \
@@ -117,5 +147,20 @@ VCS_INFO_adjust
gitaction="$(VCS_INFO_git_getaction ${gitdir})"
gitbase=${PWD%/${$( ${vcs_comm[cmd]} rev-parse --show-prefix )%/##}}
rrn=${gitbase:t}
-VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" ''
+
+local patchdir=${gitdir}/patches/${gitbranch}
+if [[ -d $patchdir ]] ; then
+ stgitpatch=$(VCS_INFO_git_get_stgit_top_patch "${patchdir}")
+ stgitunapplied=$(VCS_INFO_git_get_stgit_unapplied "${patchdir}")
+
+ stgitpatch=${stgitpatch:-"no patch applied"}
+
+ zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" stgitformat stgitmsg || stgitmsg=" %p (%c)"
+ zformat -f stgitmsg "${stgitmsg}" "p:${stgitpatch}" "c:${stgitunapplied}"
+ gitmisc=${stgitmsg}
+else
+ gitmisc=''
+fi
+
+VCS_INFO_formats "${gitaction}" "${gitbranch}" "${gitbase}" "${gitstaged}" "${gitunstaged}" "${gitsha1}" "${gitmisc}"
return 0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: add support for stgit in VCS_Info
2009-05-22 17:24 ` Julien Langer
@ 2009-05-22 17:42 ` Frank Terbeck
0 siblings, 0 replies; 4+ messages in thread
From: Frank Terbeck @ 2009-05-22 17:42 UTC (permalink / raw)
To: zsh-workers
Julien Langer <julien.langer@googlemail.com>:
> 2009/5/22 Frank Terbeck <ft@bewatermyfriend.org>
> > Julien Langer <julien.langer@googlemail.com>:
> > > This patch adds some support for stgit to VCS_Info. It displays
> > > the currently active patch and the number of unapplied patches.
> > > The additional info is configured via a new "stgitformat" style
> > > and is put into the "misc" part of the prompt. I don't know if
> > > this is the best idea, what do you (Frank?) think?
> >
> > One thing, the rest of VCS_INFO_get_data_git() uses four spaces
> > for indenting and the patch mixes tabs into that.
> >
> > Also when introducing a new style, a documentation update would be
> > nice. :)
>
>
> Ok, here's the updated patch.
This is looking good for me. Thanks!
Regards, Frank
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-05-22 17:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-22 15:45 PATCH: add support for stgit in VCS_Info Julien Langer
2009-05-22 16:17 ` Frank Terbeck
2009-05-22 17:24 ` Julien Langer
2009-05-22 17:42 ` Frank Terbeck
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).