Commits

ZyX_I committed 342ee2d

@%aurum/drivers/bazaar: Made rf-getrepoprop(, 'url') use push_location before parent_location
Added python version of rf-getrepoprop()
Added versions of rf-agetrepoprop() and rf-astatus() that use bzrlib

Comments (0)

Files changed (3)

autoload/aurum/drivers/bazaar.vim

     endif
 endfunction
 "▶1 bzr.getrepoprop :: repo, propname → a
+if s:usepythondriver "▶2
+function s:bzr.getrepoprop(repo, prop)
+    let d={}
+    try
+        execute s:pya.'get_repo_prop(vim.eval("a:repo.path"), '.
+                    \               'vim.eval("a:prop"))'
+    endtry
+    return d[a:prop]
+endfunction
+else "▶2
 function s:bzr.getrepoprop(repo, prop)
     if a:prop is# 'branch'
         return join(s:F.bzr(a:repo, 'nick', [], {}, 0, 'nickf')[:-2], "\n")
     elseif a:prop is# 'url'
-        return s:F.bzr(a:repo, 'config', ['parent_location'], {}, 0,
-                    \  'configf')[:-2]
+        let [url, exit_code]=s:F.bzr(a:repo, 'config', ['push_location'], {}, 0,
+                    \                0)
+        if exit_code
+            return s:F.bzr(a:repo, 'config', ['parent_location'], {}, 0,
+                        \  'configf')[0]
+        endif
+        return url[0]
     elseif a:prop is# 'brancheslist'
         return []
         " FIXME Use “bzr branches”?
     endif
     call s:_f.throw('nocfg', a:prop, a:repo.path)
 endfunction
+endif
 "▶1 bzr.push :: repo, dryrun, force[, URL[, rev]]
 function s:bzr.push(repo, dryrun, force, ...)
     if a:dryrun
 " TODO
 "▶1 astatus, agetcs, agetrepoprop
 if s:_r.repo.userepeatedcmd
-    try
-        python import aurum.rcdriverfuncs
-        let s:addafuncs=1
-    catch
-        let s:addafuncs=0
-    endtry
-    if s:addafuncs
-        function s:bzr.astatus(repo, interval, ...)
-            if a:0<3 || a:1 isnot 0 || a:2 isnot 0 ||
-                        \type(a:3)!=type([]) || len(a:3)!=1
-                call s:_f.throw('aconimp')
-            endif
+    if s:usepythondriver
+        if exists('*pyeval')
+            function s:bzr.astatus(repo, interval, ...)
+                let args = string(a:interval).', '.s:pp.'._get_status, '.
+                            \'vim.eval("a:repo.path"), '
+                let args.= join(map(copy(a:000), s:revargsexpr), ',')
+                return s:_r.utils.pyeval('aurum.repeatedcmd.new('.args.')')
+            endfunction
+        else
+            function s:bzr.astatus(repo, interval, ...)
+                let args = string(a:interval).', '.s:pp.'._get_status, '.
+                            \'vim.eval("a:repo.path"), '
+                let args.= join(map(copy(a:000), s:revargsexpr), ',')
+                execute 'python vim.command("return "+'.
+                            \       'aurum.auutils.nonutf_dumps('.
+                            \               'aurum.repeatedcmd.new('.args.')))'
+            endfunction
+        endif
+        function s:bzr.agetrepoprop(repo, interval, prop)
             return s:_r.utils.pyeval('aurum.repeatedcmd.new('.
-                        \        string(a:interval).', '.
-                        \       'aurum.rcdriverfuncs.bzr_status, '.
-                        \        s:_r.utils.pystring(a:repo.path).', '.
-                        \        s:_r.utils.pystring(a:3[0]).')')
+                        \                 string(a:interval).', '.
+                        \                'aurum.auutils.get_one_prop, '.
+                        \                 s:pp.'._get_repo_prop, '.
+                        \                 s:_r.utils.pystring(a:repo.path).', '.
+                        \                 string(a:prop).')')
         endfunction
-        function s:bzr.agetrepoprop(repo, interval, prop)
-            if a:prop isnot# 'branch'
-                call s:_f.throw('anbnimp')
-            endif
-            return s:_r.utils.pyeval('aurum.repeatedcmd.new('.
-                        \        string(a:interval).', '.
-                        \       'aurum.rcdriverfuncs.bzr_branch, '.
-                        \        s:_r.utils.pystring(a:repo.path).')')
-        endfunction
+    else
+        try
+            python import aurum.rcdriverfuncs
+            let s:addafuncs=1
+        catch
+            let s:addafuncs=0
+        endtry
+        if s:addafuncs
+            function s:bzr.astatus(repo, interval, ...)
+                if a:0<3 || a:1 isnot 0 || a:2 isnot 0 ||
+                            \type(a:3)!=type([]) || len(a:3)!=1
+                    call s:_f.throw('aconimp')
+                endif
+                return s:_r.utils.pyeval('aurum.repeatedcmd.new('.
+                            \        string(a:interval).', '.
+                            \       'aurum.rcdriverfuncs.bzr_status, '.
+                            \        s:_r.utils.pystring(a:repo.path).', '.
+                            \        s:_r.utils.pystring(a:3[0]).')')
+            endfunction
+            function s:bzr.agetrepoprop(repo, interval, prop)
+                if a:prop isnot# 'branch'
+                    call s:_f.throw('anbnimp')
+                endif
+                return s:_r.utils.pyeval('aurum.repeatedcmd.new('.
+                            \        string(a:interval).', '.
+                            \       'aurum.rcdriverfuncs.bzr_branch, '.
+                            \        s:_r.utils.pystring(a:repo.path).')')
+            endfunction
+        endif
     endif
 endif
 "▶1 Register driver

python/aurum/aubazaar.py

     def f(*args, **kwargs):
         with(bzrlib.initialize()):
             return func(*args, **kwargs)
+    f.__name__ = func.__name__
     return f
 
 outermethod      = outermethodgen(g_repo, flush)
 
 repo_props={
         'branch':        lambda repo: repo.branch.nick,
-        'url':           lambda repo: str(repo.branch.get_parent()),
+        'url':           lambda repo: str(   repo.branch.get_push_location()
+                                          or repo.branch.get_parent()),
         'bookmarkslist': lambda repo: [],
         'brancheslist':  lambda repo: [],
         'tagslist':      lambda repo: sorted_str_keys(repo.branch.tags.get_tag_dict()),
 }
 
-get_repo_prop = outermethod(autoexportmethod()(get_repo_prop_gen(repo_props, pathattr='basedir')))
+get_repo_prop = outermethod(
+                autoexportmethod()(
+                bzrmethod(
+                get_repo_prop_gen(repo_props, pathattr='basedir'))))
 
 class StatusReporter(object):
     __slots__ = ('status', 'repo', 'ignored', 'files')

test/drivers-bazaar.ok

Binary file modified.