From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30234 invoked from network); 26 Jan 2022 14:21:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 26 Jan 2022 14:21:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1643206868; b=UlEoExPA6Ynmf48dEFMYzIpLhBGUYPvB2wV3jz90sPHv43s44bRjFq1TBj30nkUR1ZgIBQN7yd 3im0RaofroUtfuESgBmUQ0oLPQp5vg3utPl/Q7uLd9STCBjBwjw6TdStv2NwejH0ZpSnrhRWCZ KD8Cycm5aLGpboK5e9MdB4U4EYAB2g/uVf5qDwTayL9aWlxtoyKiU1/EegoHcvLkYQ3syc0vdZ CVeS7zZtSh2+3mlpoBXhNN9+951f1oLzDcR/NcqNjIdfE+I+/L/oRg7SPLAcHn47vCN2EzzrMg dXePQsBs7o937NDiJF5x10dJTeTolFKBFOOXn73CuHfL0Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (wout5-smtp.messagingengine.com) smtp.remote-ip=64.147.123.21; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1643206868; bh=2yGtMJztv61dCaOmp5fqiTXsHS0tF4j1jjuOpvQtuR0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:DKIM-Signature:DKIM-Signature: DKIM-Signature; b=hQPeWlUFMoRvDUh8QKnqEyJgorrQ8b59ipIJgJ/yna4B2M8Hj3ILLGNn0KBLle9i8uWZAB6y4m BJJVk6KY+Sv87bSBEifW4VB93nFnyM9V6znz5lql/PyC1LrqxiafciVZ8qHHE9/JvbFmNV/LXd M+zhatOmme9ok3SVCdzXlZqXV9znAU1fvWoOi/tt33RbAz5IgfFf9E3ypFsEgj14O7heeAg4gE rdfYSJyMXECtPi56GnndWJdN3airXJeNSEpzLZV7y8HspEc1Xre8H46RWiTD7iJtMG7sBZ4Clu ktGo1ZvlopMBiedhHv/C6G5sIIWLl0Z9SqdusjKyvNhfCg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=3WSTRLoLSWlM+HBapE7OGZG9lbR5YcJWhtgkgMOl+KY=; b=Lyt0fAfwLuX8hImoiRrGeNXY7z EWpeEe1gFfWH5IXE8iW6psyskUoz3TjCPtSbYgSaCmkGATyf/s6iP8b0zDPpWCTB9hAXYzBAGqo/O T+lazj5BPKtdZiApP5BGlpeJ1zk5IsxbkCczIq4yPJ/WDYn4lhduciBi1JAK8etkAxP38IAu21eSH rPawFSapaQgmNXmZfCfenc3TkQZco/2oqwPBsuJfhWwlnHoAtOhQYbny1jAJ1fvK+mhR7qLT09L9/ xIpvUM/hGQ/ybaNJ1DKNG184S0jbtkXahlxP2twuTe+J1eN7Qs8vP78q73UZPbGHeqV245p+xdMsm DRh0q+JQ==; Received: from authenticated user by zero.zsh.org with local id 1nCjAa-0001zh-FS; Wed, 26 Jan 2022 14:21:08 +0000 Authentication-Results: zsh.org; iprev=pass (wout5-smtp.messagingengine.com) smtp.remote-ip=64.147.123.21; dkim=pass header.d=daniel.shahaf.name header.s=fm2 header.a=rsa-sha256; dkim=pass header.d=messagingengine.com header.s=fm1 header.a=rsa-sha256; dmarc=none header.from=daniel.shahaf.name; arc=none Received: from wout5-smtp.messagingengine.com ([64.147.123.21]:57061) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1nCj8V-0000a0-Na; Wed, 26 Jan 2022 14:19:00 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id C69F23200D53; Wed, 26 Jan 2022 09:18:57 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 26 Jan 2022 09:18:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; bh=3WS TRLoLSWlM+HBapE7OGZG9lbR5YcJWhtgkgMOl+KY=; b=fonfa3srDqlTgdttt7i NmhsoExyvw+leT1U9kPmbdtFm940dcMvER16cdmbZv1JK3ZoewyPeYj33D8hsvDk DRGvPUsJNL5vQ1cGmOSxiS/aqqQlYhRzs5G+9FOdrx+HGJLlWO+e0DPKtj3odWW1 VIHXtgKN8ZoS3zV9B62f8cIKjoCZ1u4ua8rJYlbEd+nRcBLqEMCGWiaW+K1cK9I4 sqoNavmp3smVSo85KoKk6+s3f7kG5h+QsbcKmjN50Uv1uXxym/CiIzeTrso+sj1F z82lbRBpkqJJdii17Mulgt/z2tp9b9u4qkeKlwPOHpE3t3Snbsmpf/HKD8l/dwMu TOw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=3WSTRL oLSWlM+HBapE7OGZG9lbR5YcJWhtgkgMOl+KY=; b=B5Qcd/Stv+MavsxxxCZrat zZlCrfLakRvhZD27zrv34k9KNEOfVc6euWxH/wZEBNgdhANPSn0vPMvcf6u3MdI5 kCgzaG94niJSXyufiUW84YktLH427OXJvFXrrMBBjQ8JUO6jaASwc8BBBAfrANem 4xqC4pDTlxtQmDPxqANKOPj7md6sgMazrh4YQxIrDd+GhjljOVAzoafu4UlOJiDm cgYIPmw2H5zg64RgFMB6cPd0UzREpLCS/w6LWYOk7Oj0ehlzbCeTL0tyOZsK517O btJJ43JaTg0o4CI8TkxsVyyDIkTrhCjfWmTCR/36WMSkRglxKAR3zcK00PpiZfjQ == X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddrfedugdeivdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkedttd ertddtnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceougdrshesuggrnhhivghl rdhshhgrhhgrfhdrnhgrmhgvqeenucggtffrrghtthgvrhhnpeetgffggfefueejgffgje ejjeelueejvefhveegledvgeeigeevuefgffejfeelteenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrg hfrdhnrghmvg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Wed, 26 Jan 2022 09:18:57 -0500 (EST) Received: by tarpaulin.shahaf.local2 (Postfix, from userid 1000) id 4JkQnW63W9z4fR; Wed, 26 Jan 2022 14:18:55 +0000 (UTC) From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH 3/5] _subversion: commit, diff, revert: Update completions for svn 1.7 and newer Date: Wed, 26 Jan 2022 14:18:45 +0000 Message-Id: <20220126141847.10271-3-danielsh@tarpaulin.shahaf.local2> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220126141847.10271-1-danielsh@tarpaulin.shahaf.local2> References: <20220126141847.10271-1-danielsh@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 49713 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: * _svn_deletedfiles: Remove. The last version of svn(1) under which that function could possibly complete anything, svn 1.6.x, was EOLed in 2013. Newer versions don't have a "text-base" directory, so $controlled is set to an empty array, so this function returned false for all files, so in 'svn rm' (up to the previous commit) all files were completed (because that's what '_files -g "*(e:false:)"' does). * _svn_status: Remove. Versions of svn newer than the aforementioned 1.6.x have an entries file but never modify it, so the "mtime has changed" check would false negative. Therefore, sequences such as: . svn echo >> some/versioned/file svn ci . wouldn't offer some/versioned/file. . Furthermore, completion would offer directories with no changed files in them, and even unversioned directories. Now only changed files/directories are offered. * _cache_svn_status, _cache_svn_mtime: Remove. If these hadn't been removed, I would have moved their declarations to file scope so _svn_status could be used from outside this file, too. The replacement function, _svn_modified, doesn't have cache support, but does honour the 'verbose' style to inhibit recursion to subdirectories. --- Completion/Unix/Command/_subversion | 69 ++++++++++++++++++----------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 9ef3077f6..cb5cbd374 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -68,7 +68,6 @@ _svn () { ;; args) local cmd args usage idx - typeset -gHA _cache_svn_status _cache_svn_mtime cmd="${${(k)_svn_cmds[(R)*:$words[1]:*]}:-${(k)_svn_cmds[(i):$words[1]:]}}" if (( $#cmd )); then @@ -141,7 +140,7 @@ _svn () { (commit) args=( ${args/(#b)(*--file*):arg:/$match[1]:file:_files} - '*:file:_files -g "*(e:_svn_status:)"' + '*:file: _svn_modified "committable"' ) ;; (delete) @@ -151,7 +150,7 @@ _svn () { ;; (diff) args+=( - '*: : _alternative "files:file:_files -g \*\(e:_svn_status:\)" "urls:URL:_svn_urls"' + '*: : _alternative "files:file: _svn_modified revertable" "urls:URL:_svn_urls"' ) ;; (help) @@ -201,7 +200,7 @@ _svn () { ;; (revert) args+=( - '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"' + '*:file: _svn_modified "revertable"' ) ;; (x-unshelve) @@ -368,33 +367,51 @@ _svn_conflicts() { () { (( $# > 0 )) } $REPLY.(mine|r<->)(NY1) } -(( $+functions[_svn_deletedfiles] )) || -_svn_deletedfiles() { - # Typical usage would be _files -g '.svn(/e:_svn_deletedfiles:)' - local cont controlled - reply=( ) - [[ $REPLY = (*/|).svn ]] || return - controlled=( $REPLY/text-base/*.svn-base(N:r:t) ) - for cont in ${controlled}; do - [[ -e $REPLY:h/$cont ]] || reply+=( ${REPLY%.svn}$cont ) - done -} +(( $+functions[_svn_modified] )) || +_svn_modified() { + setopt localoptions extendedglob -(( $+functions[_svn_status] )) || -_svn_status() { - local dir=$REPLY:h - local pat="${1:-([ADMR~]|?M)}" + local depth dir expl partial_word space=' ' - zmodload -F zsh/stat b:zstat 2>/dev/null - local key="$(zstat +device $dir):$(zstat +inode $dir)" - local mtime="$(zstat +mtime $dir/.svn/entries)" + local svn_context=$1 - if (( ! $+_cache_svn_status[$key] || _cache_svn_mtime[$key] != mtime )); then - _cache_svn_status[$key]="$(_call_program files svn status -q -N -- $dir)" - _cache_svn_mtime[$key]="$mtime" + local partial_word=${(Q)words[CURRENT]} + if [[ -z $partial_word ]]; then + dir="./" + elif [[ -d $partial_word ]]; then + dir=$partial_word + else + dir=${partial_word:h} fi - (( ${(M)#${(f)_cache_svn_status[$key]}:#(#s)${~pat}*$REPLY} )) + if zstyle -T ":completion:${curcontext}:${curtag}" verbose; then + depth=infinity + else + depth=immediates + fi + + local -a status_lines + # Run 'status' + status_lines=( ${(f)"$(_call_program modified-files "svn status -q --depth=${(q)depth} -- ${(q)dir}")"} ) + # Filter to only the right set of statuses + case $svn_context in + (committable) + status_lines=( ${(M)status_lines:#(#s)([ADMR]?|?M)${space}???${space}${space}*} ) + ;; + (revertable) + status_lines=( ${(M)status_lines:#(#s)([ACDMR~!]?|?[CM])${space}????${space}*} ) + ;; + esac + # Strip the 7 status-letter columns and the column of spaces + status_lines=( ${status_lines#????????} ) + # Strip one leading space. This is in case `svn status` ever adds another + # column. If that hasn't happened and you're reading this comment because + # the following line broke your use of filenames that start with a literal + # space, well, nice to meet you! I didn't know you existed. + status_lines=( ${status_lines#${space}} ) + + _wanted svn-modified expl 'modified files in svn' \ + compadd - "${status_lines[@]}" } (( $+functions[_svn_remote_paths] )) ||