Commits

ZyX_I committed 97b0349

@aurum/drivers/subversion: Same refactoring

  • Participants
  • Parent commits c1ded20
  • Branches svnsupport

Comments (0)

Files changed (2)

plugin/aurum/drivers/common/utils.vim

         endif
     endtry
 endfunction
+"▶1 utils.addfiles :: repo, files + status → + add, forget
+function s:utils.addfiles(repo, files)
+    let status=a:repo.functions.status(a:repo, 0, 0, a:files)
+    for file in status.unknown
+        call a:repo.functions.add(a:repo, file)
+    endfor
+    for file in status.deleted
+        call a:repo.functions.forget(a:repo, file)
+    endfor
+endfunction
+"▶1 utils.usefile :: repo, message, kw, kw, func, args, kwargs, emes
+function s:utils.usefile(repo, message, kwfile, kwmes, Func, args, kwargs, ...)
+    if a:message=~#'\v[\r\n]'
+        let tmpfile=tempname()
+        call writefile(split(a:message, "\n", 1), tmpfile, 'b')
+        let a:kwargs[a:kwfile]=tmpfile
+        let usingfile=1
+    else
+        let a:kwargs[a:kwmes]=a:message
+        let usingfile=0
+    endif
+    try
+        return call(a:Func, [a:repo, 'commit', a:args, a:kwargs]+a:000, {})
+    finally
+        if usingfile && filereadable(tmpfile)
+            call delete(tmpfile)
+        endif
+    endtry
+endfunction
 "▶1 post resource
 call s:_f.postresource('utils', s:utils)
 unlet s:utils

plugin/aurum/drivers/subversion.vim

 endfunction
 "▶1 svn.commit :: repo, message[, files[, user[, date[, _]]]]
 function s:svn.commit(repo, message, ...)
-    let kwargs={}
-    let usingfile=0
-    if a:message=~#'\v[\r\n]'
-        let tmpfile=tempname()
-        call writefile(split(a:message, "\n", 1), tmpfile, 'b')
-        let kwargs.file=tmpfile
-        let usingfile=1
-    else
-        let kwargs.message=a:message
-    endif
     let args=[]
     if a:0
         if !empty(a:1)
             let args+=['--']+a:1
-            let status=a:repo.functions.status(a:repo, 0, 0, a:1)
-            for file in status.unknown
-                call a:repo.functions.add(a:repo, file)
-            endfor
-            for file in status.deleted
-                call a:repo.functions.forget(a:repo, file)
-            endfor
+            call s:_r.utils.addfiles(a:repo, a:1)
         endif
         if a:0>1 && !empty(a:2)
             call s:_f.throw('animp')
             call s:_f.throw('cbnimp')
         endif
     endif
-    try
-        return s:F.svnm(a:repo, 'commit', args, kwargs, 0, 'cif')
-    finally
-        if usingfile && filereadable(tmpfile)
-            call delete(tmpfile)
-        endif
-    endtry
+    return s:_r.utils.usefile(a:repo, a:message, 'file', 'message',
+                \             s:F.svnm, args, {}, 0, 'cif')
 endfunction
 "▶1 svn.update :: repo, rev, force → + FS
 function s:svn.update(repo, rev, force)
                 \   'cpf', a:source, a:destination)
 endfunction
 "▶1 svn.remove :: repo, file → + FS
+" FIXME For some reason :AuJ in drivers-subversion-subdir test is not actually 
+" removing file
 function s:svn.remove(repo, file)
     return s:F.svnm(a:repo, 'delete', ['--', a:file], {}, 0, 'rmf', a:file)
 endfunction