Commits

ZyX_I committed 35a2a0e

ftplugin/aurumannotate: Added some throws. Ref #12

Comments (0)

Files changed (1)

ftplugin/aurumannotate.vim

             \                       '@/os': '0.0',})
 let s:_messages={
             \  'nofile': 'File %s was added in revision %s',
-            \ 'norfile': 'File %s is not present in the working directory',
+            \ 'norfile': 'File %s is not present in the working directory '.
+            \            'or is not readable',
+            \  'noprev': 'Can’t find any revision before %s',
+            \  'nonext': 'Can’t find any revision after %s',
+            \  'nopars': 'Revision %s has no parents',
         \}
 "▶1 getfile :: repo, cs → path
 function s:F.getfile(repo, cs)
         if a:action[:2] is# 'rev'
             let cs1=bvar.repo.functions.getcs(bvar.repo, hex)
             if empty(cs1.parents)
-                return
+                call s:_f.throw('nopars', cs1.hex)
             endif
             let rev1=cs1.parents[0]
         elseif bvar.rev isnot# bvar.repo.functions.getworkhex(bvar.repo)
                 if empty(rev1)
                     let file1=s:_r.os.path.join(bvar.repo.path, bvar.file)
                     let existed=bufexists(file1)
-                    if filereadable(file1)
-                        execute 'silent edit' fnameescape(file1)
-                    else
+                    if !filereadable(file1)
                         call s:_f.throw('norfile', file1)
                     endif
+                    execute 'silent edit' fnameescape(file1)
                 else
-                    try
-                        let existed=s:_r.run('silent edit', 'file', bvar.repo,
-                                    \        rev1, file)
-                    catch /\V\^Frawor:\[^:]\+:nofile:/
-                        call s:_f.throw('nofile', file, rev1)
-                    endtry
+                    let existed=s:_r.run('silent edit', 'file', bvar.repo, rev1,
+                                \                               file)
                 endif
                 if existed
                     setlocal bufhidden=wipe
         let c=((a:action is# 'previous')?(v:count1):(-v:count1))
         let rev=bvar.repo.functions.getnthparent(bvar.repo, bvar.rev, c).hex
         if rev is# hex
-            return
+            call s:_f.throw('no'.a:action[:3], hex)
         endif
         call s:_r.run('silent edit', 'annotate', bvar.repo, rev, bvar.file)
         setlocal scrollbind
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.