Commits

ZyX_I committed e24212e

@%aurum/file, @%aurum/annotate: Added renames support
Fixes #75. Untested
@%aurum/maputils: Added _r.maputils.getnthparentfile function

Comments (0)

Files changed (4)

autoload/aurum/file.vim

 "▶1 
 scriptencoding utf-8
 execute frawor#Setup('0.1', {'@%aurum/cmdutils': '4.1',
-            \                '@%aurum/maputils': '0.0',
+            \                '@%aurum/maputils': '0.1',
             \                 '@%aurum/bufvars': '0.0',
             \               '@%aurum/lineutils': '0.0',
             \                 '@%aurum/vimdiff': '1.0',
         call s:_r.maputils.update(bvar.repo, bvar.rev, v:count)
     elseif a:action is# 'previous' || a:action is# 'next'
         let c=((a:action is# 'previous')?(v:count1):(-v:count1))
-        let rev=bvar.repo.functions.getnthparent(bvar.repo, bvar.rev, c).hex
-        let hadbhwipe=(&bufhidden is# 'wipe')
-        call s:_r.mrun('silent edit', 'file', bvar.repo, rev, bvar.file)
+        let [rev, file]=s:_r.maputils.getnthparentfile(bvar.repo, bvar.rev,
+                    \                                  bvar.file, c)
+        let existed=s:_r.mrun('silent edit', 'file', bvar.repo, rev, file)
         if bufexists(buf)
             execute 'bwipeout' buf
         endif
-        if hadbhwipe
-            setlocal bufhidden=wipe
-        endif
     elseif a:action is# 'vimdiff'
         let file=s:_r.os.path.normpath(s:_r.os.path.join(bvar.repo.path,
                     \                                    bvar.file))
                     \                            v:count1).hex
         call s:_r.vimdiff.split([['file', bvar.repo, rev, bvar.file]], -1)
     elseif a:action is# 'diff'
-        call s:_r.mrun('silent edit', 'diff', bvar.repo, '', bvar.rev,
-                    \                         [bvar.file], {})
-        setlocal bufhidden=wipe
+        let existed=s:_r.mrun('silent edit', 'diff', bvar.repo, '', bvar.rev,
+                    \                                [bvar.file], {})
     elseif a:action is# 'revdiff'
-        call s:_r.mrun('silent edit', 'diff', bvar.repo, bvar.rev, '',
-                    \                         [bvar.file], {})
-        setlocal bufhidden=wipe
+        let existed=s:_r.mrun('silent edit', 'diff', bvar.repo, bvar.rev, '',
+                    \                                [bvar.file], {})
     elseif a:action is# 'fulldiff'
-        call s:_r.mrun('silent edit', 'diff', bvar.repo, '', bvar.rev,
-                    \                         [], {})
-        setlocal bufhidden=wipe
+        let existed=s:_r.mrun('silent edit', 'diff', bvar.repo, '', bvar.rev,
+                    \                                [], {})
     elseif a:action is# 'revfulldiff'
-        call s:_r.mrun('silent edit', 'diff', bvar.repo, bvar.rev, '',
-                    \                         [], {})
-        setlocal bufhidden=wipe
+        let existed=s:_r.mrun('silent edit', 'diff', bvar.repo, bvar.rev, '',
+                    \                                [], {})
     elseif a:action is# 'fullvimdiff'
         call s:_r.vimdiff.full(bvar.repo, [0, bvar.rev], 1, [], 0)
     elseif a:action is# 'revfullvimdiff'
         endif
         call s:_r.vimdiff.full(bvar.repo, [bvar.rev, cs.parents[0]], 1, [], 0)
     endif
+    if exists('existed') && !existed
+        setlocal bufhidden=wipe
+    endif
 endfunction
 "▶2 s:m
 function s:m(...)

autoload/aurum/maputils.vim

 "▶1
 scriptencoding utf-8
-execute frawor#Setup('0.0', {'@/resources': '0.0',
+execute frawor#Setup('0.1', {'@/resources': '0.0',
             \                       '@/os': '0.0',})
 let s:_messages={
             \'plinst': 'If you install Command-T, Ctrlp, FuzzyFinder, unite, '.
 function s:r.readfilewrapper(file, repo, rev)
     return a:repo.functions.readfile(a:repo, a:rev, a:file)
 endfunction
+"▶1 getnthparentfile :: repo, rev, file, n → (hex, file)
+function s:r.getnthparentfile(repo, rev, file, n)
+    let n=a:n
+    let shift=(n>0 ? 1 : -1)
+    let file=a:file
+    let hex=a:repo.functions.getrevhex(a:repo, a:rev)
+    while n
+        let cs=a:repo.functions.getnthparent(a:repo, hex, shift)
+        let rhex=(shift>0 ? hex : cs.hex)
+        if cs.hex is# hex
+            break
+        endif
+        let hex=cs.hex
+        let renames=a:repo.functions.getcsprop(a:repo, rhex, 'renames')
+        if shift<0
+            let rrenames={}
+            call map(copy(renames), 'extend(rrenames, {v:val : v:key})')
+            let renames=rrenames
+        endif
+        if get(renames, file, 0) isnot 0
+            let file=renames[file]
+        endif
+        let n-=shift
+    endwhile
+    return [hex, file]
+endfunction
 "▶1 Post maputils resource
 call s:_f.postresource('maputils', s:r)
 "▶1
     0.1: Added |:AuFile| prompt option.
 @%aurum/hyperlink:
     0.1: Added support for password in URL.
+@%aurum/maputils:
+    0.1: Added _r.maputils.getnthparentfile()
 
 vim: ft=help:tw=78

ftplugin/aurumannotate.vim

             \                '@%aurum/vimdiff': '1.1',
             \               '@%aurum/annotate': '1.0',
             \               '@%aurum/cmdutils': '4.0',
-            \               '@%aurum/maputils': '0.0',
+            \               '@%aurum/maputils': '0.1',
             \                   '@%aurum/edit': '1.2',
             \                     '@/mappings': '0.0',
             \                           '@/os': '0.0',})
     "▶2 `previous' and `next' actions
     elseif a:action is# 'previous' || a:action is# 'next'
         let c=((a:action is# 'previous')?(v:count1):(-v:count1))
-        let rev=bvar.repo.functions.getnthparent(bvar.repo, bvar.rev, c).hex
-        if rev is# hex
-            call s:_f.throw('no'.a:action[:3], hex)
+        let [rev, file]=s:_r.maputils.getnthparentfile(bvar.repo, bvar.rev,
+                    \                                  bvar.file, c)
+        if rev is# bvar.rev
+            call s:_f.throw('no'.a:action[:3], bvar.rev)
         endif
-        call s:_r.run('silent edit', 'annotate', bvar.repo, rev, bvar.file)
+        call s:_r.run('silent edit', 'annotate', bvar.repo, rev, file)
         let newbvar=s:_r.bufvars[bufnr('%')]
         if hasannbuf
             execute annwin.'wincmd w'
             vertical resize 42
             wincmd p
         endif
-        let existed=s:_r.mrun('silent edit', 'file', bvar.repo, rev, bvar.file)
+        let existed=s:_r.mrun('silent edit', 'file', bvar.repo, rev, file)
         let annbuf=bufnr('%')
         wincmd p
         call s:_r.annotate.setannbuf(newbvar, annbuf)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.