Commits

ZyX_I  committed ee279fd

Added :AuVimDiff files, :AuVimDiff onlymodified and :AuVimDiff untracked

  • Participants
  • Parent commits 02988f8

Comments (0)

Files changed (6)

File doc/aurum.txt

     Opens a vimdiff windows. Possible options:
     Option       Description ~
     file         File to be opened. Default: current file (see |:AuAnnotate|).
+                 Not used when `full' option is enabled.
+    files        Pattern, determines files to be opened. Default: all files.
+                 Not used when `full' option is disabled.
+                 Note: each pattern must contain at least one non-word 
+                       character (|/\W|).
     [no]curfile  Determines whether current state of the file should be used.
     [no]usewin   Overrides |g:aurum_usewin|. Determines whether new window 
                  should be opened instead of using existing one. First file 
     [no]full     If enabled, opens multiple tabs containing all files changed 
                  between selected revisions (revisions and working directory 
                  state if `curfile' is enabled). Overrides `file' option.
+    [no]onlymodified
+                 Determines whether removed, deleted, added and unknown files 
+                 should be included in the full diff (default: not included: 
+                 option enabled).
+    [no]untracked
+                 Determines whether untracked (deleted and unknown) files 
+                 should be included in the full diff (default: no).
+                 Overrides `onlymodified' option.
     repo         Path. Repository that should be used.
 
     Note: if less then two revisions were specified, one will be working 

File plugin/aurum/cmdutils.vim

             let rev=0
         endif
     "▶2 a:opts.files files → repo?
-    elseif a:ann==-2 && has_key(a:opts, 'files') && !empty(a:opts.files)
+    elseif has_key(a:opts, 'files') && !empty(a:opts.files)
         let files=[]
         if index(a:opts.files, ':')!=-1
-            let [repo, rev, file]=s:F.getrrf(a:opts, 'nocurf', -1)[1:]
+            let newopts=copy(a:opts)
+            unlet newopts.files
+            let [repo, rev, file]=s:F.getrrf(newopts, 'nocurf', -1)[1:]
+            if repo is 0
+                unlet repo
+                let repo=s:_r.repo.get(file)
+            endif
+            if a:ann!=-2 && repo isnot 0
+                let file=repo.functions.reltorepo(repo, file)
+            endif
             let files+=[file]
         else
             let repo=s:_r.repo.get(a:opts.files[0])
                 \   ((exists('files'))?
                 \       (files):
                 \   ((file is 0)?
-                \       (0):
+                \       (0)
+                \   :
                 \       ([file]))):
                 \   (file))]
 endfunction

File plugin/aurum/vimdiff.vim

     "▶2 Open first revision
     let frev=a:revs[0]
     if !has_key(a:fdescr, 1) || a:fdescr[1] is# 'removed'
+                \            || a:fdescr[1] is# 'deleted'
         tabnew
         let existed=0
     elseif frev is 0
     let vertical=(stridx(&diffopt, 'vertical')!=-1)
     for rev in a:revs[1:]
         if !has_key(a:fdescr, i) || a:fdescr[i] is# 'added'
+                    \            || a:fdescr[i] is# 'unknown'
             diffthis
             if vertical
                 vnew
     "▲2
 endfunction
 "▶1 vimdfunc
-let s:fullstatuses=['modified', 'added', 'removed']
 " TODO exclude binary files from full diff
 function s:vimdfunc.function(opts, ...)
     "▶2 repo and revisions
         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(s:fullstatuses, v:val[0])!=-1')
+            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]={}
             endfor
             let i+=1
         endfor
+        "▶2 Filter out only requested files
+        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 file isnot# 0 && has_key(files, file)
+                    let files2[file]=remove(files, file)
+                else
+                    call s:_f.throw('nodfile')
+                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
+        endif
+        "▲2
         let s:lastfullid+=1
         for [f, d] in items(files)
             call s:F.opentab(repo, revs, f, d)
 let s:vimdfunc['@FWC']=['-onlystrings '.
             \           '{  repo  '.s:_r.cmdutils.nogetrepoarg.
             \           '  ?file  type ""'.
+            \           ' *?files (match /\W/)'.
             \           ' !?full'.
+            \           ' !?untracked'.
+            \           ' !?onlymodified'.
             \           ' !?curfile'.
             \           ' !?usewin'.
             \           '}'.

File test/vimdiff-full.in

+:W{{{1 full
 :R AuVimDiff full
 :WTabs
+:W{{{1 ,X
 ,X:WTabs
+:W{{{1 noonlymodified
+:R AuVimDiff full noonlymodified
+:WTabs
+,X
+:W{{{1 untracked
+:R AuVimDiff full untracked
+:WTabs
+,X
+:W{{{1 noonlymodified files *.lst
+:R AuVimDiff full noonlymodified files *.lst
+:WTabs
+,X
+:W{{{1 files :
+:R silent edit nohglinesrev.lst
+:AuVimDiff full files :
+:WTabs
+,X:bwipeout!
+:W{{{1 files repo/*.lst
+:execute 'AuVimDiff full files '.g:curtest.'repo/*.lst'
+:WTabs
+,X
+:source addmessages.vim

File test/vimdiff-full.ok

+{{{1 full
+ 1*1: 
+*2*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+*2#2: vimdiff-fullrepo/nohglinesrev.lst
+{{{1 ,X
+*1*1: 
+{{{1 noonlymodified
  1*1: 
  2*1: 
  2#2: vimdiff-fullrepo/addeddef
  3#2: 
 *4*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
 *4#2: vimdiff-fullrepo/nohglinesrev.lst
-*1*1: 
+{{{1 untracked
+ 1*1: 
+ 2*1: 
+ 2#2: vimdiff-fullrepo/addeddef
+ 3*1: 
+ 3#2: vimdiff-fullrepo/hglinesrev.lst
+ 4*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:hglines2.lst
+ 4#2: 
+ 5*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+ 5#2: vimdiff-fullrepo/nohglinesrev.lst
+*6*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglines.lst
+*6#2: 
+{{{1 noonlymodified files *.lst
+ 1*1: 
+ 2*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+ 2#2: vimdiff-fullrepo/nohglinesrev.lst
+*3*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:hglines2.lst
+*3#2: 
+{{{1 files :
+ 1*1: vimdiff-fullrepo/nohglinesrev.lst
+*2*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+*2#2: vimdiff-fullrepo/nohglinesrev.lst
+{{{1 files repo/*.lst
+ 1*1: 
+*2*1: aurum://file:%ETMPDIR%%-test%-vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+*2#2: %TMPDIR%/test/vimdiff-fullrepo/nohglinesrev.lst

File test/wine/vimdiff-full.ok

+{{{1 full
+ 1*1: 
+*2*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+*2#2: vimdiff-fullrepo\nohglinesrev.lst
+{{{1 ,X
+*1*1: 
+{{{1 noonlymodified
  1*1: 
  2*1: 
  2#2: vimdiff-fullrepo\addeddef
  3#2: 
 *4*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
 *4#2: vimdiff-fullrepo\nohglinesrev.lst
-*1*1: 
+{{{1 untracked
+ 1*1: 
+ 2*1: 
+ 2#2: vimdiff-fullrepo\addeddef
+ 3*1: 
+ 3#2: vimdiff-fullrepo\hglinesrev.lst
+ 4*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:hglines2.lst
+ 4#2: 
+ 5*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+ 5#2: vimdiff-fullrepo\nohglinesrev.lst
+*6*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglines.lst
+*6#2: 
+{{{1 noonlymodified files *.lst
+ 1*1: 
+ 2*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+ 2#2: vimdiff-fullrepo\nohglinesrev.lst
+*3*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:hglines2.lst
+*3#2: 
+{{{1 files :
+ 1*1: vimdiff-fullrepo\nohglinesrev.lst
+*2*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+*2#2: vimdiff-fullrepo\nohglinesrev.lst
+{{{1 files repo/*.lst
+ 1*1: 
+*2*1: aurum:\\file:%ETMPDIR%%+test%+vimdiff-fullrepo:504f74154456dbb0e9441326514e42ce66279e62:nohglinesrev.lst
+*2#2: vimdiff-fullrepo\nohglinesrev.lst