From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4189 invoked by alias); 17 Mar 2011 23:08:54 -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: 28903 Received: (qmail 4819 invoked from network); 17 Mar 2011 23:08:51 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: Mike Meyer Cc: zsh-workers@zsh.org Subject: Re: How to contribute VCSInfo back end for fossil In-Reply-To: <20110317182628.63ad9100@bhuda.mired.org> (Mike Meyer's message of "Thu, 17 Mar 2011 18:26:28 -0400") References: <20110317182628.63ad9100@bhuda.mired.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Date: Fri, 18 Mar 2011 00:06:26 +0100 Message-ID: <87hbb1ibyl.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Df-Sender: 430444 Mike Meyer wrote: > Sorry if this is the wrong place, but neither google nor > hand-examining the zsh sites turned up a place for such submissions... This is exactly the right place. > Anyway, I wrote a vcs_info backend for the fossil scm > (http://fossil-scm.org/). I'd like to donate the code back to the zsh > community, but don't see an obvious way to do so. Great. I've briefly looked at the code and it seems clear enough. I'd like to commit the following: diff --git a/Functions/VCS_Info/Backends/VCS_INFO_detect_fossil b/Functions/VCS_Info/Backends/VCS_INFO_detect_fossil new file mode 100644 index 0000000..5515283 --- /dev/null +++ b/Functions/VCS_Info/Backends/VCS_INFO_detect_fossil @@ -0,0 +1,13 @@ +## vim:ft=zsh +## fossil support by: Mike Meyer +## Distributed under the same BSD-ish license as zsh itself. + +setopt localoptions NO_shwordsplit + +[[ $1 == '--flavours' ]] && return 1 + +VCS_INFO_check_com ${vcs_comm[cmd]} || return 1 +vcs_comm[detect_need_file]=_FOSSIL_ +VCS_INFO_bydir_detect . || return 1 + +return 0 diff --git a/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil b/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil new file mode 100644 index 0000000..4568b64 --- /dev/null +++ b/Functions/VCS_Info/Backends/VCS_INFO_get_data_fossil @@ -0,0 +1,37 @@ +## vim:ft=zsh +## fossil support by: Mike Meyer +## Distributed under the same BSD-ish license as zsh itself. + +setopt localoptions extendedglob +local a b +local change changed +local action merging +local -A fsinfo +local -xA hook_com + +${vcs_comm[cmd]} status | while IFS=: read a b; do fsinfo[${a//-/_}]="${b## #}"; done +fshash=${fsinfo[checkout]%% *} +changed=${(Mk)fsinfo:#(ADDED|EDITED|DELETED|UPDATED)*} +merging=${(Mk)fsinfo:#*_BY_MERGE*} +if [ -n "$merging" ]; then + action="merging" +fi + +# Build the revision display +fsrev="${hook_com[hash]}" + +# Now build the branch display +zstyle -s ":vcs_info:${vcs}:${usercontext}:${rrn}" branchformat fsbranch || fsbranch="%b:%r" + +hook_com=( branch "${fsinfo[tags]%%, *}" revision "${fsrev}" ) + +if VCS_INFO_hook 'set-branch-format' "${fsbranch}"; then + zformat -f fsbranch "${fsbranch}" "b:${hook_com[branch]}" "r:${hook_com[revision]}" +else + fsbranch=${hook_com[branch-replace]} +fi + +hook_com=() + +VCS_INFO_formats "$action" "${fsbranch}" "${fsinfo[local_root]}" '' "$changed" "${fsrev}" "${fsinfo[repository]}" +return 0 As you can see, I've removed the code that surrounded the `$fsrev' variable. Specifically, the `fsrevformat' style and the `set-fsrev-format' hook. They didn't add much, as you've got full access to the same data in with the `branchformat' style and the `set-branch-format' hook (I kept the `$fsrev' variable for clarity). Like this, the only required documentation update would be to name fossil among the supported systems in zshcontrib(1). If you're okay with those changes, it would be good if you could check whether the above code works or not - I didn't test those changes. Regards, Frank