Commits

ZyX_I  committed 3dadec9

ftplugin/aurumlog: Added AuLog RFVdiff and FVdiff mappings. Ref #6
Moved getblock to @aurum/log
@aurum/cmdutils: Added support for aurum://log to getrrf

  • Participants
  • Parent commits ec1b60c

Comments (0)

Files changed (6)

File doc/aurum.txt

     Open log for given repo. {opts} are the same as used by |:AuLog|.
     Local mappings (mgid=AuLog, current revision=revision under cursor):
                                                            *g:frawormap_AuLog*
-                         *g:frawormap_AuLog_File* *g:frawormap_AuLog_Enter*
-                         *g:frawormap_AuLog_User* *g:frawormap_AuLog_Update*
-                         *g:frawormap_AuLog_Rev*  *g:frawormap_AuLog_Branch*
-                         *g:frawormap_AuLog_Diff* *g:frawormap_AuLog_Fdiff*
-                         *g:frawormap_AuLog_Next* *g:frawormap_AuLog_RFdiff*
-                         *g:frawormap_AuLog_Prev* *g:frawormap_AuLog_Rdiff*
-                         *g:frawormap_AuLog_Open* *g:frawormap_AuLog_Annotate*
-                         *g:frawormap_AuLog_Date*     *aurum-m-AuLog_Date*
-                             *aurum-m-AuLog_File*     *aurum-m-AuLog_Enter*
-                             *aurum-m-AuLog_User*     *aurum-m-AuLog_Update*
-                             *aurum-m-AuLog_Rev*      *aurum-m-AuLog_Branch*
-                             *aurum-m-AuLog_Diff*     *aurum-m-AuLog_Fdiff*
-                             *aurum-m-AuLog_Next*     *aurum-m-AuLog_RFdiff*
-                             *aurum-m-AuLog_Prev*     *aurum-m-AuLog_Rdiff*
-                             *aurum-m-AuLog_Open*     *aurum-m-AuLog_Annotate*
+                        *g:frawormap_AuLog_File*  *g:frawormap_AuLog_Enter*
+                        *g:frawormap_AuLog_User*  *g:frawormap_AuLog_Update*
+                        *g:frawormap_AuLog_Rev*   *g:frawormap_AuLog_Branch*
+                        *g:frawormap_AuLog_Diff*  *g:frawormap_AuLog_FVdiff*
+                        *g:frawormap_AuLog_Fdiff* *g:frawormap_AuLog_RFVdiff*
+                        *g:frawormap_AuLog_Next*  *g:frawormap_AuLog_RFdiff*
+                        *g:frawormap_AuLog_Prev*  *g:frawormap_AuLog_Rdiff*
+                        *g:frawormap_AuLog_Open*  *g:frawormap_AuLog_Annotate*
+                        *g:frawormap_AuLog_Date*      *aurum-m-AuLog_Date*
+                            *aurum-m-AuLog_File*      *aurum-m-AuLog_Enter*
+                            *aurum-m-AuLog_User*      *aurum-m-AuLog_Update*
+                            *aurum-m-AuLog_Rev*       *aurum-m-AuLog_Branch*
+                            *aurum-m-AuLog_Diff*      *aurum-m-AuLog_Fdiff*
+                            *aurum-m-AuLog_Next*      *aurum-m-AuLog_RFdiff*
+                            *aurum-m-AuLog_Prev*      *aurum-m-AuLog_Rdiff*
+                            *aurum-m-AuLog_Open*      *aurum-m-AuLog_Annotate*
     Mapname  LHS  Description ~
     Enter    <CR> Depending on element under cursor:
                   Element          Action ~
                   current one
     Branch   gb   View only revisions that are in the same branch as current
     Rev      gr   View only ancestors of current revision
-    Fdiff    gd   View changes between repository state at current revision 
-                  and working directory state
+    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
+    Fdiff    gd   View changes between current revision and working directory 
+                  state
     RFdiff   gc   View changes introduced by current revision
     Diff      d   View diff between working directory and current revision 
                   versions of one of the files

File ftplugin/aurumlog.vim

             \'nocontents': 'Log is empty',
         \}
 let s:ignkeys=['crrestrict', 'filepats', 'revs', 'cmd', 'repo']
-"▶1 bisect :: [a], function + self → a
-function s:F.bisect(list, function)
-    let llist=len(a:list)
-    let lborder=0
-    let rborder=llist-1
-    let lres=call(a:function, [a:list[lborder]], self)
-    if lres<=0
-        return a:list[lborder]
-    endif
-    let rres=call(a:function, [a:list[rborder]], self)
-    if rres>=0
-        return a:list[rborder]
-    endif
-    let totest='r'
-    let cur=(((rborder+1)/2)-1)
-    while lborder!=rborder
-        let res=call(a:function, [a:list[cur]], self)
-        if res==0
-            return a:list[cur]
-        else
-            let shift=((rborder-lborder)/2)
-            if shift==0
-                let shift=1
-            endif
-            let {(res>0)?('l'):('r')}border=cur
-            let cur=lborder+shift
-        endif
-    endwhile
-    return a:list[lborder]
-endfunction
-"▶1 checkinblock :: block → -1|0|1
-function s:F.checkinblock(block)
-    let curline=line('.')-1
-    return       ((curline<a:block[0][0])?(-1):
-                \((curline>a:block[1][0])?( 1):
-                \                         ( 0)))
-endfunction
-"▶1 getblock :: bvar + cursor, bvar → block
-function s:F.getblock(bvar)
-    if empty(a:bvar.rectangles)
-        call s:_f.throw('nocontents')
-    endif
-    return s:F.bisect(a:bvar.rectangles, s:F.checkinblock)
-endfunction
 "▶1 findCurSpecial :: bvar, hex, blockstart + cursor → special
 "▶2 s:spSort :: special, special → -1|0|1
 let s:sufweights={'-': 3, 'r': 2, 'l': 1, 'R': 0,}
 function s:F.cr(...)
     "▶2 Get changeset, current special, encode options
     let bvar=s:_r.bufvars[bufnr('%')]
-    let [blockstart, blockend, hex]=s:F.getblock(bvar)
+    let [blockstart, blockend, hex]=bvar.getblock(bvar)
     if a:0
         let spname=a:1
     else
     "▲3
     return s:F.cwin(bvar).":silent ".cmd."\n"
 endfunction
+"▶1 fvdiff
+function s:F.fvdiff(...)
+    let bvar=s:_r.bufvars[bufnr('%')]
+    let hex=bvar.getblock(bvar)[2]
+    let cmd=':AuVimDiff full noonlymodified '
+    if !a:0
+        return cmd.'curfile '.hex."\n"
+    else
+        let cs=bvar.repo.changesets[hex]
+        if !empty(cs.parents)
+            return cmd.hex.' '.cs.parents[0]."\n"
+        endif
+    endif
+    return ''
+endfunction
 "▶1 gethexfile
 function s:F.gethexfile()
     let bvar=s:_r.bufvars[bufnr('%')]
-    let [blockstart, blockend, hex]=s:F.getblock(bvar)
+    let [blockstart, blockend, hex]=bvar.getblock(bvar)
     let spname=s:F.findCurSpecial(bvar, hex, blockstart[0])
     let cs=bvar.repo.changesets[hex]
     let file=0
 function s:F.findfirstvisible(n)
     let bvar=s:_r.bufvars[bufnr('%')]
     let repo=bvar.repo
-    let [blockstart, blockend, hex]=s:F.getblock(bvar)
+    let hex=bvar.getblock(bvar)[2]
     let n=abs(a:n)
     let direction=((a:n>0)?('parents'):('children'))
     let tocheck=[]
 "▶1 update
 function s:F.update()
     let bvar=s:_r.bufvars[bufnr('%')]
-    let [blockstart, blockend, hex]=s:F.getblock(bvar)
+    let hex=bvar.getblock(bvar)[2]
     call s:_r.repo.update(bvar.repo, hex, v:count)
     return "\<C-\>\<C-n>:silent edit\n"
 endfunction
             \    'Date': {'lhs': 'gM', 'rhs': ['time']                        },
             \  'Branch': {'lhs': 'gb', 'rhs': ['branch']                      },
             \     'Rev': {'lhs': 'gr', 'rhs': ['rev']                         },
-            \ 'RFVdiff': {'lhs': 'gC', 'rhs': ['fullvimdiff']                 },
+            \  'FVdiff': {'lhs': 'gD', 'rhs': s:F.fvdiff                      },
+            \ 'RFVdiff': {'lhs': 'gC', 'rhs': [1],         'func': s:F.fvdiff },
             \   'Fdiff': {'lhs': 'gd', 'rhs': ['curdiff']                     },
             \  'RFdiff': {'lhs': 'gc', 'rhs': ['revdiff']                     },
             \    'Diff': {'lhs':  'd', 'rhs': [1],         'func': s:F.diff   },

File plugin/aurum/cmdutils.vim

     endif
     return r
 endfunction
+"▶2 rrf.log : bvar → repo, . → (rev), 0 → (file)
+function s:rrf.log(bvar, opts, ann, failmsg)
+    return {'repo': a:bvar.repo,
+           \ 'rev': a:bvar.getblock(a:bvar)[2],
+           \'file': 0,}
+endfunction
 "▲2
 "▶1 getrrf :: opts, failmsg, ann + buf → (hasbuf, repo, rev, file)
 let s:rrffailresult=[0, 0, 0, 0]

File plugin/aurum/log.vim

     endif
     let a:bvar.templatelist=s:F.temp.parse(template)
 endfunction
+"▶1 getblock :: bvar + cursor, bvar → block
+"▶2 bisect :: [a], function + self → a
+function s:F.bisect(list, function)
+    let llist=len(a:list)
+    let lborder=0
+    let rborder=llist-1
+    let lres=call(a:function, [a:list[lborder]], self)
+    if lres<=0
+        return a:list[lborder]
+    endif
+    let rres=call(a:function, [a:list[rborder]], self)
+    if rres>=0
+        return a:list[rborder]
+    endif
+    let totest='r'
+    let cur=(((rborder+1)/2)-1)
+    while lborder!=rborder
+        let res=call(a:function, [a:list[cur]], self)
+        if res==0
+            return a:list[cur]
+        else
+            let shift=((rborder-lborder)/2)
+            if shift==0
+                let shift=1
+            endif
+            let {(res>0)?('l'):('r')}border=cur
+            let cur=lborder+shift
+        endif
+    endwhile
+    return a:list[lborder]
+endfunction
+"▶2 checkinblock :: block → -1|0|1
+function s:F.checkinblock(block)
+    let curline=line('.')-1
+    return       ((curline<a:block[0][0])?(-1):
+                \((curline>a:block[1][0])?( 1):
+                \                         ( 0)))
+endfunction
+"▲2
+function s:F.getblock(bvar)
+    if empty(a:bvar.rectangles)
+        call s:_f.throw('nocontents')
+    endif
+    return s:F.bisect(a:bvar.rectangles, s:F.checkinblock)
+endfunction
 "▶1 setup
 "▶2 getkwreg
 function s:F.getkwreg(kw, nextlit)
 function s:F.setup(read, repo, opts, ...)
     let opts=a:opts
     let bvar=get(a:000, 0, {'opts': opts})
+    let bvar.getblock=s:F.getblock
     "▶2 Add `ignorefiles'
     let ignorefiles=(has_key(opts, 'ignfiles')?
                 \               (opts.ignfiles):

File test/logmaps.in

 /(branch A)
 gr:call WriteFile(bufname('%'))
 :bwipeout!
+:W{{{1 gD
+:R AuLog
+gg/ 25:\x\x\x
+gD:WTabs
+,X
+:bwipeout!
+:W{{{1 gC
+:R AuLog
+/ 2:\x\x\x
+gC:WTabs
+,X
+:bwipeout!
 :W{{{1 gd
 :R AuLog
 / 1:\x\x\x

File test/logmaps.ok

 aurum://log:%ETMPDIR%%-test%-logmapsrepo:crrestrict:branch,branch:A,
 {{{1 gr
 aurum://log:%ETMPDIR%%-test%-logmapsrepo:crrestrict:revision,revision:be92227e3e43f4e7402408afe110098d209d2568,
+{{{1 gD
+ 1*1: aurum://log:%ETMPDIR%%-test%-logmapsrepo:
+ 1#2: 
+ 2*1: 
+ 2#2: %TMPDIR%/test/logmapsrepo/.hgignore
+*3*1: 
+*3#2: %TMPDIR%/test/logmapsrepo/directory/file
+{{{1 gC
+ 1*1: aurum://log:%ETMPDIR%%-test%-logmapsrepo:
+ 1#2: 
+*2*1: aurum://file:%ETMPDIR%%-test%-logmapsrepo:dfe39aa48c6ddde158e42217548b531a45ff66e9:crepo.zsh
+*2#2: aurum://file:%ETMPDIR%%-test%-logmapsrepo:5a6a1bf999fad1f4547eeb887af54f31d11833f2:crepo.zsh
 {{{1 gd
 aurum://diff:%ETMPDIR%%-test%-logmapsrepo::dfe39aa48c6ddde158e42217548b531a45ff66e9
 {{{1 gc