1. ZyX_I
  2. aurum

Commits

ZyX_I  committed 41a621b

Moved :AuDiff and :AuFile into separate files
Made AuDiff and AuFile mapping groups be defined only for buffers created using :AuDiff and :AuFile commands respectively

  • Participants
  • Parent commits 09adc67
  • Branches default

Comments (0)

Files changed (9)

File doc/aurum.txt

View file
                   Accepts count, in this case first parent is taken {count} 
                   times ({count}=2: first parent of first parent)
 
+    Note These mappings are defined for aurumannotate filetype.
+
 aurum://commit:{repo}:{user}:{date}:{files}                   *aurum://commit*
     Open buffer that prompts for a commit message. Writing this buffer will 
     record the commit and close the buffer. It is the only pseudo-protocol 
     Mapname  LHS  Description ~
     Commit    i   Finish writing commit message and commit changes
 
+    Note These mappings are defined for aurumcommit filetype.
+
 aurum://copy:{file}                                             *aurum://copy*
     Like opening {file} read-only, but safer as you can't write opened file.
 
                   will open {rev1} version.
     Vdiff     D   View diff section under cursor using |vimdiff|.
 
+    Note These mappings are defined only when buffer is created using 
+         |:AuDiff| command or Prev/Next above mappings.
+
 aurum://file:{repo}:{rev}:{file}                                *aurum://file*
     Open file {file} from repository {repo} as it was at revision {rev}.
     Local mappings (mgid=AuFile, without leader by default):
                   buffer with revision set to first parent of {rev} and same 
                   {repo} and {file} arguments
 
+    Note These mappings are defined only when buffer is created using 
+         |:AuFile| command or Prev/Next above mappings.
+
 aurum://log:{repo}:{opts}                                        *aurum://log*
     Open log for given repo. {opts} are the same as used by |:AuLog|.
     Local mappings (mgid=AuLog, current revision=revision under cursor):
                   Accepts count: {count}=3: update to first parent of first 
                   parent of current revision
 
+    Note These mappings are defined for aurumlog filetype.
+
 aurum://status:{repo}:{opts}                                  *aurum://status*
     View status of a repository {repo}. {opts} are the same as used by 
     |:AuStatus|.
     Note all mappings that have v{Mapname} version also accept count. In this 
          case it will work like selecting {count} lines starting from current 
          one and invoking v{Mapname}
+    Note These mappings are defined for aurumstatus filetype.
 
 ------------------------------------------------------------------------------
 2.4. Global mappings                                          *aurum-mappings*

File plugin/aurum.vim

View file
     " TODO :AuMerge ?
     " TODO :AuExplore
     let s:addargs={'Update': {'bang': 1}, 'Move': {'bang': 1}}
-    for s:cmd in ['Diff', 'File', 'Update', 'Move', 'Junk', 'Track',
-                \ 'Hyperlink', 'Grep']
+    for s:cmd in ['Update', 'Move', 'Junk', 'Track', 'Hyperlink', 'Grep']
         let s:part=tolower(s:cmd[:3])
         if len(s:cmd)>4 && stridx('aeiouy', s:part[-1:])!=-1
             let s:part=s:part[:-2]
             \   'nogf': 'No files found',
             \'_mvheader': ['Source', 'Destination'],
         \}
-"▶1 closebuf :: bvar → + buf
-function s:F.closebuf(bvar)
-    let r="\<C-\>\<C-n>"
-    if has_key(a:bvar, 'prevbuf') && bufexists(a:bvar.prevbuf)
-        let r.=':buffer '.a:bvar.prevbuf."\n"
-    endif
-    let r.=':bwipeout '.bufnr('%')."\n"
-    return r
-endfunction
 "▶1 getexsttrckdfiles
 function s:F.getexsttrckdfiles(repo)
     let cs=a:repo.functions.getcs(a:repo, '.')
                         \ fnameescape(s:_r.os.path.normpath(
                         \             s:_r.os.path.join(repo.path, file)))
         endif
-        call s:_f.mapgroup.map('AuFile', buf)
     "▶2 annotate command (repo:rev:file)
     elseif command is# 'annotate'
         let [repo, rev, file]=s:F.repotuplesplit(tail, 2)
                         \                    filelist, opts)
             setlocal filetype=diff
         endif
-        call s:_f.mapgroup.map('AuDiff', buf)
     "▶2 status command (repo:opts)
     elseif command is# 'status'
         let [repo, opts]=s:F.repotupleoptssplit(tail, 0)
     file
 endfunction
 let s:_augroups+=['AuCommitMessage']
-"▶1 aurum://file mappings
-function s:F.runfilemap(action)
-    let buf=bufnr('%')
-    let bvar=s:_r.bufvars[buf]
-    let cmd="\<C-\>\<C-n>"
-    if a:action is# 'exit'
-        return s:F.closebuf(bvar)
-    elseif a:action is# 'update'
-        call s:_r.repo.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 epath=escape(bvar.repo.path, ':\')
-        let cmd.=':edit '.fnameescape('aurum://file:'.epath.':'.rev.
-                    \                             ':'.bvar.file)."\n"
-        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 epath=escape(bvar.repo.path, ':\')
-            let file='aurum://file:'.epath.':'.rev.':'.bvar.file
-            let cmd.=':call call(<SNR>'.s:_sid.'_Eval("s:_r.vimdiff.split"), '.
-                        \       '['.string(file).", 0], {})\n:wincmd p\n"
-        endif
-    elseif a:action is# 'diff' || a:action is# 'revdiff'
-        let opts='repo '.fnameescape(bvar.repo.path)
-        if a:action is# 'diff'
-            let opts.=' rev2 '.bvar.rev
-        else
-            let opts.=' rev1 '.bvar.rev
-        endif
-        let cmd.=':AuDiff '.opts."\n"
-    endif
-    return cmd
-endfunction
-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,})
-"▶1 aurum://diff mappings
-function s:F.rundiffmap(action)
-    let buf=bufnr('%')
-    let bvar=s:_r.bufvars[buf]
-    let cmd="\<C-\>\<C-n>"
-    if a:action is# 'exit'
-        return s:F.closebuf(bvar)
-    elseif a:action is# 'update'
-        let rev=(empty(bvar.rev1)?(bvar.rev2):(bvar.rev1))
-        call s:_r.repo.update(bvar.repo, rev, v:count)
-        return ''
-    elseif a:action is# 'previous' || a:action is# 'next'
-        let c=((a:action is# 'previous')?(v:count1):(-v:count1))
-        if empty(bvar.rev1)
-            let rev1=''
-        else
-            let rev1=bvar.repo.functions.getnthparent(bvar.repo,bvar.rev1,c).hex
-        endif
-        if empty(bvar.rev2)
-            let rev2=''
-        else
-            let rev2=bvar.repo.functions.getnthparent(bvar.repo,bvar.rev2,c).hex
-        endif
-        let epath=escape(bvar.repo.path, ':\')
-        let cmd.=':edit '.
-                    \fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.':'.
-                    \                            bvar.originfiles.':'.
-                    \                  s:_r.cmdutils.encodeopts(bvar.opts))."\n"
-        let cmd.=":bwipeout ".buf."\n"
-    elseif a:action is# 'open'
-        let file=s:_r.cmdutils.getdifffile(bvar)
-        if file is 0
-            return ''
-        endif
-        let epath=escape(bvar.repo.path, ':\')
-        let fullpath=s:_r.os.path.join(bvar.repo.path, file)
-        if empty(bvar.rev1)
-            if filereadable(fullpath)
-                let cmd.=':edit'
-            else
-                let cmd.=':AuFile '.((empty(bvar.rev2))?(bvar.repo.work_hex):
-                            \                           (bvar.rev2))
-            endif
-        else
-            let cmd.=':AuFile '.bvar.rev1
-        endif
-        let cmd.=' '.fnameescape(fullpath)."\n"
-    elseif a:action is# 'vimdiff'
-        let cmd.=':AuVimDiff '
-        if empty(bvar.rev1)
-            let cmd.='curfile'
-        else
-            let cmd.=bvar.rev1
-        endif
-        let cmd.=' '.bvar.rev2."\n"
-        let cmd.=':if bufwinnr('.buf.')!=-1 | '.
-                    \'execute bufwinnr('.buf.')."wincmd w" | '.
-                    \'close | '.
-                    \'wincmd p | '.
-                    \"endif\n"
-    endif
-    return cmd
-endfunction
-call s:_f.mapgroup.add('AuDiff', {
-            \  'Next': {'lhs': 'K', 'rhs': ['next'    ]},
-            \  'Prev': {'lhs': 'J', 'rhs': ['previous']},
-            \'Update': {'lhs': 'U', 'rhs': ['update'  ]},
-            \  'Exit': {'lhs': 'X', 'rhs': ['exit'    ]},
-            \  'Open': {'lhs': 'o', 'rhs': ['open'    ]},
-            \ 'Vdiff': {'lhs': 'D', 'rhs': ['vimdiff' ]},
-        \}, {'func': s:F.rundiffmap, 'silent': 1, 'mode': 'n', 'dontmap': 1,})
-"▶1 difffunc
-function s:difffunc.function(opts, ...)
-    if a:0 && a:opts.repo is# ':'
-        let repo=s:_r.repo.get(a:1)
-    else
-        let repo=s:_r.repo.get(a:opts.repo)
-    endif
-    call s:_r.cmdutils.checkrepo(repo)
-    let files=map(filter(copy(a:000), 'v:val isnot# ":"'),
-                \ 'repo.functions.reltorepo(repo, v:val)')
-    let hascur = (len(a:000)!=len(files))
-    "▶2 Get revisions and file list
-    if has_key(a:opts, 'changes')
-        let rev1=repo.functions.getrevhex(repo, a:opts.changes)
-        let rev2=''
-    else
-        let rev1=get(a:opts, 'rev1', '')
-        let rev2=get(a:opts, 'rev2', '')
-    endif
-    if empty(rev2)
-        if empty(rev1)
-            let rev2=repo.work_hex
-        else
-            let rev2=repo.functions.getnthparent(repo, rev1, 1).hex
-        endif
-    else
-        let rev2=repo.functions.getrevhex(repo, rev2)
-    endif
-    if !empty(rev1)
-        let rev1=repo.functions.getrevhex(repo, rev1)
-    endif
-    let status=filter(copy(repo.functions.status(repo,
-                \                                empty(rev1)?0:rev1, rev2)),
-                \     'v:key isnot# "clean" && v:key isnot# "ignored"')
-    let csfiles=[]
-    call map(values(status), 'extend(csfiles, v:val)')
-    unlet status
-    "▶2 Filter out requested files
-    call map(csfiles, 'join(s:_r.os.path.split(v:val)[1:], "/")')
-    let filelist=[]
-    for pattern in map(copy(files), 's:_r.cmdutils.globtopat(v:val)')
-        let filelist+=filter(copy(csfiles), 'v:val=~#pattern && '.
-                    \                       'index(filelist, v:val)==-1')
-    endfor
-    if hascur
-        let curfile=s:_r.cmdutils.getrrf({'repo': ':'}, 'nocurf', -1)[3]
-        let curfile=repo.functions.reltorepo(repo, curfile)
-        if index(csfiles, curfile)!=-1 && index(filelist, curfile)==-1
-            let filelist+=[curfile]
-        endif
-    endif
-    if a:0 && empty(filelist)
-        return
-    endif
-    "▲2
-    let opts=s:_r.cmdutils.encodeopts(filter(copy(a:opts),
-                \                    'index(s:_r.repo.diffoptslst, v:key)!=-1'))
-    let epath=escape(repo.path, ':\')
-    let efiles=join(map(filelist, 'escape(v:val, "\\;:")'), ';')
-    let prevbuf=bufnr('%')
-    execute get(a:opts, 'cmd', 'silent edit')
-                \ fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.
-                \                         ':'.efiles.':'.opts)
-    if !has_key(a:opts, 'cmd')
-        let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
-    endif
-endfunction
-let s:difffunc['@FWC']=['-onlystrings '.
-            \           '{  repo     '.s:_r.cmdutils.nogetrepoarg.
-            \           '  ?rev1     type ""'.
-            \           '  ?rev2     type ""'.
-            \           '  ?changes  type ""'.
-            \           s:_r.repo.diffoptsstr.
-            \           '  ?cmd      type ""'.
-            \           '}'.
-            \           '+ type ""', 'filter']
-call add(s:diffcomp,
-            \substitute(substitute(substitute(substitute(s:difffunc['@FWC'][0],
-            \'\V|*_r.repo.get',                 '',                   ''),
-            \'\V+ type ""',                     '+ (path)',           ''),
-            \'\Vcmd\s\+type ""',                'cmd '.s:_r.comp.cmd, ''),
-            \'\v(rev[12]|changes)\s+\Vtype ""', '\1 '. s:_r.comp.rev, 'g'))
-"▶1 filefunc
-function s:filefunc.function(rev, file, opts)
-    let opts=extend(copy(a:opts), {'rev': a:rev})
-    if a:file isnot 0
-        if a:file isnot# ':'
-            let opts.file=a:file
-        endif
-    endif
-    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(opts, 'noffile', 0)
-    if repo is 0
-        return
-    endif
-    let rev=repo.functions.getrevhex(repo, a:rev)
-    if get(a:opts, 'replace', 0)
-        call s:_r.cmdutils.setlines(repo.functions.readfile(repo, rev, file), 0)
-        return
-    endif
-    let epath=escape(repo.path, ':\')
-    if hasbuf
-        let filetype=&filetype
-    endif
-    let prevbuf=bufnr('%')
-    execute get(a:opts, 'cmd', 'silent edit')
-                \ fnameescape('aurum://file:'.epath.':'.rev.':'.file)
-    if exists('filetype') && &filetype isnot# filetype
-        let &filetype=filetype
-    endif
-    if !has_key(a:opts, 'cmd')
-        let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
-    endif
-endfunction
-let s:filefunc['@FWC']=['-onlystrings '.
-            \           '[:"."    type "" '.
-            \           '[:=(0)   either (match /\L/, path fr)]]'.
-            \           '{  repo '.s:_r.cmdutils.nogetrepoarg.
-            \           ' !?replace'.
-            \           '  ?cmd    type ""}', 'filter']
-call add(s:filecomp,
-            \substitute(substitute(substitute(s:filefunc['@FWC'][0],
-            \'\V:=(0)\s\+either (\[^)]\+)', 'path',                         ''),
-            \'\Vcmd\s\+type ""',            'cmd '.s:_r.comp.cmd,           ''),
-            \'\V:"."\s\+type ""', 'either ((type ""), '.s:_r.comp.rev.')',  ''))
 "▶1 updfunc
 function s:updfunc.function(bang, rev, repopath)
     let repo=s:_r.repo.get(a:repopath)

File plugin/aurum/cmdutils.vim

View file
         call d.set('.', a:lines)
     endif
 endfunction
+"▶1 closebuf :: bvar → + buf
+function s:F.closebuf(bvar)
+    let r="\<C-\>\<C-n>"
+    if has_key(a:bvar, 'prevbuf') && bufexists(a:bvar.prevbuf)
+        return ':buffer '.a:bvar.prevbuf."\n"
+    endif
+    return ':bwipeout '.bufnr('%')."\n"
+endfunction
 "▶1 Post cmdutils resource
 call s:_f.postresource('cmdutils', {'globtopat': s:F.globtopattern,
             \                      'globescape': s:F.globescape,
             \                     'getdifffile': s:F.getdifffile,
             \                       'checkrepo': s:F.checkrepo,
             \                        'setlines': s:F.setlines,
+            \                        'closebuf': s:F.closebuf,
             \                    'nogetrepoarg': s:nogetrepoarg,
             \})
 "▶1 Some completion-related globals

File plugin/aurum/diff.vim

View file
+"▶1 
+scriptencoding utf-8
+if !exists('s:_pluginloaded')
+    execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
+                \                 '@aurum/bufvars': '0.0',
+                \                    '@aurum/repo': '0.0',
+                \                           '@/os': '0.0',
+                \                          '@/fwc': '0.0',
+                \                     '@/mappings': '0.0',
+                \                     '@/commands': '0.0',
+                \                    '@/functions': '0.0',}, 0)
+    call FraworLoad('@/commands')
+    call FraworLoad('@/functions')
+    let s:diffcomp=[]
+    let s:difffunc={}
+    call s:_f.command.add('AuDiff', s:difffunc, {'nargs': '*',
+                \                             'complete': s:diffcomp})
+    finish
+elseif s:_pluginloaded
+    finish
+endif
+"▶1 difffunc
+function s:difffunc.function(opts, ...)
+    if a:0 && a:opts.repo is# ':'
+        let repo=s:_r.repo.get(a:1)
+    else
+        let repo=s:_r.repo.get(a:opts.repo)
+    endif
+    call s:_r.cmdutils.checkrepo(repo)
+    let files=map(filter(copy(a:000), 'v:val isnot# ":"'),
+                \ 'repo.functions.reltorepo(repo, v:val)')
+    let hascur = (len(a:000)!=len(files))
+    "▶2 Get revisions and file list
+    if has_key(a:opts, 'changes')
+        let rev1=repo.functions.getrevhex(repo, a:opts.changes)
+        let rev2=''
+    else
+        let rev1=get(a:opts, 'rev1', '')
+        let rev2=get(a:opts, 'rev2', '')
+    endif
+    if empty(rev2)
+        if empty(rev1)
+            let rev2=repo.work_hex
+        else
+            let rev2=repo.functions.getnthparent(repo, rev1, 1).hex
+        endif
+    else
+        let rev2=repo.functions.getrevhex(repo, rev2)
+    endif
+    if !empty(rev1)
+        let rev1=repo.functions.getrevhex(repo, rev1)
+    endif
+    let status=filter(copy(repo.functions.status(repo,
+                \                                empty(rev1)?0:rev1, rev2)),
+                \     'v:key isnot# "clean" && v:key isnot# "ignored"')
+    let csfiles=[]
+    call map(values(status), 'extend(csfiles, v:val)')
+    unlet status
+    "▶2 Filter out requested files
+    call map(csfiles, 'join(s:_r.os.path.split(v:val)[1:], "/")')
+    let filelist=[]
+    for pattern in map(copy(files), 's:_r.cmdutils.globtopat(v:val)')
+        let filelist+=filter(copy(csfiles), 'v:val=~#pattern && '.
+                    \                       'index(filelist, v:val)==-1')
+    endfor
+    if hascur
+        let curfile=s:_r.cmdutils.getrrf({'repo': ':'}, 'nocurf', -1)[3]
+        let curfile=repo.functions.reltorepo(repo, curfile)
+        if index(csfiles, curfile)!=-1 && index(filelist, curfile)==-1
+            let filelist+=[curfile]
+        endif
+    endif
+    if a:0 && empty(filelist)
+        return
+    endif
+    "▲2
+    let opts=s:_r.cmdutils.encodeopts(filter(copy(a:opts),
+                \                    'index(s:_r.repo.diffoptslst, v:key)!=-1'))
+    let epath=escape(repo.path, ':\')
+    let efiles=join(map(filelist, 'escape(v:val, "\\;:")'), ';')
+    let prevbuf=bufnr('%')
+    execute get(a:opts, 'cmd', 'silent edit')
+                \ fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.
+                \                         ':'.efiles.':'.opts)
+    if !has_key(a:opts, 'cmd')
+        let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
+    endif
+    call s:_f.mapgroup.map('AuDiff', bufnr('%'))
+endfunction
+let s:difffunc['@FWC']=['-onlystrings '.
+            \           '{  repo     '.s:_r.cmdutils.nogetrepoarg.
+            \           '  ?rev1     type ""'.
+            \           '  ?rev2     type ""'.
+            \           '  ?changes  type ""'.
+            \           s:_r.repo.diffoptsstr.
+            \           '  ?cmd      type ""'.
+            \           '}'.
+            \           '+ type ""', 'filter']
+call add(s:diffcomp,
+            \substitute(substitute(substitute(substitute(s:difffunc['@FWC'][0],
+            \'\V|*_r.repo.get',                 '',                   ''),
+            \'\V+ type ""',                     '+ (path)',           ''),
+            \'\Vcmd\s\+type ""',                'cmd '.s:_r.comp.cmd, ''),
+            \'\v(rev[12]|changes)\s+\Vtype ""', '\1 '. s:_r.comp.rev, 'g'))
+"▶1 aurum://diff mappings
+let s:mmgroup=':call <SNR>'.s:_sid.'_Eval("s:_f.mapgroup.map(''AuDiff'', '.
+            \                                               "bufnr('%'))\")\n"
+function s:F.rundiffmap(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)
+    elseif a:action is# 'update'
+        let rev=(empty(bvar.rev1)?(bvar.rev2):(bvar.rev1))
+        call s:_r.repo.update(bvar.repo, rev, v:count)
+        return ''
+    elseif a:action is# 'previous' || a:action is# 'next'
+        let c=((a:action is# 'previous')?(v:count1):(-v:count1))
+        if empty(bvar.rev1)
+            let rev1=''
+        else
+            let rev1=bvar.repo.functions.getnthparent(bvar.repo,bvar.rev1,c).hex
+        endif
+        if empty(bvar.rev2)
+            let rev2=''
+        else
+            let rev2=bvar.repo.functions.getnthparent(bvar.repo,bvar.rev2,c).hex
+        endif
+        let epath=escape(bvar.repo.path, ':\')
+        let cmd.=':edit '.
+                    \fnameescape('aurum://diff:'.epath.':'.rev1.':'.rev2.':'.
+                    \                            bvar.originfiles.':'.
+                    \                  s:_r.cmdutils.encodeopts(bvar.opts))."\n"
+        let cmd.=s:mmgroup
+        let cmd.=":bwipeout ".buf."\n"
+    elseif a:action is# 'open'
+        let file=s:_r.cmdutils.getdifffile(bvar)
+        if file is 0
+            return ''
+        endif
+        let epath=escape(bvar.repo.path, ':\')
+        let fullpath=s:_r.os.path.join(bvar.repo.path, file)
+        if empty(bvar.rev1)
+            if filereadable(fullpath)
+                let cmd.=':edit'
+            else
+                let cmd.=':AuFile '.((empty(bvar.rev2))?(bvar.repo.work_hex):
+                            \                           (bvar.rev2))
+            endif
+        else
+            let cmd.=':AuFile '.bvar.rev1
+        endif
+        let cmd.=' '.fnameescape(fullpath)."\n"
+    elseif a:action is# 'vimdiff'
+        let cmd.=':AuVimDiff '
+        if empty(bvar.rev1)
+            let cmd.='curfile'
+        else
+            let cmd.=bvar.rev1
+        endif
+        let cmd.=' '.bvar.rev2."\n"
+        let cmd.=':if bufwinnr('.buf.')!=-1 | '.
+                    \'execute bufwinnr('.buf.')."wincmd w" | '.
+                    \'close | '.
+                    \'wincmd p | '.
+                    \"endif\n"
+    endif
+    return cmd
+endfunction
+call s:_f.mapgroup.add('AuDiff', {
+            \  'Next': {'lhs': 'K', 'rhs': ['next'    ]},
+            \  'Prev': {'lhs': 'J', 'rhs': ['previous']},
+            \'Update': {'lhs': 'U', 'rhs': ['update'  ]},
+            \  'Exit': {'lhs': 'X', 'rhs': ['exit'    ]},
+            \  'Open': {'lhs': 'o', 'rhs': ['open'    ]},
+            \ 'Vdiff': {'lhs': 'D', 'rhs': ['vimdiff' ]},
+        \}, {'func': s:F.rundiffmap, 'silent': 1, 'mode': 'n', 'dontmap': 1,})
+"▶1
+call frawor#Lockvar(s:, '_r,_pluginloaded')
+" vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File plugin/aurum/file.vim

View file
+"▶1 
+scriptencoding utf-8
+if !exists('s:_pluginloaded')
+    execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
+                \                 '@aurum/bufvars': '0.0',
+                \                 '@aurum/vimdiff': '0.0',
+                \                    '@aurum/repo': '0.0',
+                \                           '@/os': '0.0',
+                \                          '@/fwc': '0.0',
+                \                     '@/mappings': '0.0',
+                \                     '@/commands': '0.0',
+                \                    '@/functions': '0.0',}, 0)
+    call FraworLoad('@/commands')
+    call FraworLoad('@/functions')
+    let s:filecomp=[]
+    let s:filefunc={}
+    call s:_f.command.add('AuFile', s:filefunc, {'nargs': '*',
+                \                             'complete': s:filecomp})
+    finish
+elseif s:_pluginloaded
+    finish
+endif
+"▶1 filefunc
+function s:filefunc.function(rev, file, opts)
+    let opts=extend(copy(a:opts), {'rev': a:rev})
+    if a:file isnot 0
+        if a:file isnot# ':'
+            let opts.file=a:file
+        endif
+    endif
+    let [hasbuf, repo, rev, file]=s:_r.cmdutils.getrrf(opts, 'noffile', 0)
+    if repo is 0
+        return
+    endif
+    let rev=repo.functions.getrevhex(repo, a:rev)
+    if get(a:opts, 'replace', 0)
+        call s:_r.cmdutils.setlines(repo.functions.readfile(repo, rev, file), 0)
+        return
+    endif
+    let epath=escape(repo.path, ':\')
+    if hasbuf
+        let filetype=&filetype
+    endif
+    let prevbuf=bufnr('%')
+    execute get(a:opts, 'cmd', 'silent edit')
+                \ fnameescape('aurum://file:'.epath.':'.rev.':'.file)
+    if exists('filetype') && &filetype isnot# filetype
+        let &filetype=filetype
+    endif
+    if !has_key(a:opts, 'cmd')
+        let s:_r.bufvars[bufnr('%')].prevbuf=prevbuf
+    endif
+    call s:_f.mapgroup.map('AuFile', bufnr('%'))
+endfunction
+let s:filefunc['@FWC']=['-onlystrings '.
+            \           '[:"."    type "" '.
+            \           '[:=(0)   either (match /\L/, path fr)]]'.
+            \           '{  repo '.s:_r.cmdutils.nogetrepoarg.
+            \           ' !?replace'.
+            \           '  ?cmd    type ""}', 'filter']
+call add(s:filecomp,
+            \substitute(substitute(substitute(s:filefunc['@FWC'][0],
+            \'\V:=(0)\s\+either (\[^)]\+)', 'path',                         ''),
+            \'\Vcmd\s\+type ""',            'cmd '.s:_r.comp.cmd,           ''),
+            \'\V:"."\s\+type ""', 'either ((type ""), '.s:_r.comp.rev.')',  ''))
+"▶1 aurum://file mappings
+let s:mmgroup=':call <SNR>'.s:_sid.'_Eval("s:_f.mapgroup.map(''AuFile'', '.
+            \                                               "bufnr('%'))\")\n"
+function s:F.runfilemap(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)
+    elseif a:action is# 'update'
+        call s:_r.repo.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 epath=escape(bvar.repo.path, ':\')
+        let cmd.=':edit '.fnameescape('aurum://file:'.epath.':'.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 epath=escape(bvar.repo.path, ':\')
+            let file='aurum://file:'.epath.':'.rev.':'.bvar.file
+            let cmd.=':call call(<SNR>'.s:_sid.'_Eval("s:_r.vimdiff.split"), '.
+                        \       '['.string(file).", 0], {})\n:wincmd p\n"
+        endif
+    elseif a:action is# 'diff' || a:action is# 'revdiff'
+        let opts='repo '.fnameescape(bvar.repo.path)
+        if a:action is# 'diff'
+            let opts.=' rev2 '.bvar.rev
+        else
+            let opts.=' rev1 '.bvar.rev
+        endif
+        let cmd.=':AuDiff '.opts."\n"
+    endif
+    return cmd
+endfunction
+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,})
+"▶1
+call frawor#Lockvar(s:, '_r,_pluginloaded')
+" vim: ft=vim ts=4 sts=4 et fmr=▶,▲

File test/audiffmaps.in

View file
-:R silent edit aurum://diff::2
+:R AuDiff rev1 2
 :R call WriteFile(filereadable('crepo.zsh'))
 :call WriteFile(bufname('%'))
 J:call WriteFile(bufname('%'))

File test/audiffmaps.ok

View file
 0
-aurum://diff::2
-aurum://diff:%TMPDIR%/test/audiffmapsrepo:fe851681c15eb282a18ab7660f85a677ee1e577c:::
-aurum://diff:%TMPDIR%/test/audiffmapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:::
+aurum://diff:%TMPDIR%/test/audiffmapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:fe851681c15eb282a18ab7660f85a677ee1e577c::
+aurum://diff:%TMPDIR%/test/audiffmapsrepo:fe851681c15eb282a18ab7660f85a677ee1e577c:00b61a9315e2ecb239feba3bc44b2ef3af4c7dd1::
+aurum://diff:%TMPDIR%/test/audiffmapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:fe851681c15eb282a18ab7660f85a677ee1e577c::
 1
 aurum://diff:%TMPDIR%/test/audiffmapsrepo:aa37b7dd6c397b16a77b1f405d49828aa6434bb2:ccf3e1d041800ad99d46dcdec6e12c8a770456f9:datelines.lst;hglines.lst:
-aurum://diff:%TMPDIR%/test/audiffmapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:::
+aurum://diff:%TMPDIR%/test/audiffmapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:fe851681c15eb282a18ab7660f85a677ee1e577c::
 aurum://file:%TMPDIR%/test/audiffmapsrepo:aa37b7dd6c397b16a77b1f405d49828aa6434bb2:hglines.lst
 %TMPDIR%/test/audiffmapsrepo/crepo.zsh
 2

File test/aufilemaps.in

View file
-:R silent edit aurum://file::2:crepo.zsh
+:R AuFile 2 crepo.zsh
 :R call WriteFile(filereadable('crepo.zsh'))
 :call WriteFile(bufname('%'))
 J:call WriteFile(bufname('%'))

File test/aufilemaps.ok

View file
 0
-aurum://file::2:crepo.zsh
+aurum://file:%TMPDIR%/test/aufilemapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:crepo.zsh
 aurum://file:%TMPDIR%/test/aufilemapsrepo:fe851681c15eb282a18ab7660f85a677ee1e577c:crepo.zsh
 aurum://file:%TMPDIR%/test/aufilemapsrepo:41c3d8d71ffecac8d1d2e4ac56b8a36c038290e1:crepo.zsh
 1