Commits

ZyX_I committed 07f2881

@aurum/drivers/subversion: Added rf-annotate()
@aurum/annotate, @aurum/cmdutils, ftplugin/aurumannotate: Added support for line=0 in rf-annotate() output

Comments (0)

Files changed (5)

     supported, option "reverse" is supported only if two revisions are given.
 |aurum-rf-status|: if at least one of first two optional arguments is 
     non-zero, then then unknown and deleted files won’t be shown (if any).
+|aurum-rf-annotate| neither tracks renames/copies nor is able to output line 
+    numbers.
 
 ==============================================================================
 11. Changelog                                                *aurum-changelog*

ftplugin/aurumannotate.vim

     let bvar=s:_r.bufvars[buf]
     let hex=bvar.revisions[line('.')-1]
     let file=bvar.files[line('.')-1]
-    let hasannbuf = has_key(bvar, 'annbuf') && bufwinnr(bvar.annbuf)!=-1
+    let hasannbuf=has_key(bvar, 'annbuf')
+    if hasannbuf
+        let abwnr=bufwinnr(bvar.annbuf)
+        let hasannbuf=(abwnr!=-1)
+    endif
     "▶2 Various *diff actions
     if a:action[-4:] is# 'diff'
         if a:action[:2] is# 'rev'
         let rev2=hex
         if hasannbuf
             wincmd c
-            execute bufwinnr(bvar.annbuf).'wincmd w'
+            execute abwnr.'wincmd w'
             setlocal noscrollbind
         endif
         if a:action[-7:-5] is# 'vim'
         if a:0 && a:1
             let file=bvar.files[line('.')-1]
             let lnr=bvar.linenumbers[line('.')-1]
+            if lnr is 0
+                unlet lnr
+            endif
         else
             let file=s:F.getfile(bvar.repo,
                         \        bvar.repo.functions.getcs(bvar.repo, hex))
         endif
         if hasannbuf
             let lnr=bvar.linenumbers[line('.')-1]
+            if lnr is 0
+                let ablnr=line('.')
+                execute abwnr.'wincmd w'
+                let line=getline(ablnr)
+                unlet lnr
+                wincmd p
+            endif
             call s:_r.run('silent edit', 'annotate', bvar.repo, hex, file)
-            execute lnr
+            if exists('lnr')
+                execute lnr
+            endif
             setlocal scrollbind cursorbind
             let abuf=bufnr('%')
             let newbvar=s:_r.bufvars[abuf]
-            execute bufwinnr(bvar.annbuf).'wincmd w'
+            execute abwnr.'wincmd w'
         endif
         let existed=s:_r.run('silent edit', 'file', bvar.repo, hex, file)
         if exists('lnr')
             execute lnr
+        elseif exists('line')
+            0
+            call search('\V\^'.escape(line, '\').'\$', 'cW')
+            let lnr=line('.')
+            wincmd p
+            execute lnr
+            wincmd p
         endif
         if hasannbuf
             if exists('lnr')
         let abuf=bufnr('%')
         let newbvar=s:_r.bufvars[abuf]
         if hasannbuf
-            execute bufwinnr(bvar.annbuf).'wincmd w'
+            execute abwnr.'wincmd w'
             setlocal noscrollbind
         else
             vsplit

plugin/aurum/annotate.vim

     if rev is 0
         let rev=repo.functions.getworkhex(repo)
     endif
+    if hasannbuf==2
+        let hasannbuf=!repo.functions.dirty(repo, file)
+    endif
     if hasannbuf
         let annbuf=bufnr('%')
     else

plugin/aurum/cmdutils.vim

             let file=repo.functions.reltorepo(repo, expand('%'))
         endif
         let  rev=0
-        let hasbuf=1
+        let hasbuf=2
     "▲2
     elseif a:failmsg isnot 0
         call s:_f.throw(a:failmsg)

plugin/aurum/drivers/subversion.vim

     return r
 endfunction
 "▶1 svn.annotate :: repo, rev, file → [(file, hex, linenumber)]
+" TODO use merge history if available
 function s:svn.annotate(repo, rev, file)
     let args=['--', a:file]
     let kwargs={'revision': ''.a:rev}
     let lines=s:F.svn(a:repo, 'blame', args, kwargs, 1, 'annf', a:rev, a:file)
     let r=[]
+    for line in lines
+        let r+=[[a:file, matchstr(line, '\v\d+'), 0]]
+    endfor
     return r
 endfunction
 "▶1 svn.commit :: repo, message[, files[, user[, date[, _]]]]