Commits

ZyX_I committed 0e07272

ftplugin/aurumstatus: Added vVdiff and vRVdiff mappings, made Vdiff and RVdiff maps accept count. Ref #6
@aurum/vimdiff: Moved full vimdiff functionality to a separate function
@aurum/diff: Made it use function referenced above

Comments (0)

Files changed (7)

   - Viewing working directory status ([:AuStatus](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line360-0)).
 
   - Commiting changes ([:AuCommit](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line98-0)), commit messages are remembered in case of 
-    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line856-0)).
+    rollback ([g:aurum_remembermsg](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line860-0)).
 
   - Obtaining various URL’s out of remote repository URL (like URL of the HTML 
     version of the current file with URL fragment pointing to the current line 
 
   - Frontends for various other VCS commands.
 
-Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line740-0)), 
+Most commands can be reached with a set of mappings (see [aurum-mappings](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line744-0)), 
 all mappings are customizable.
 
 
                  *g:frawormap_AuStatus_Diff*   *g:frawormap_AuStatus_vDiff*
                  *g:frawormap_AuStatus_Rdiff*  *g:frawormap_AuStatus_vRdiff*
                  *g:frawormap_AuStatus_Vdiff*  *g:frawormap_AuStatus_RVdiff*
+                 *g:frawormap_AuStatus_vVdiff* *g:frawormap_AuStatus_vRVdiff*
                  *g:frawormap_AuStatus_Commit* *g:frawormap_AuStatus_Annotate*
                  *g:frawormap_AuStatus_Track*  *g:frawormap_AuStatus_vCommit*
                  *g:frawormap_AuStatus_vTrack* *g:frawormap_AuStatus_Forget*
                      *aurum-m-AuStatus_Diff*       *aurum-m-AuStatus_vDiff*
                      *aurum-m-AuStatus_Rdiff*      *aurum-m-AuStatus_vRdiff*
                      *aurum-m-AuStatus_Vdiff*      *aurum-m-AuStatus_RVdiff*
+                     *aurum-m-AuStatus_vVdiff*     *aurum-m-AuStatus_vRVdiff*
                      *aurum-m-AuStatus_Commit*     *aurum-m-AuStatus_Annotate*
                      *aurum-m-AuStatus_Track*      *aurum-m-AuStatus_vCommit*
                      *aurum-m-AuStatus_vTrack*     *aurum-m-AuStatus_Forget*
     Rdiff     c   Like Fdiff, but show only current file
     vRdiff    c   Like Fdiff, but shows files selected in visual mode
     Vdiff     D   Like Diff, but use |vimdiff| to view changes
+    vVdiff    D   Like FVdiff, but limit files only to selected ones
     RVdiff    C   Like Rdiff, but use |vimdiff| to view changes
+    vRVdiff   C   Like RFVdiff, but limit files only to selected ones
     Annotate  a   Open file under cursor and annotate it
     Commit    i   Commit changes made to file under cursor
     vCommit   i   Commit changes made to selected files
     1.1: Added “requiresbvar” _f.newcommand option
 @aurum/vimdiff:
     0.1: Added full, untracked, onlymodified and files options to |:AuVimDiff|
+    0.2: Added _r.vimdiff.full
 @aurum/log:
     0.1: Added |aurum-style-git| and |aurum-style-gitoneline| log styles, 
          added skipping of $rev if |aurum-repo.hasrevisions| is false, made it 

ftplugin/aurumstatus.vim

 setlocal noswapfile
 setlocal nomodeline
 execute frawor#Setup('0.0', {'@aurum/bufvars': '0.0',
-            \                '@aurum/vimdiff': '0.0',
+            \                '@aurum/vimdiff': '0.2',
+            \               '@aurum/cmdutils': '0.0',
             \                   '@aurum/edit': '1.0',
             \                 '@aurum/commit': '0.0',
             \                    '@/mappings': '0.0',
     let vline1=line("'<")
     let vline2=line("'>")
     let file=bvar.files[curline]
+    let manyfiles=(visual || v:count1>1)
     if has_key(s:noacttypes, a:action) &&
+                \!(a:action[-7:] is# 'vimdiff' && manyfiles) &&
                 \index(s:noacttypes[a:action], bvar.types[curline])!=-1
         return ''
     endif
     if !(a:action is# 'commit' || a:action is# 'track' || a:action is# 'forget'
-                \|| a:action[-11:] is# 'fullvimdiff')
+                \|| a:action[-11:] is# 'fullvimdiff' ||
+                \(a:action[-7:] is# 'vimdiff' && manyfiles))
         if isrecord
             let [lwnr, rwnr, swnr]=bvar.getwnrs()
             execute lwnr.'wincmd w'
     elseif a:action is# 'revfullvimdiff'
         let cs1=bvar.repo.functions.getcs(bvar.repo, rev1)
         if !empty(cs1.parents)
-            let fileglob=escape(s:_r.os.path.join(bvar.repo.path, '**'), ' ')
-            execute 'AuVimDiff full files '.fileglob.' noonlymodified '.
-                        \' '.rev1.' '.cs1.parents[0]
+            call s:_r.vimdiff.full(bvar.repo, [rev1, cs1.parents[0]], 1, [], 0)
         endif
-    elseif a:action is# 'revvimdiff' || a:action is# 'vimdiff'
+    elseif !manyfiles && (a:action is# 'revvimdiff' || a:action is# 'vimdiff')
         let file1=s:_r.fname('file', bvar.repo, rev1, file)
-        if empty(rev2) || a:action is# 'vimdiff'
+        if a:action is# 'revvimdiff'
+            let cs1=bvar.repo.functions.getcs(bvar.repo, rev1)
+            if empty(cs1.parents)
+                return
+            else
+                let file2=s:_r.fname('file', bvar.repo, cs1.parents[0], file)
+            endif
+        elseif empty(rev2)
             let file2=s:_r.os.path.join(bvar.repo.path, file)
         else
             let file2=s:_r.fname('file', bvar.repo, rev2, file)
         endif
         let range=range(curline, rborder)
     endif
-    if has_key(s:noacttypes, a:action)
+    if has_key(s:noacttypes, a:action) && a:action[-7:] isnot# 'vimdiff'
         call filter(range,
                     \'index(s:noacttypes[a:action], bvar.types[v:val])==-1')
     endif
         call s:_r.run('silent edit', 'diff', bvar.repo, rev1,  '',  files, {})
     elseif a:action is# 'revdiff'
         call s:_r.run('silent edit', 'diff', bvar.repo, rev1, rev2, files, {})
+    elseif a:action is# 'revvimdiff' || a:action is# 'vimdiff'
+        let args=[bvar.repo]
+        if a:action is# 'revvimdiff'
+            let cs1=bvar.repo.functions.getcs(bvar.repo, rev1)
+            if empty(cs1.parents)
+                return
+            endif
+            let args+=[[cs1.parents[0], rev1]]
+        else
+            if empty(rev2)
+                let args+=[[0, rev1]]
+            else
+                let args+=[[rev1, rev2]]
+            endif
+        endif
+        let args+=[2, files, 0]
+        return call(s:_r.vimdiff.full, args, {})
     endif
 endfunction
 let s:_augroups+=['AuStatusCommit']
             \   'Fdiff': {'lhs': 'gc',   'rhs': s:F.getrhs(      'fulldiff')},
             \    'Diff': {'lhs':  'd',   'rhs': s:F.getrhs(          'diff')},
             \   'vDiff': {'lhs':  'd',   'rhs': s:F.getrhs(          'diff', 1),
-            \             'mode': 'v'},
+            \             'mode': 'x'},
             \   'Rdiff': {'lhs':  'c',   'rhs': s:F.getrhs(       'revdiff')},
             \  'vRdiff': {'lhs':  'c',   'rhs': s:F.getrhs(       'revdiff', 1),
-            \             'mode': 'v'},
+            \             'mode': 'x'},
             \   'Vdiff': {'lhs':  'D',   'rhs': s:F.getrhs(       'vimdiff')},
+            \  'vVdiff': {'lhs':  'D',   'rhs': s:F.getrhs(       'vimdiff', 1),
+            \             'mode': 'x'},
             \  'RVdiff': {'lhs':  'C',   'rhs': s:F.getrhs(    'revvimdiff')},
+            \ 'vRVdiff': {'lhs':  'C',   'rhs': s:F.getrhs(    'revvimdiff', 1),
+            \             'mode': 'x'},
             \'Annotate': {'lhs':  'a',   'rhs': s:F.getrhs(      'annotate')},
             \  'Commit': {'lhs':  'i',   'rhs': s:F.getrhs(        'commit')},
             \ 'vCommit': {'lhs':  'i',   'rhs': s:F.getrhs(        'commit', 1),

plugin/aurum/diff.vim

 if !exists('s:_pluginloaded')
     execute frawor#Setup('0.0', {'@aurum/cmdutils': '0.0',
                 \                 '@aurum/bufvars': '0.0',
+                \                 '@aurum/vimdiff': '0.2',
                 \                    '@aurum/repo': '2.0',
                 \                    '@aurum/edit': '1.0',
                 \                           '@/os': '0.0',
 "▶1 aurum://diff mappings
 let s:mmgroup=':call <SNR>'.s:_sid.'_Eval("s:_f.mapgroup.map(''AuDiff'', '.
             \                                               "bufnr('%'))\")\n"
+"▶2 rundiffmap
 function s:F.rundiffmap(action)
     let buf=bufnr('%')
     let bvar=s:_r.bufvars[buf]
                     \'close | '.
                     \'wincmd p | '.
                     \"endif\n"
-    elseif a:action is# 'fullvimdiff'
-        let cmd.=':AuVimDiff noonlymodified full '
-        if !empty(bvar.files)
-            let cmd.=join(map(copy(bvar.files), '"files ".'.
-                        \'escape(s:_r.cmdutils.globescape(v:val), " ")'))
-        endif
-        if empty(bvar.rev1)
-            let cmd.='curfile'
-        else
-            let cmd.=bvar.rev1
-        endif
-        let cmd.=' '.bvar.rev2."\n"
     endif
     return cmd
 endfunction
+"▶2 fvdiff
+function s:F.fvdiff()
+    let bvar=s:_r.bufvars[bufnr('%')]
+    let args=[bvar.repo]
+    if empty(bvar.rev1)
+        let args+=[[0, bvar.rev2]]
+    elseif empty(bvar.rev2)
+        let args+=[[0, bvar.rev1]]
+    else
+        let args+=[[bvar.rev1, bvar.rev2]]
+    endif
+    let args+=[1, bvar.files, 0]
+    return call(s:_r.vimdiff.full, args, {})
+endfunction
+"▲2
 call s:_f.mapgroup.add('AuDiff', {
             \  'Next': {'lhs':  'K', 'rhs': ['next'       ]},
             \  'Prev': {'lhs':  'J', 'rhs': ['previous'   ]},
             \  'Exit': {'lhs':  'X', 'rhs': ['exit'       ]},
             \  'Open': {'lhs':  'o', 'rhs': ['open'       ]},
             \ 'Vdiff': {'lhs':  'D', 'rhs': ['vimdiff'    ]},
-            \'FVdiff': {'lhs': 'gD', 'rhs': ['fullvimdiff']},
+            \'FVdiff': {'lhs': 'gD', 'rhs': ':call <SNR>'.s:_sid.'_Eval('.
+            \                                            '"s:F.fvdiff()")<CR>'},
         \}, {'func': s:F.rundiffmap, 'silent': 1, 'mode': 'n', 'dontmap': 1,})
 "▶1 diff resource
 let s:diff= {'arguments': 2,

plugin/aurum/vimdiff.vim

 "▶1 
 scriptencoding utf-8
 if !exists('s:_pluginloaded')
-    execute frawor#Setup('0.1', {'@/os': '0.0',
+    execute frawor#Setup('0.2', {'@/os': '0.0',
                 \     '@aurum/cmdutils': '0.0',
                 \         '@aurum/edit': '1.0',
                 \               '@/fwc': '0.0',
     1 wincmd w
     "▲2
 endfunction
+"▶1 fullvimdiff
+function s:F.fullvimdiff(repo, revs, mt, files, areglobs, ...)
+    let statuses=map(a:revs[1:],
+                \    'a:repo.functions.status(a:repo, v:val, a:revs[0])')
+    let files={}
+    let i=1
+    let stypes=['modified']
+    "▶2 Get accepted statuses list
+    if a:mt
+        let stypes+=['added', 'removed']
+        if a:mt==2
+            let stypes+=['deleted', 'unknown']
+        endif
+    endif
+    "▶2 Get file statuses
+    for status in statuses
+        for [k, fs] in filter(items(status), 'index(stypes, v:val[0])!=-1')
+            for f in fs
+                if !has_key(files, f)
+                    let files[f]={}
+                endif
+                let files[f][i]=k
+            endfor
+        endfor
+        let i+=1
+    endfor
+    "▶2 Filter out requested files
+    if !empty(a:files)
+        let files2={}
+        if a:areglobs
+            let filepats=map(filter(copy(a:files), 'v:val isnot# ":"'),
+                        \    's:_r.globtopat(v:val)')
+            "▶3 Current file
+            if a:0 && !empty(a:1)
+                for f in a:1
+                    if has_key(files, f)
+                        let files2[f]=remove(files, f)
+                    else
+                        call s:_f.throw('cndiff', f)
+                    endif
+                endfor
+            endif
+            "▲3
+            for pattern in filepats
+                call map(filter(keys(files), 'v:val=~#pattern'),
+                            \'extend(files2, {v:val : remove(files, v:val)})')
+            endfor
+        else
+            for f in filter(copy(a:files), 'has_key(files, v:val)')
+                let files2[f]=remove(files, f)
+            endfor
+        endif
+        let files=files2
+    endif
+    "▶2 Open tabs
+    let s:lastfullid+=1
+    for [f, d] in items(files)
+        call s:F.opentab(a:repo, a:revs, f, d)
+    endfor
+    "▲2
+endfunction
 "▶1 vimdfunc
 " TODO exclude binary files from full diff
 function s:vimdfunc.function(opts, ...)
     endif
     "▲2
     if get(a:opts, 'full', 0)
-        let statuses=map(revs[1:], 'repo.functions.status(repo,v:val,revs[0])')
-        let files={}
-        let i=1
-        "▶2 Get accepted statuses list
-        let stypes=['modified']
-        if get(a:opts, 'untracked', 0)
-            let stypes+=['added', 'removed', 'deleted', 'unknown']
-        elseif !get(a:opts, 'onlymodified', 1)
-            let stypes+=['added', 'removed']
-        endif
-        "▶2 Get file statuses
-        for status in statuses
-            for [k, fs] in filter(items(status), 'index(stypes, v:val[0])!=-1')
-                for f in fs
-                    if !has_key(files, f)
-                        let files[f]={}
-                    endif
-                    let files[f][i]=k
-                endfor
-            endfor
-            let i+=1
-        endfor
-        "▶2 Filter out only requested files
+        let args=[repo, revs,
+                    \((get(a:opts, 'untracked', 0))?
+                    \   (2):
+                    \   (!get(a:opts, 'onlymodified', 1)))]
         if has_key(a:opts, 'files')
-            let filepats=map(filter(copy(a:opts.files), 'v:val isnot# ":"'),
-                        \    's:_r.globtopat(repo.functions.reltorepo(repo, '.
-                        \                                            'v:val))')
-            let files2={}
-            "▶3 Current file
-            if len(filepats)!=len(a:opts.files)
-                if !empty(file)
-                    if has_key(files, file[0])
-                        let files2[file[0]]=remove(files, file[0])
-                    else
-                        call s:_f.throw('cndiff', file[0])
-                    endif
+            let files=map(filter(copy(a:opts.files), 'v:val isnot# ":"'),
+                        \        'repo.functions.reltorepo(repo, v:val)')
+            let args+=[files, 1]
+            if len(files)!=len(a:opts.files)
+                if empty(file)
+                    call s:_f.throw('nodfile')
                 else
-                    call s:_f.throw('nodfile')
+                    let args+=[file]
                 endif
             endif
-            "▲3
-            for pattern in filepats
-                call map(filter(keys(files), 'v:val=~#pattern'),
-                            \'extend(files2, {v:val : remove(files, v:val)})')
-            endfor
-            let files=files2
-        elseif !empty(file)
-            let files2={}
-            for f in filter(copy(file), 'has_key(files, v:val)')
-                let files2[f]=remove(files, f)
-            endfor
-            let files=files2
+        elseif empty(file)
+            let args+=[[], 0]
+        else
+            let args+=[file, 0]
         endif
-        "▲2
-        let s:lastfullid+=1
-        for [f, d] in items(files)
-            call s:F.opentab(repo, revs, f, d)
-        endfor
+        return call(s:F.fullvimdiff, args, {})
     else
         if file is 0
             call s:_f.throw('nodfile')
             \'\vfile\s+type\s*\V""', 'file path',        ''),
             \'\V+ type ""',          '+ '.s:_r.comp.rev, ''))
 "▶1 Post resource
-call s:_f.postresource('vimdiff', {'split': s:F.diffsplit,})
+call s:_f.postresource('vimdiff', {'split': s:F.diffsplit,
+            \                       'full': s:F.fullvimdiff,})
 "▶1
 call frawor#Lockvar(s:, '_r,_pluginloaded,lastfullid')
 " vim: ft=vim ts=4 sts=4 et fmr=▶,▲
 :call WriteFile('d: '.&diff)
 :bwipeout!
 :bwipeout!
+:W{{{1 2C
+:R AuStatus rev1 tip rev2 -2
+gg2C:WTabs
+,X:bwipeout!
 :W{{{1 gD
 :R AuStatus
 gD:WTabs
 :call WriteFile('d: '.&diff)
 :bwipeout!
 :bwipeout!
+:W{{{1 2D
+:R AuStatus
+:0/\v^M/-1
+2D:WTabs
+,X:bwipeout!
 :W{{{1 i
 :R AuStatus
 gg0idd02x:silent write
 *1: aurum://diff:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62::nohglinesrev.lst:
 {{{1 C
 *1: aurum://file:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
-#2: %TMPDIR%/test/statmapsrepo/nohglinesrev.lst
+#2: aurum://file:%ETMPDIR%%-test%-statmapsrepo:d8140c0b7b0b670bafe0891bcf0c4582092de884:nohglinesrev.lst
 d: 1
+{{{1 2C
+ 1#1: 
+ 1*2: aurum://status:%ETMPDIR%%-test%-statmapsrepo:rev1:tip,rev2:-2,
+ 2*1: aurum://file:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62:.hgignore
+ 2#2: 
+*3*1: aurum://file:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62:directory%-file
+*3#2: 
 {{{1 gD
  1#1: 
  1*2: aurum://status:%ETMPDIR%%-test%-statmapsrepo:
 *1: aurum://file:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
 #2: %TMPDIR%/test/statmapsrepo/nohglinesrev.lst
 d: 1
+{{{1 2D
+ 1#1: 
+ 1*2: aurum://status:%ETMPDIR%%-test%-statmapsrepo:
+ 2*1: aurum://file:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+ 2#2: %TMPDIR%/test/statmapsrepo/nohglinesrev.lst
+*3*1: aurum://file:%ETMPDIR%%-test%-statmapsrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglines.lst
+*3#2: 
 {{{1 i
 @  Changeset 27
 |  Tags: tip
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.