ZyX_I avatar ZyX_I committed c1ded20 Merge

Merge

Comments (0)

Files changed (3)

plugin/aurum/drivers/common/utils.vim

     endif
     return r
 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/git.vim

 "▶1 git.commit :: repo, message[, files[, user[, date[, _]]]]
 function s:git.commit(repo, message, ...)
     let kwargs={'cleanup': 'verbatim'}
-    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 kwargs.all=1
         else
             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)
             let kwargs.author=a:2
     else
         let kwargs.all=1
     endif
-    try
-        return s:F.gitm(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.gitm, args, kwargs, 0, 'cif')
 endfunction
 "▶1 git.update :: repo, rev, force → + FS
 " XXX This must not transform {rev} into hash: it will break rf-branch()

plugin/aurum/drivers/mercurial.vim

 "▶1 hg.commit :: repo, message[, files[, user[, date[, closebranch[, force]]]]]
 function s:hg.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.logfile=tmpfile
-        let usingfile=1
-    else
-        let kwargs.message=a:message
-    endif
     let args=[]
     if a:0
         if !empty(a:1)
             let kwargs.close_branch=1
         endif
     endif
-    try
-        call s:F.runcmd(a:repo, 'commit', args, kwargs)
-    finally
-        if usingfile && filereadable(tmpfile)
-            call delete(tmpfile)
-        endif
-    endtry
+    return s:_r.utils.usefile(a:repo, a:message, 'logfile', 'message',
+                \             s:F.runcmd, args, kwargs)
 endfunction
 "▶1 hg.update :: repo, rev, force
 if s:usepythondriver "▶2
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.