From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 66f052b3 for ; Tue, 10 Dec 2019 05:18:29 +0000 (UTC) Received: (qmail 329 invoked by alias); 10 Dec 2019 05:18:20 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 24510 Received: (qmail 28705 invoked by uid 1010); 10 Dec 2019 05:18:20 -0000 X-Qmail-Scanner-Diagnostics: from out5-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25656. spamassassin: 3.4.2. Clear:RC:0(66.111.4.29):SA:0(-2.6/5.0):. Processed in 4.145501 secs); 10 Dec 2019 05:18:20 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrudelvddgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujggfsehttd dttddtredvnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhi vghlrdhshhgrhhgrfhdrnhgrmhgvqeenucfkphepjeelrddukedtrdehjedrudduleenuc frrghrrghmpehmrghilhhfrhhomhepugdrshesuggrnhhivghlrdhshhgrhhgrfhdrnhgr mhgvnecuvehluhhsthgvrhfuihiivgeptd X-ME-Proxy: Date: Tue, 10 Dec 2019 05:17:34 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: [WIP PATCH] vcs_info svn support for 'svnversion' Message-ID: <20191210051734.xmo2pyn6m7vzblwr@tarpaulin.shahaf.local2> References: <20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191201005217.m4rpqq623l4vapwe@tarpaulin.shahaf.local2> User-Agent: NeoMutt/20170113 (1.7.2) Daniel Shahaf wrote on Sun, Dec 01, 2019 at 00:52:17 +0000: > [[[ > From: Daniel Shahaf > 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 } ]]]