Commits

ZyX_I committed e53d2d3

Moved filepats creation code to ftplugin/aurumstatus, removed aurum://noop:, made it possible to edit removed files (:AuRecord)

Comments (0)

Files changed (2)

ftplugin/aurumstatus.vim

     else
         let show=s:defshow
     endif
+    if has_key(bvar.opts, 'files')
+        let bvar.opts.filepats=map(copy(bvar.opts.files),
+                    \              's:_r.aurum.globtopattern(v:val)')
+    endif
     let isrecord=get(bvar.opts, 'record', 0)
     for [type, files] in filter(items(status), 'index(show, v:val[0])!=-1')
         let char=has_key(s:statchars, type)? s:statchars[type]: toupper(type[0])
     call FraworLoad('@/commands')
     call FraworLoad('@/functions')
     " TODO revision completion
+    " TODO Add :AuEdit, :AuVsplit, :AuSplit, ... (or just cmd option?) (?)
     let s:glogfunc={}
     let s:glogcomp=[]
     call s:_f.command.add('AuGlog', s:glogfunc, {'nargs': '*',
-                \                                'complete': s:glogcomp})
+                \                             'complete': s:glogcomp})
+    " TODO Add repo argument to :AuAnnotate and :AuVimDiff
     let s:annfunc={}
     call s:_f.command.add('AuAnnotate', s:annfunc, {'nargs': '*'})
+    " TODO Add file argument to :AuVimDiff
+    " TODO Make :AuVimDiff accept more then one revision argument
     let s:difffunc={}
     call s:_f.command.add('AuVimDiff', s:difffunc, {'nargs': '*'})
+    " TODO Add :AuDiff
     let s:statfunc={}
     let s:statcomp=[]
     call s:_f.command.add('AuStatus', s:statfunc, {'nargs': '*',
-                \                                  'complete': s:statcomp})
+                \                               'complete': s:statcomp})
     let s:recfunc={}
     let s:reccomp=[]
     call s:_f.command.add('AuRecord', s:recfunc, {'nargs': '*',
 let s:_options={
             \'diffopts':  {'default': {},
             \              'checker': 'dict {numlines         range 0 inf '.
-            \                               '?key hgdiffopts  bool}'},
+            \                               '?in diffoptslst  bool}'},
             \'recheight': {'default': 0,
             \               'filter': '(if type "" earg _  range 0 inf)'},
         \}
             \  'iblanks': 'ignore_blank_lines',
             \ 'numlines': 'unified',
         \}
-let s:diffoptsstr=join(map(keys(s:hgdiffopts),
+" FIXME This should not be connected with mercurial backend
+" XXX Some code relies on the fact that all options from s:diffoptslst are
+"     numeric
+let s:diffoptslst=keys(s:hgdiffopts)
+let s:diffoptsstr=join(map(s:diffoptslst,
             \          'v:val is# "numlines" ? '.
             \               '" ?".v:val." range 0 inf" : '.
             \               '"!?".v:val'))
     let bvar.prevct=b:changedtick
     let bvar.reset=0
     let bvar.backupfiles={}
+    let bvar.newfiles=[]
     let bvar.lines=map(copy(bvar.chars), 'v:val." ".bvar.files[v:key]')
     let bvar.swheight=height
     let bvar.startundo=undotree().seq_cur
             call s:_f.warn('renfail', backupfile, file)
         endif
     endfor
+    for file in a:bvar.newfiles
+        if delete(file)
+            call s:_f.warn('delfail', file)
+        endif
+    endfor
 endfunction
 "▶3 rec.getwnrs
 function s:F.rec.getwnrs()
         let modified=status%2
         execute lwnr.'wincmd w'
         let fullpath=s:_r.os.path.join(bvar.repo.path, file)
-        if !modified
+        if !modified && (type is# 'modified' || type is# 'added' ||
+                    \    type is# 'unknown')
             let backupfile=fullpath.'.orig'
             let i=0
             while s:_r.os.path.exists(backupfile)
                 let i+=1
             endwhile
         endif
-        if type is# 'modified' || type is# 'added' || type is# 'unknown'
+        if type is# 'modified' || type is# 'added'   || type is# 'unknown'
+                    \          || type is# 'removed' || type is# 'deleted'
             if !modified
                 execute swnr.'wincmd w'
                 let status=3
                 diffthis
                 wincmd p
             elseif !modified
-                execute 'edit' fnameescape('aurum://copy:'.fullpath)
-                setlocal noreadonly modifiable bufhidden=wipe
+                if type is# 'added' || type is# 'unknown'
+                    execute 'edit' fnameescape('aurum://copy:'.fullpath)
+                    setlocal noreadonly modifiable bufhidden=wipe
+                elseif type is# 'removed' || type is# 'deleted'
+                    execute 'edit' fnameescape('aurum://file:'.epath.':.:'.file)
+                    setlocal noreadonly modifiable bufhidden=wipe
+                endif
             endif
             if !modified
-                let isexe=executable(fullpath)
-                if rename(fullpath, backupfile)
-                    call s:_f.warn('renfail', fullpath, backupfile)
-                    setlocal readonly nomodifiable
-                    return
+                if exists('backupfile')
+                    let isexe=executable(fullpath)
+                    if rename(fullpath, backupfile)
+                        call s:_f.warn('renfail', fullpath, backupfile)
+                        setlocal readonly nomodifiable
+                        return
+                    endif
+                    let bvar.backupfiles[backupfile]=fullpath
+                else
+                    let isexe=0
                 endif
                 augroup AuRecordLeft
                     execute 'autocmd BufWriteCmd <buffer> write! '.
                                 \fnameescape(fullpath).' | setlocal nomodified'
                 augroup END
                 setlocal buftype=acwrite
-                let bvar.backupfiles[backupfile]=fullpath
                 write
                 if isexe && s:_r.os.name is# 'posix'
                     call s:_r.os.run(['chmod', '+x', fullpath])
         if has_key(opts, 'revrange')
             let opts.revrange=split(opts.revrange, ';')
         endif
-        for key in filter(['merges', 'patch', 'limit', 'stat', 'showfiles'],
+        for key in filter(['merges', 'patch', 'limit', 'stat', 'showfiles']+
+                    \     s:diffoptslst,
                     \     'has_key(opts, v:val)')
             let opts[key]=+opts[key]
         endfor
         let s:bufvars[buf]={'repo': repo, 'rev1': rev1, 'rev2': rev2,
                     \       'files': filelist,}
         setlocal filetype=diff
+        " XXX All options should be from s:diffoptslst list
+        call map(opts, '+v:val')
         call repo.functions.difftobuffer(repo, buf, rev1, rev2, filelist, opts)
     "▶4 status command (repo:opts)
     elseif command is# 'status'
         let [repo, opts]=s:F.comm.repotupleoptssplit(tail, 0)
         if has_key(opts, 'files')
-            let opts.filepats=map(split(opts.files, '\v%(\\@<!\\%(\\\\)*)@<!;'),
-                        \         's:F.comm.globtopattern(v:val)')
+            let opts.files=split(opts.files, '\v%(\\@<!\\%(\\\\)*)@<!;')
         endif
         if has_key(opts, 'show')
             let opts.show=split(opts.show, ';')
         endif
         call setline('.', fcontents)
         let s:bufvars[buf]={'file': tail}
-    "▶4 noop command (do nothing)
-    " This command is needed to generate buffer names that will explain what is 
-    " this buffer for (it may be used if I implement session support)
-    elseif command is# 'noop'
-        if !has_key(s:bufvars, buf)
-            let s:bufvars[buf]={}
-        endif
     endif
 endfunction
 let s:_augroups+=['AuCommitMessage']
     let file=bufname('%')
     let file=s:_r.os.path.relpath(file, repo.path)
     let file=join(s:_r.os.path.split(file)[1:], '/')
-    let rev1=repo.functions.getrevhex(repo, get(a:000, 0, '.'))
+    let rev1=a:0  ?repo.functions.getrevhex(repo, a:1):0
     let rev2=a:0>1?repo.functions.getrevhex(repo, a:2):0
     if rev2 is 0
+        if rev1 is 0
+            let rev1=repo.functions.getrevhex(repo, '.')
+        endif
         call s:F.comm.diffsplit(bufnr('%'), 'aurum://file::'.rev1.':'.file)
     else
         execute 'edit '.fnameescape('aurum://file::'.rev1.':'.file)
             \          ' *?type      (in [modified added removed deleted '.
             \                            'uknown ignored] ~start)'.
             \          '  ?message   (type "")'.
+            \          ' !?closebranch'.
             \          '}'.
             \          '+ type ""']
 call add(s:comcomp,