From 911500d3be2a604176657028f8adfb9e4d3b42cd Mon Sep 17 00:00:00 2001 From: Yasuhiro KIMURA Date: Fri, 29 May 2020 06:36:47 +0900 Subject: 45934: _subversion: Make 'svnliteadmin' completed same as 'svnadmin' In FreeBSD base system svnadmin is installed as 'svnliteadmin'. So make 'svnliteadmin' completed same as 'svnadmin'. --- Completion/Unix/Command/_subversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index a1e9109de..26eef500f 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -1,4 +1,4 @@ -#compdef svn svnlite=svn svnadmin svnadmin-static=svnadmin +#compdef svn svnlite=svn svnadmin svnadmin-static=svnadmin svnliteadmin=svnadmin _svn () { local curcontext="$curcontext" state line expl ret=1 -- cgit v1.2.3 From 63425124835ec6c5cccdb17b50ac2a4cb8a0e90f Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 26 Jan 2022 14:18:43 +0000 Subject: 49711: _subversion: _svn_status: Don't offer unversioned files This function is used only by revert, diff, and commit, none of which can run on unversioned files (those with status '?'). --- ChangeLog | 5 +++++ Completion/Unix/Command/_subversion | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/ChangeLog b/ChangeLog index 11166e6bb..3636b8e65 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2022-01-29 Daniel Shahaf + + * 49711: Completion/Unix/Command/_subversion: _svn_status: + Don't offer unversioned files + 2022-01-27 Daniel Shahaf * unposted: Doc/Zsh/contrib.yo: vcs_info quilt docs: Fix diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 26eef500f..2f66c3522 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -390,7 +390,7 @@ _svn_status() { local mtime="$(zstat +mtime $dir/.svn/entries)" if (( ! $+_cache_svn_status[$key] || _cache_svn_mtime[$key] != mtime )); then - _cache_svn_status[$key]="$(_call_program files svn status -N $dir)" + _cache_svn_status[$key]="$(_call_program files svn status -q -N -- $dir)" _cache_svn_mtime[$key]="$mtime" fi -- cgit v1.2.3 From cb2b0e7c6cdd851f79b6856335e8ab7a3d3d1935 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 26 Jan 2022 14:18:44 +0000 Subject: 49712: _subversion: svn rm: Complete all svn-controlled files, not only missing/deleted files Note that currently, _svn_controlled matches all files. --- ChangeLog | 3 +++ Completion/Unix/Command/_subversion | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/ChangeLog b/ChangeLog index 3636b8e65..9d308258a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-01-29 Daniel Shahaf + * 49712: Completion/Unix/Command/_subversion: svn rm: Complete + all svn-controlled files, not only missing/deleted files + * 49711: Completion/Unix/Command/_subversion: _svn_status: Don't offer unversioned files diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 2f66c3522..9ef3077f6 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -146,7 +146,7 @@ _svn () { ;; (delete) args+=( - '*:file:_files -g ".svn(/e:_svn_deletedfiles:)"' + '*:file:_files -g "*(e:_svn_controlled:)"' ) ;; (diff) -- cgit v1.2.3 From a803a5f4c46629c18c05a9ee09d5ae34407e35c4 Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 26 Jan 2022 14:18:45 +0000 Subject: 49713: _subversion: commit, diff, revert: Update completions for svn 1.7 and newer * _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. --- ChangeLog | 3 ++ Completion/Unix/Command/_subversion | 69 +++++++++++++++++++++++-------------- 2 files changed, 46 insertions(+), 26 deletions(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/ChangeLog b/ChangeLog index 9d308258a..15e3a9999 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-01-29 Daniel Shahaf + * 49713: Completion/Unix/Command/_subversion: commit, diff, + revert: Update completions for svn 1.7 and newer + * 49712: Completion/Unix/Command/_subversion: svn rm: Complete all svn-controlled files, not only missing/deleted files 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] )) || -- cgit v1.2.3 From a956caa2339ea8ae07765943687925c7c2a836bf Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 26 Jan 2022 14:18:46 +0000 Subject: 49714: _subversion: resolve: Complete conflicted files created by merges, too --- ChangeLog | 3 +++ Completion/Unix/Command/_subversion | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/ChangeLog b/ChangeLog index 15e3a9999..d2598a8ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-01-29 Daniel Shahaf + * 49714: Completion/Unix/Command/_subversion: resolve: Complete + conflicted files created by merges, too + * 49713: Completion/Unix/Command/_subversion: commit, diff, revert: Update completions for svn 1.7 and newer diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index cb5cbd374..e9a3d9b1a 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -364,7 +364,11 @@ _svn_uncontrolled() { (( $+functions[_svn_conflicts] )) || _svn_conflicts() { - () { (( $# > 0 )) } $REPLY.(mine|r<->)(NY1) + # ### These strings are actually translatable + # + # The asterisks are to support an optional extension; see + # "preserved-conflict-file-exts" in ~/.subversion/config. + () { (( $# > 0 )) } $REPLY.(mine|r<->|working*|merge-left*|merge-right*)(NY1) } (( $+functions[_svn_modified] )) || -- cgit v1.2.3 From 04513dd5df31bc235691400b76a524d117cefede Mon Sep 17 00:00:00 2001 From: Daniel Shahaf Date: Wed, 26 Jan 2022 14:18:47 +0000 Subject: 49715: _subversion: add: Complete target arguments to this subcommand --- ChangeLog | 3 +++ Completion/Unix/Command/_subversion | 24 ++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) (limited to 'Completion/Unix/Command/_subversion') diff --git a/ChangeLog b/ChangeLog index d2598a8ca..328844766 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2022-01-29 Daniel Shahaf + * 49715: Completion/Unix/Command/_subversion: add: Complete + target arguments to this subcommand + * 49714: Completion/Unix/Command/_subversion: resolve: Complete conflicted files created by merges, too diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index e9a3d9b1a..8fc46a292 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -122,7 +122,7 @@ _svn () { case $cmd in; (add) args+=( - '*:file:_files -g "*(e:_svn_uncontrolled:)"' + '*:file: _svn_modified "addable"' ) ;; (auth) @@ -350,18 +350,12 @@ _svn_controlled() { # because 1.6 has been deprecated for 8 years and EOL for 6 years, we opt to DTRT # for >=1.7. Therefore: - # TODO: Reimplement this function and _svn_uncontrolled for svn>=1.7. + # TODO: Reimplement this function for svn>=1.7. # (Use 'svn st' or 'svn info', not 'svn ls') return 0 } -(( $+functions[_svn_uncontrolled] )) || -_svn_uncontrolled() { - # TODO: See comments in _svn_controlled - return 0 -} - (( $+functions[_svn_conflicts] )) || _svn_conflicts() { # ### These strings are actually translatable @@ -375,7 +369,7 @@ _svn_conflicts() { _svn_modified() { setopt localoptions extendedglob - local depth dir expl partial_word space=' ' + local depth dir expl maybe_quiet partial_word space=' ' local svn_context=$1 @@ -394,9 +388,15 @@ _svn_modified() { depth=immediates fi + if [[ $svn_context = addable ]]; then + maybe_quiet="" + else + maybe_quiet="-q" + fi + local -a status_lines # Run 'status' - status_lines=( ${(f)"$(_call_program modified-files "svn status -q --depth=${(q)depth} -- ${(q)dir}")"} ) + status_lines=( ${(f)"$(_call_program modified-files "svn status $maybe_quiet --depth=${(q)depth} -- ${(q)dir}")"} ) # Filter to only the right set of statuses case $svn_context in (committable) @@ -405,6 +405,10 @@ _svn_modified() { (revertable) status_lines=( ${(M)status_lines:#(#s)([ACDMR~!]?|?[CM])${space}????${space}*} ) ;; + (addable) + # The 'D' is just in case there's an unversioned file of the same name as the deleted file + status_lines=( ${(M)status_lines:#(#s)[?ID]${space}${space}???${space}${space}*} ) + ;; esac # Strip the 7 status-letter columns and the column of spaces status_lines=( ${status_lines#????????} ) -- cgit v1.2.3