Commits

ZyX_I committed c878e88

@%aurum/drivers/bazaar: Made it use new utils API

Comments (0)

Files changed (1)

autoload/aurum/drivers/bazaar.vim

 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@%aurum/drivers/common/hypsites': '0.0',
             \                                   '@%aurum/repo': '5.0',
-            \                   '@%aurum/drivers/common/utils': '0.4',
+            \                   '@%aurum/drivers/common/utils': '1.0',
             \                                           '@/os': '0.1',
             \                                      '@/options': '0.0',})
 let s:_messages={
 "▶1 s:hypsites
 " TODO Support for git and subversion hypsites
 let s:hypsites=s:_r.hypsites.bzr
-"▶1 bzrcmd :: repo, cmd, args, kwargs, esc → String
-function s:F.bzrcmd(repo, ...)
-    return 'bzr --no-aliases '.call(s:_r.utils.getcmd, a:000, {})
+"▶1 bzrcmd :: cmd, args, kwargs → String
+function s:F.bzrcmd(...)
+    return ['bzr', '--no-aliases']+call(s:_r.utils.getcmd, a:000, {})
 endfunction
 "▶1 bzr :: repo, cmd, args, kwargs, has0[, msgid[, marg1[, …]]] → [String] + ?
 function s:F.bzr(repo, cmd, args, kwargs, hasnulls, ...)
-    let cmd=s:F.bzrcmd(a:repo, a:cmd, a:args, a:kwargs, a:hasnulls)
-    let r=s:_r.utils.run(cmd, a:hasnulls, a:repo.path)
-    if v:shell_error && a:0
-        call call(s:_f.throw, a:000+[a:repo.path, join(r[:-1-(a:hasnulls)],
-                    \                                  "\n")], {})
+    let cmd=s:F.bzrcmd(a:cmd, a:args, a:kwargs)
+    let [r, exit_code]=s:_r.utils.run(cmd, a:hasnulls, a:repo.path)
+    if a:0
+        if a:1 is 0
+            return [r, exit_code]
+        elseif exit_code
+            call call(s:_f.throw, a:000+[a:repo.path, join(r[:-1-(a:hasnulls)],
+                        \                                  "\n")], {})
+        endif
     endif
     return r
 endfunction
     let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
     let kwargs={}
     if !empty(diffopts)
-        let kwargs['diff-options']=s:_r.utils.kwargstostr(diffopts, 1)
+        let kwargs['diff-options']=join(s:_r.utils.kwargstolst(diffopts))
     endif
     let args=[]
     if empty(a:rev2)
     if !empty(a:files)
         let args+=['--']+a:files
     endif
-    let r=s:F.bzr(a:repo, 'diff', args, kwargs, 1)
+    let [r, exit_code]=s:F.bzr(a:repo, 'diff', args, kwargs, 1, 0)
     " 0 is returned when repository is unchanged
     " 1 is returned when repository has changes
     " 2 and further indicate an error
-    if v:shell_error>1
+    if exit_code>1
         call s:_f.throw('difff', a:rev1, a:rev2, join(a:files, ', '))
     endif
     return r