1. ZyX_I
  2. aurum

Commits

ZyX_I  committed 5898b51

Added :AuMove tests
Some fixes

  • Participants
  • Parent commits fd86a9e
  • Branches default

Comments (0)

Files changed (5)

File plugin/aurum.vim

View file
             \'\V|*_r.repo.get',     '',            ''),
             \'\V:"tip"\s\+type ""', s:_r.comp.rev, ''))
 "▶1 movefunc
+" :AuM          — move current file to current directory
+" :AuM dir      — move current file to given directory
+" :AuM pat  pat — act like `zmv -W': use second pat to construct new file name
+" :AuM pat+ dir — move given file(s) to given directory
+" :AuM pat+     — move given file(s) to current directory
 function s:movefunc.function(bang, opts, ...)
     if a:0
-        let repo=s:_r.repo.get(a:0)
+        let repo=s:_r.repo.get(a:1)
     else
         let repo=s:_r.repo.get(':')
     endif
     let cs=repo.functions.getcs(repo, '.')
-    call repo.functions.getcsprop(repo, cs, 'allfiles')
+    let allfiles=copy(repo.functions.getcsprop(repo, cs, 'allfiles'))
+    let status=repo.functions.status(repo)
+    call filter(allfiles, 'index(status.removed, v:val)==-1 && '.
+                \         'index(status.deleted, v:val)==-1')
+    let allfiles+=status.added
     if get(a:opts, 'copy', 0)
         let key='copy'
     else
                     \                       1)
         let repl=split(a:2, '\V\(**\?\|?\)', 1)
         let moves={}
-        for [file, match] in filter(map(copy(cs.allfiles),
+        for [file, match] in filter(map(copy(allfiles),
                     \                   '[v:val, matchlist(v:val, pattern)]'),
                     \               '!empty(v:val[1])')
             let target=''
             call call(repo.functions[key], [repo, a:bang, file, target], {})
         endfor
         return
-    elseif a:0==2 && !isdirectory(a:2)
+    elseif a:0==2 && !isdirectory(a:2) && filewritable(a:1)
         let fst=a:1
         if fst is# ':'
             let fst=s:_r.cmdutils.getrrf(rrfopts, 'nocurf', -1)[3]
         let files=[]
         for pattern in map(copy(globs), 's:_r.cmdutils.globtopat('.
                     \                   'repo.functions.reltorepo(repo,v:val))')
-            let files+=filter(copy(cs.allfiles),
+            let files+=filter(copy(allfiles),
                         \     'v:val=~#pattern && index(files, v:val)==-1')
         endfor
         if hascur
         if !empty(target)
             let dest=s:_r.os.path.join(target, dest)
         endif
-        echom file '->' dest
         call call(repo.functions[key], [repo, a:bang, file, dest], {})
     endfor
 endfunction

File test/move.in

View file
+:command -bar CS :execute 'Run AuStatus' | bwipeout! | bwipeout! | for file in split(glob(g:curtest.'repo/test/*'), "\n") | call delete(file) | endfor | R silent AuUpdate!
+:W{{{1 :AuM
+:R call mkdir('test')
+:R silent edit hglines.lst
+:execute 'silent cd ./'.g:curtest.'repo/test'
+:AuMove
+:silent cd ../..
+:CS
+:W{{{1 :AuM dir
+:R silent edit alines.lst
+:R AuMove test
+:CS
+:W{{{1 :AuM pat pat
+:execute 'AuMove '.g:curtest.'repo/**.lst '.g:curtest.'repo/test/**.mkv'
+:CS
+:W{{{1 :AuM pat pat
+:execute 'silent cd ./'.g:curtest.'repo/test'
+:AuMove ../*.lst ../?*.zsh
+:silent cd ../..
+:CS
+:W{{{1 :AuM pat dir
+:R AuMove *.lst test
+:CS
+:source addmessages.vim

File test/move.ok

View file
+{{{1 :AuM
+A test/hglines.lst
+R hglines.lst
+{{{1 :AuM dir
+A test/alines.lst
+R alines.lst
+{{{1 :AuM pat pat
+A test/ablines.mkv
+A test/alines.mkv
+A test/blines.mkv
+A test/clines.mkv
+A test/datelines.mkv
+A test/dlines.mkv
+A test/hglines.mkv
+A test/hglines2.mkv
+A test/ignored10.mkv
+A test/nohglines.mkv
+A test/nohglinesrev.mkv
+R ablines.lst
+R alines.lst
+R blines.lst
+R clines.lst
+R datelines.lst
+R dlines.lst
+R hglines.lst
+R hglines2.lst
+R ignored10.lst
+R nohglines.lst
+R nohglinesrev.lst
+{{{1 :AuM pat pat
+A test/ablines.lst
+A test/alines.lst
+A test/blines.lst
+A test/chgrepo.zsh
+A test/clines.lst
+A test/datelines.lst
+A test/dlines.lst
+A test/hglines.lst
+A test/hglines2.lst
+A test/ignored10.lst
+A test/nohglines.lst
+A test/nohglinesrev.lst
+R ablines.lst
+R alines.lst
+R blines.lst
+R chgrepo.zsh
+R clines.lst
+R datelines.lst
+R dlines.lst
+R hglines.lst
+R hglines2.lst
+R ignored10.lst
+R nohglines.lst
+R nohglinesrev.lst
+{{{1 :AuM pat dir
+A test/ablines.lst
+A test/alines.lst
+A test/blines.lst
+A test/clines.lst
+A test/datelines.lst
+A test/dlines.lst
+A test/hglines.lst
+A test/hglines2.lst
+A test/ignored10.lst
+A test/nohglines.lst
+A test/nohglinesrev.lst
+R ablines.lst
+R alines.lst
+R blines.lst
+R clines.lst
+R datelines.lst
+R dlines.lst
+R hglines.lst
+R hglines2.lst
+R ignored10.lst
+R nohglines.lst
+R nohglinesrev.lst

File test/prevmessage.ok

View file
 |  @ files
 >>> Messages:
 
-%TMPDIR%/test
 
 
 Frawor:plugin/aurum/commit:emptmsg:Message must contain at least one non-blank character

File test/vimrc

View file
 syntax on
 let s:outfile=fnamemodify(g:outfile, ':p')
 function s:Run(bang, write, cmd)
-    let reporoot=g:curtest.'repo'
+    let reporoot='./'.g:curtest.'repo'
+    let olddir=fnamemodify('.', ':p')
     if !a:bang
-        execute 'cd' fnameescape(reporoot)
+        execute 'silent cd' fnameescape(reporoot)
     endif
     execute a:cmd
     if exists('g:postcmd')
         execute 'silent' g:postcmd
     endif
     if !a:bang
-        cd ..
+        execute 'silent cd' fnameescape(olddir)
     endif
     if a:write
         execute 'silent write! >> '.fnameescape(s:outfile)