zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: zsh-users@zsh.org
Subject: Re: [WIP PATCH] vcs_info svn support for 'svnversion'
Date: Tue, 10 Dec 2019 05:17:34 +0000	[thread overview]
Message-ID: <20191210051734.xmo2pyn6m7vzblwr@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2>

Daniel Shahaf wrote on Sun, Dec 01, 2019 at 00:52:17 +0000:
> [[[
> From: Daniel Shahaf <danielsh@apache.org>
> Subject: [PATCH]
>  WIP: vcs_info svn: Use svnversion to show uniform revisions and local mods
> 
> The 'staged' expando, %c, will now be set if there's an 'M' in the output of `svnversion`.
> 
> The 'revision number' expando, %i, will now show the full output of svnversion.
> 
> svnversion will only be used if the check-for-changes and get-revision styles are both set.
> 
> TODO: derive the svnversion command name robustly
> TODO: write docs

Here's another version.  Differences:

- It's not a patch now, but configuration to be added to zshrc.

- It uses only public APIs, but takes advantage of an implementation detail to
  avoid svnversion doing a (potentially expensive) tree crawl.  The trade-off is
  that it's not read-only any more.

[[[
zstyle -e ':vcs_info:svn+post-backend:*' hooks 'reply=( ${${(k)functions[(I)[+]vi-svn-post-backend*]}#+vi-} )'

## svn: indicate mixed-revision working copies in the %i (revision) expando
zstyle -e ':vcs_info:svn:*:*' "zshrc:make-temporary-changes" '[[ $PWD == ~/* ]] && reply=(true)'
+vi-svn-post-backend-mixed-revision() {

  local non_uniform_revision modified

  if zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "check-for-changes" ; then
    local output="$(svnversion 2>/dev/null)"
    if [[ ${output} == *M* ]]; then
      hook_com[unstaged]='yes' # value is ignored
    fi
    if [[ ${output} == *:* ]]; then
      non_uniform_revision=${output}
    fi
  elif zstyle -t ":vcs_info:${vcs}:${usercontext}:${rrn}" "zshrc:make-temporary-changes" \
    && [[ -w ${hook_com[base_orig]}/.svn/wc.db ]]; then
    {
      # Make a dummy propmod to prevent svnversion(1) from doing a worktree stat() crawl.
      #
      # This relies on an implementation detail of svn_wc_revision_status2():
      # It will not do a tree crawl if it detected a propery mod (or a tree mod).
      ${vcs_comm[cmd]} propset --quiet vcs_info:dummy yes -- ${hook_com[base_orig]}
      local output="${$(svnversion 2>/dev/null)/M/}" # remove 'M' caused by the dummy propmod
      if [[ ${output} == *:* ]]; then
        non_uniform_revision=${output}
      fi
    } always {
      ${vcs_comm[cmd]} propdel --quiet vcs_info:dummy     -- ${hook_com[base_orig]}
    }
  fi

  if [[ $non_uniform_revision == *:* ]]; then
    integer min=${non_uniform_revision%%:*} max=${${non_uniform_revision#*:}%%[^0-9]*}
    hook_com[revision]="r${min}:r${max}${non_uniform_revision//[0-9:]##}"
    hook_com[revision]+=" (+$((max-min)))"
  fi

  return 0
}

]]]

  reply	other threads:[~2019-12-10  5:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-01  0:52 Daniel Shahaf
2019-12-10  5:17 ` Daniel Shahaf [this message]
2019-12-10  5:55   ` Daniel Shahaf

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=20191210051734.xmo2pyn6m7vzblwr@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@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).