Commits

ZyX_I committed 02774a9

@%aurum/file: Added Fdiff, RFdiff, FVdiff and RFVdiff mappings
Made it no longer use <expr> mappings

Comments (0)

Files changed (4)

autoload/aurum/file.vim

             \                            '@/os': '0.0',
             \                      '@/mappings': '0.0',})
 let s:_messages={
-            \'wfail': 'Writing to %s failed',
-            \'dfail': 'Failed to delete %s',
+            \ 'wfail': 'Writing to %s failed',
+            \ 'dfail': 'Failed to delete %s',
+            \'nopars': 'Revision %s has no parents',
         \}
 "▶1 callbacks
 let s:F.callbacks={}
 call s:_f.newcommand(s:file)
 unlet s:file
 "▶1 aurum://file mappings
-let s:mmgroup=':call <SNR>'.s:_sid.'_Eval("s:_f.mapgroup.map(''AuFile'', '.
-            \                                               "bufnr('%'))\")\n"
-function s:F.runfilemap(action)
+function s:F.runmap(action)
     let buf=bufnr('%')
     let bvar=s:_r.bufvars[buf]
-    let cmd="\<C-\>\<C-n>"
     if a:action is# 'exit'
-        let cmd.=s:_r.cmdutils.closebuf(bvar)
+        execute s:_r.cmdutils.closebuf(bvar)
     elseif a:action is# 'update'
         call s:_r.maputils.update(bvar.repo, bvar.rev, v:count)
-        return ''
     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 cmd.=':edit '.fnameescape(s:_r.fname('file', bvar.repo, rev,
-                    \                            bvar.file))."\n"
-        let cmd.=s:mmgroup
-        let cmd.=":bwipeout ".buf."\n"
-    elseif a:action is# 'vimdiff' || a:action is# 'revvimdiff'
-        if a:action is# 'vimdiff'
-            let file=s:_r.os.path.normpath(s:_r.os.path.join(bvar.repo.path,
-                        \                                    bvar.file))
-            let cmd.=':diffsplit '.fnameescape(file)."\n"
-        else
-            let rev=bvar.repo.functions.getnthparent(bvar.repo, bvar.rev, 1).hex
-            let file=s:_r.fname('file', bvar.repo, rev, bvar.file)
-            let cmd.=':call call(<SNR>'.s:_sid.'_Eval("s:_r.vimdiff.split"), '.
-                        \       '['.string(file).", 0], {})\n"
+        let hadbhwipe=(&bufhidden is# 'wipe')
+        call s:_r.mrun('silent edit', 'file', bvar.repo, rev, bvar.file)
+        if bufexists(buf)
+            execute 'bwipeout' buf
         endif
-    elseif a:action is# 'diff' || a:action is# 'revdiff'
-        let opts='repo '.escape(bvar.repo.path, ' ')
-        if a:action is# 'diff'
-            let opts.=' rev2 '.bvar.rev
-        else
-            let opts.=' rev1 '.bvar.rev
+        if hadbhwipe
+            setlocal bufhidden=wipe
         endif
-        let cmd.=':AuDiff '.opts."\n"
+    elseif a:action is# 'vimdiff'
+        let file=s:_r.os.path.normpath(s:_r.os.path.join(bvar.repo.path,
+                    \                                    bvar.file))
+        call s:_r.vimdiff.split([file], -1)
+    elseif a:action is# 'revvimdiff'
+        let rev=bvar.repo.functions.getnthparent(bvar.repo, bvar.rev,
+                    \                            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
+    elseif a:action is# 'revdiff'
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, bvar.rev, '',
+                    \                         [bvar.file], {})
+        setlocal bufhidden=wipe
+    elseif a:action is# 'fulldiff'
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, '', bvar.rev,
+                    \                         [], {})
+        setlocal bufhidden=wipe
+    elseif a:action is# 'revfulldiff'
+        call s:_r.mrun('silent edit', 'diff', bvar.repo, bvar.rev, '',
+                    \                         [], {})
+        setlocal bufhidden=wipe
+    elseif a:action is# 'fullvimdiff'
+        call s:_r.vimdiff.full(bvar.repo, [0, bvar.rev], 1, [], 0)
+    elseif a:action is# 'revfullvimdiff'
+        let cs=bvar.repo.functions.getcs(bvar.repo, bvar.rev)
+        if empty(cs.parents)
+            call s:_f.throw('nopars', cs.hex)
+        endif
+        call s:_r.vimdiff.full(bvar.repo, [bvar.rev, cs.parents[0]], 1, [], 0)
     endif
-    return cmd
 endfunction
+"▶2 s:m
+function s:m(...)
+    return ':<C-u>call call(<SID>Eval("s:F.runmap"), '.string(a:000).', {})<CR>'
+endfunction
+"▲2
 call s:_f.mapgroup.add('AuFile', {
-            \  'Next': {'lhs': 'K', 'rhs': ['next'      ]},
-            \  'Prev': {'lhs': 'J', 'rhs': ['previous'  ]},
-            \'Update': {'lhs': 'U', 'rhs': ['update'    ]},
-            \  'Exit': {'lhs': 'X', 'rhs': ['exit'      ]},
-            \  'Diff': {'lhs': 'd', 'rhs': [      'diff']},
-            \ 'Rdiff': {'lhs': 'c', 'rhs': ['rev'.'diff']},
-            \ 'Vdiff': {'lhs': 'D', 'rhs': [   'vimdiff']},
-            \'RVdiff': {'lhs': 'C', 'rhs': ['revvimdiff']},
-        \}, {'func': s:F.runfilemap, 'silent': 1, 'mode': 'n', 'dontmap': 1,})
+            \   'Next': {'lhs':  'K', 'rhs': s:m('next'          )},
+            \   'Prev': {'lhs':  'J', 'rhs': s:m('previous'      )},
+            \ 'Update': {'lhs':  'U', 'rhs': s:m('update'        )},
+            \   'Exit': {'lhs':  'X', 'rhs': s:m('exit'          )},
+            \   'Diff': {'lhs':  'd', 'rhs': s:m(          'diff')},
+            \  'Rdiff': {'lhs':  'c', 'rhs': s:m('rev'.    'diff')},
+            \  'Vdiff': {'lhs':  'D', 'rhs': s:m(       'vimdiff')},
+            \ 'RVdiff': {'lhs':  'C', 'rhs': s:m('rev'. 'vimdiff')},
+            \  'Fdiff': {'lhs': 'gd', 'rhs': s:m(   'full'.'diff')},
+            \ 'RFdiff': {'lhs': 'gc', 'rhs': s:m('revfull'.'diff')},
+            \ 'FVdiff': {'lhs': 'gD', 'rhs': s:m(   'fullvimdiff')},
+            \'RFVdiff': {'lhs': 'gC', 'rhs': s:m('revfullvimdiff')},
+        \}, {'silent': 1, 'mode': 'n', 'dontmap': 1,})
+delfunction s:m
 "▶1
 call frawor#Lockvar(s:, '_r,_pluginloaded')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲
     Open file {file} from repository {repo} as it was at revision {rev}.
     Local mappings (mgid=AuFile, without leader by default):
                                                           *g:frawormap_AuFile*
-                        *g:frawormap_AuFile_Next*  *g:frawormap_AuFile_Prev*
-                        *g:frawormap_AuFile_Diff*  *g:frawormap_AuFile_Update*
-                        *g:frawormap_AuFile_Rdiff* *g:frawormap_AuFile_RVdiff*
-                        *g:frawormap_AuFile_Vdiff*     *aurum-m-AuFile_Vdiff*
-                            *aurum-m-AuFile_Next*      *aurum-m-AuFile_Prev*
-                            *aurum-m-AuFile_Rdiff*     *aurum-m-AuFile_RVdiff*
-                            *aurum-m-AuFile_Diff*      *aurum-m-AuFile_Update*
+                       *g:frawormap_AuFile_Next*  *g:frawormap_AuFile_RFdiff*
+                       *g:frawormap_AuFile_Prev*  *g:frawormap_AuFile_RFVdiff*
+                       *g:frawormap_AuFile_Diff*  *g:frawormap_AuFile_Update*
+                       *g:frawormap_AuFile_Rdiff* *g:frawormap_AuFile_RVdiff*
+                       *g:frawormap_AuFile_Fdiff* *g:frawormap_AuFile_FVdiff*
+                       *g:frawormap_AuFile_Vdiff*     *aurum-m-AuFile_Vdiff*
+                           *aurum-m-AuFile_Next*      *aurum-m-AuFile_RFdiff*
+                           *aurum-m-AuFile_Prev*      *aurum-m-AuFile_RFVdiff*
+                           *aurum-m-AuFile_Rdiff*     *aurum-m-AuFile_RVdiff*
+                           *aurum-m-AuFile_Diff*      *aurum-m-AuFile_Update*
+                           *aurum-m-AuFile_Fdiff*     *aurum-m-AuFile_FVdiff*
     Mapname  LHS  Description ~
     Next      K   View current file as it was at first child of current 
                   revision. Accepts count, in this case first child is taken 
     RVdiff    C   View |vimdiff| between current buffer and aurum://file 
                   buffer with revision set to first parent of {rev} and same 
                   {repo} and {file} arguments
+    Fdiff    gd   View changes between current revision and working directory 
+                  state
+    RFdiff   gc   View changes introduced by current revision
+    FVdiff   gD   View changes between current revision and working directory 
+                  state in a multiple tabs each containing |vimdiff|
+    RFVdiff  gC   View all changes introduced by current revision as 
+                  a |vimdiff| in a multiple tabs
 
     Note These mappings are defined only when buffer is created using 
          |:AuFile| command or from most mappings.
 Date       gM       l      Shows revisions committed in the current month
 Branch     gb       l      Shows revisions that have the same branch
 Rev        gr       l      Shows revisions that are descendants of the current
-FVdiff     gD   acD lS  g  Shows full vimdiff between current revision and WD
+FVdiff     gD   acDflS  g  Shows full vimdiff between current revision and WD
                            (status and diff: between two current revisions)
-RFVdiff    gC   a   ls     Shows changes done in current rev as full vimdiff
+RFVdiff    gC   a  fls     Shows changes done in current rev as full vimdiff
 Vdiff       D   acDf S  g  Shows vimdiff between cur. rev. and WD for file
                            (status and diff: between two current revisions)
 RVdiff      C   a  f s     Shows changes to file in cur. rev. as a vimdiff
-Fdiff      gd   ac  lS  g  Shows diff between current revision and working dir
+Fdiff      gd   ac flS  g  Shows diff between current revision and working dir
                            (status: between two current revisions)
-RFdiff     gc   a   ls     Shows changes introduced by current revision
+RFdiff     gc   a  fls     Shows changes introduced by current revision
 Diff        d   ac flS  g  Shows diff between rev and WD for current file
                            (status: between two current revisions)
 Rdiff       c   a  fls     Shows changes done in current rev to current file

test/maps-file.in

 :bwipeout!
 c:call WriteFile(bufname('%'))
 :bwipeout!
+gd:call WriteFile(bufname('%'))
+:bwipeout!
+gc:call WriteFile(bufname('%'))
+:bwipeout!
 :W::: D
 D:WW
-:diffoff!
+:wincmd w
 :bwipeout!
 :W::: C
 C:WW
 :W::: ,X
 ,X:WW
+:W::: gD
+JgD:WTabs
+,X:W::: gC
+gC:WTabs
+,X
+:source addEmessages.vim

test/maps-file.ok

 =aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
 *1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
 #2: aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
+aurum://diff:%ETMPDIR%%-test%-maps-filerepo::5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh:
+aurum://diff:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2::crepo.zsh:
 aurum://diff:%ETMPDIR%%-test%-maps-filerepo::5a6a1bf999fad1f4547eeb887af54f31d11833f2::
-aurum://diff:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:dfe39aa48c6ddde158e42217548b531a45ff66e9::
+aurum://diff:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:::
 ::: D
-*1: %TMPDIR%/test/maps-filerepo/crepo.zsh
-#2: aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
+#1: %TMPDIR%/test/maps-filerepo/crepo.zsh
+*2: aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
 ::: C
 #1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
 *2: aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
 ::: ,X
 *1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
+::: gD
+ 1*1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
+*2*1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
+*2#2: %TMPDIR%/test/maps-filerepo/crepo.zsh
+::: gC
+ 1*1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
+ 2*1: 
+ 2#2: aurum://file:%ETMPDIR%%-test%-maps-filerepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
+*3*1: aurum://file:%ETMPDIR%%-test%-maps-filerepo:99ea42d70fbe32af955de907352999b1d94bef5f:createrepo.zsh
+*3#2: 
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.