ZyX_I avatar ZyX_I committed 32e3909

@aurum/edit, @aurum/file: Added ability to source aurum://file URLs
@aurum/drivers/git: Some fixes (fixed rf-getcs() returning wrong dictionary and rf-getchangesets() returning wrong dictionaries in list, rf-getcsprop() not returning renames/copies/files/changes/removes properties and not supporting changesets with more then two parents)

Comments (0)

Files changed (9)

 
-This plugin provides a vim <--> VCS (currently only mercurial) integration for 
-your projects. Features:
+This plugin provides a vim <--> VCS (currently mercurial and git) integration 
+for your projects. Features:
 
   - Partially committing changes ([:AuRecord](http://vimpluginloader.sourceforge.net/doc/aurum.txt.html#line349-0)).
 

plugin/aurum/annotate.vim

 elseif s:_pluginloaded
     finish
 endif
+let s:_messages={
+            \'nosource': 'Sourcing aurum://annotate buffers is not supported',
+        \}
 "▶1 formatann :: repo, cs, lnum, numlen → String
 function s:F.formatann(repo, cs, lnum, numlen)
     if !has_key(self, a:cs.hex)
 endfunction
 "▲2
 function s:F.setup(read, repo, rev, file)
+    if a:read==2
+        call s:_f.throw('nosource')
+    endif
     let rev=a:repo.functions.getrevhex(a:repo, a:rev)
     let bvar={'rev': rev, 'file': a:file}
     let ann=copy(a:repo.functions.annotate(a:repo, rev, a:file))

plugin/aurum/commit.vim

             \'emptmsg': 'Message must contain at least one non-blank character',
             \'nocfile': 'Unsure what should be commited',
             \'nocread': 'Cannot read aurum://commit',
+            \'nocso':   'Cannot source aurum://commit',
         \}
 let s:_options={
             \'remembermsg':         {'default': 1, 'filter': 'bool'},
 endfunction
 function s:commit.function(read, repo, user, date, cb, files)
     if a:read
-        call s:_f.throw('nocread')
+        call s:_f.throw(a:read==2 ? 'nocso' : 'nocread')
     endif
     augroup AuCommit
         autocmd! BufLeave <buffer> :call s:F.bufleave()

plugin/aurum/diff.vim

 elseif s:_pluginloaded
     finish
 endif
+let s:_messages={
+            \'nosource': 'Sourcing aurum://diff buffers is not supported',
+        \}
 "▶1 difffunc
 function s:difffunc.function(opts, ...)
     if a:0 && a:opts.repo is# ':'
             \ 'filetype': 'diff',
             \}
 function s:diff.function(read, repo, rev1, rev2, files, opts)
+    if a:read==2
+        call s:_f.throw('nosource')
+    endif
     "▶2 Get revisions
     let rev1=a:rev1
     let rev2=a:rev2

plugin/aurum/drivers/git.vim

         let [cs, i]=s:F.parsecs(log, i)
         let a:repo.changesets[cs.hex]=extend(get(a:repo.changesets, cs.hex, {}),
                     \                        cs)
-        let cslist+=[cs]
+        let cslist+=[a:repo.changesets[cs.hex]]
     endwhile
     "▲2
     return cslist
                 \      0)[0]
     " XXX This construct is used to preserve information like “allfiles” etc
     let a:repo.changesets[cs.hex]=extend(get(a:repo.changesets, cs.hex, {}), cs)
-    return cs
+    return a:repo.changesets[cs.hex]
 endfunction
 "▶1 git.getwork :: repo → cs
 function s:git.getwork(repo)
                 endif
             endfor
             let a:cs.changes=a:cs.files+a:cs.removes
-        elseif lparents==2
+        elseif lparents>=2
             " FIXME Here must be files that had merge conflicts
             let a:cs.renames={}
             let a:cs.copies={}
             let a:cs.files=[]
             let a:cs.removes=[]
         endif
+        return a:cs[a:prop]
     endif
     let a:cs[a:prop]=r
     return r

plugin/aurum/edit.vim

     call s:_f.augroup.add('Aurum',
                 \[['BufReadCmd',   'aurum://*', 0, [s:auefunc,  0]],
                 \ ['FileReadCmd',  'aurum://*', 0, [s:auefunc,  1]],
+                \ ['SourceCmd',    'aurum://*', 0, [s:auefunc,  2]],
                 \ ['BufWriteCmd',  'aurum://*', 0, [s:auefunc, -1]],
                 \ ['FileWriteCmd', 'aurum://*', 0, [s:auefunc, -2]],
                 \])
     call s:_r.setlines(readfile(a:file, 'b'), a:read)
     if !a:read
         let s:_r.bufvars[bufnr('%')]={'file': a:file, 'command': 'copy'}
-    endif
-    if exists('#filetypedetect#BufRead')
-        execute 'doautocmd filetypedetect BufRead' fnameescape(a:file)
+        if exists('#filetypedetect#BufRead')
+            execute 'doautocmd filetypedetect BufRead' fnameescape(a:file)
+        endif
     endif
 endfunction
 "▶1 repotuplesplit :: str, UInt → (repo, String, ...)

plugin/aurum/file.vim

 elseif s:_pluginloaded
     finish
 endif
+let s:_messages={
+            \'wfail': 'Writing to %s failed',
+            \'dfail': 'Failed to delete %s',
+        \}
 "▶1 filefunc
 function s:filefunc.function(rev, file, opts)
     let opts=copy(a:opts)
             \'\V:=(0)\s\+either (\[^)]\+)', 'path',                         ''),
             \'\Vcmd\s\+type ""',            'cmd '.s:_r.comp.cmd,           ''),
             \'\V:"."\s\+type ""', 'either ((type ""), '.s:_r.comp.rev.')',  ''))
+"▶1 docmd :: [String], read::0|1|2 → _ + ?
+function s:F.docmd(lines, read)
+    if a:read==0 || a:read==1
+        return s:_r.setlines(a:lines, a:read)
+    elseif a:read==2
+        let tmpname=tempname()
+        if writefile(a:lines, tmpname, 'b')==-1
+            call s:_f.throw('wfail', tmpname)
+        endif
+        try
+            execute 'source' fnameescape(tmpname)
+        finally
+            if delete(tmpname)
+                call s:_f.throw('dfail', tmpname)
+            endif
+        endtry
+    endif
+endfunction
 "▶1 file resource
 let s:file={'arguments': 2,}
 function s:file.function(read, repo, rev, file)
     let rev=a:repo.functions.getrevhex(a:repo, a:rev)
-    call s:_r.setlines(a:repo.functions.readfile(a:repo, rev, a:file), a:read)
-    if exists('#filetypedetect#BufRead')
+    call s:F.docmd(a:repo.functions.readfile(a:repo, rev, a:file), a:read)
+    if !a:read && exists('#filetypedetect#BufRead')
         execute 'doautocmd filetypedetect BufRead'
                     \ fnameescape(s:_r.os.path.normpath(
                     \             s:_r.os.path.join(a:repo.path, a:file)))

plugin/aurum/log.vim

             \'closewindow': {'default': 1, 'filter': 'bool'},
         \}
 let s:_messages={
-            \'2multl': 'Two multiline statements on one line',
-            \'argmis': 'Missing argument #%u for keyword %s',
+            \  '2multl': 'Two multiline statements on one line',
+            \  'argmis': 'Missing argument #%u for keyword %s',
+            \'nosource': 'Sourcing aurum://log buffers is not supported',
         \}
 "▶1 glog
 "▶2 glog.utfedges
 endfunction
 "▲2
 function s:F.setup(read, repo, opts)
+    if a:read==2
+        call s:_f.throw('nosource')
+    endif
     let opts=a:opts
     let bvar={}
     call a:repo.functions.getchangesets(a:repo)
     endfor
     "▶2 Generate cs.files for several options
     if has_key(opts, 'files') || get(opts, 'showrenames', 0) ||
-                \                     get(opts, 'showcopies',  0) ||
-                \                     get(opts, 'showfiles',   0) ||
-                \                     get(opts, 'stat',        0)
+                \                get(opts, 'showcopies',  0) ||
+                \                get(opts, 'showfiles',   0) ||
+                \                get(opts, 'stat',        0)
         for cs in css
             call a:repo.functions.getcsprop(a:repo, cs, 'files')
         endfor
     endif
     "▶2 Generate cs.changes for showfiles option
-    if get(opts, 'showfiles', 0)
+    if has_key(opts, 'files') || get(opts, 'showfiles', 0)
         for cs in css
             call a:repo.functions.getcsprop(a:repo, cs, 'changes')
         endfor
     if has_key(opts, 'files')
         let opts.csfiles={}
         for cs in css
-            let changes=a:repo.functions.getcsprop(a:repo,cs, 'changes')
-            let changes=copy(changes)
+            let changes=copy(cs.changes)
             let csfiles=[]
             let opts.csfiles[cs.hex]=csfiles
             for pattern in opts.filepats
         if (has_key(opts, 'branch') && cs.branch isnot# opts.branch)||
                     \(has_key(opts, 'merges') &&
                     \   ((opts.merges)?(len(cs.parents)<=1):
-                    \                    (len(cs.parents)>1))) ||
+                    \                  (len(cs.parents)>1))) ||
                     \(has_key(opts, 'search') &&
                     \   cs.description!~#opts.search) ||
                     \(has_key(opts, 'user') && cs.user!~#opts.user) ||
         "▲3
         if skip
             if foundfirst
-                let opts.skipchangesets[cs.hex]=1
+                let opts.skipchangesets[cs.hex]=cs
             endif
         else
             if foundfirst

plugin/aurum/status.vim

 let s:_options={
             \'usestatwin': {'default': 1, 'filter': 'bool'},
         \}
+let s:_messages={
+            \'nosource': 'Sourcing aurum://status buffers is not supported',
+        \}
 let s:defshow=['modified', 'added', 'removed', 'deleted', 'unknown']
 let s:allshow=s:defshow+['ignored', 'clean']
 let s:showchars={}
 endfunction
 "▶1 setup
 function s:F.setup(read, repo, opts)
+    if a:read==2
+        call s:_f.throw('nosource')
+    endif
     let opts=a:opts
     for key in filter(['rev1', 'rev2'], 'has_key(opts, v:val)')
         let opts[key]=a:repo.functions.getrevhex(a:repo, opts[key])
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.