Commits

ZyX_I committed ae1bf4d

@aurum/drivers/mercurial: Replaced s:_r.py.cmd with s:py

  • Participants
  • Parent commits 05110b7

Comments (0)

Files changed (1)

File plugin/aurum/drivers/mercurial.vim

 let s:hg={}
 let s:iterfuncs={}
 let s:usepythondriver=0
-if has_key(s:_r, 'py')
+if has('python')
+    let s:py='python'
     try
-        " execute s:_r.py.cmd "try:\n".
-                    " \       "    if type(aurum).__name__=='module':\n".
-                    " \       "        reload(aurum)\n".
-                    " \       "except NameError:\n".
-                    " \       "    pass"
-        execute s:_r.py.cmd 'import aurum'
+        " execute s:py "try:\n".
+                    " \"    if type(aurum).__name__=='module':\n".
+                    " \"        reload(aurum)\n".
+                    " \"except NameError:\n".
+                    " \"    pass"
+        execute s:py 'import aurum'
         let s:usepythondriver=1
     catch
         " s:usepythondriver stays equal to 0, errors are ignored
     " do this either, but it will be necessary to review these lines after 
     " python3 support in mercurial will be finished.
     if s:usepythondriver
-        execute s:_r.py.cmd 'reload(aurum)'
+        execute s:py 'reload(aurum)'
     endif
 endif
 let s:nullrev=repeat('0', 40)
     if index(s:_f.getoption('hg_useshell'), a:attr)!=-1
         return s:F.runshellcmd(a:repo, a:attr, a:args, a:kwargs)
     endif
-    execute s:_r.py.cmd 'aurum.call_cmd(vim.eval("a:repo.path"), '.
-                \                      'vim.eval("a:attr"), '.
-                \                      '*vim.eval("a:args"), '.
-                \                      '**vim.eval("a:kwargs"))'
+    execute s:py 'aurum.call_cmd(vim.eval("a:repo.path"), '.
+                \               'vim.eval("a:attr"), '.
+                \               '*vim.eval("a:args"), '.
+                \               '**vim.eval("a:kwargs"))'
 endfunction
 "▲2
 else "▶1
     function s:F.getcs(repo, rev)
         let cs={}
         try
-            execute s:_r.py.cmd 'aurum.get_cs(vim.eval("a:repo.path"), '.
-                        \                    'vim.eval("a:rev"))'
+            execute s:py 'aurum.get_cs(vim.eval("a:repo.path"), '.
+                        \             'vim.eval("a:rev"))'
         endtry
         return cs
     endfunction
         let d={}
         try
             " XXX get_updates also modifies a:repo
-            " execute s:_r.py.cmd 'import cProfile as profile'
-            " execute s:_r.py.cmd 'profile.run("aurum.get_updates(vim.eval(''a:repo.path''), '.a:start.')", "python.profile")'
-            execute s:_r.py.cmd 'aurum.get_updates(vim.eval("a:repo.path"), '.
-                        \                          a:start.')'
+            " execute s:py 'import cProfile as profile'
+            " execute s:py 'profile.run("aurum.get_updates(vim.eval(''a:repo.path''), '.a:start.')", "python.profile")'
+            execute s:py 'aurum.get_updates(vim.eval("a:repo.path"), '.
+                        \                   a:start.')'
         endtry
         return d
     endfunction
         endif
         let d={}
         try
-            execute s:_r.py.cmd 'aurum.get_tags(vim.eval("a:repo.path"))'
+            execute s:py 'aurum.get_tags(vim.eval("a:repo.path"))'
         endtry
         call s:F.updatewithtagsdict(a:repo.changesets, d)
     endfunction
 if s:usepythondriver "▶2
 function s:hg.getrevhex(repo, rev)
     try
-        execute s:_r.py.cmd
-                    \ 'vim.command(''return "''+'.
-                    \    'aurum.g_cs(aurum.g_repo(vim.eval("a:repo.path")), '.
+        execute s:py 'vim.command(''return "''+'.
+                    \      'aurum.g_cs(aurum.g_repo(vim.eval("a:repo.path")), '.
                     \               'vim.eval("a:rev")).hex()+''"'')'
     catch /\v^Frawor:/
         throw v:exception
 if s:usepythondriver "▶2
 function s:hg.setcsprop(repo, cs, prop)
     try
-        execute s:_r.py.cmd 'aurum.get_cs_prop(vim.eval("a:repo.path"), '.
-                    \                         'vim.eval("a:cs.hex"), '.
-                    \                         'vim.eval("a:prop"))'
+        execute s:py 'aurum.get_cs_prop(vim.eval("a:repo.path"), '.
+                    \                  'vim.eval("a:cs.hex"), '.
+                    \                  'vim.eval("a:prop"))'
     endtry
 endfunction
 else "▶2
     let revargs=join(map(copy(a:000), 'v:val is 0? "None": string(v:val)'), ',')
     let d={}
     try
-        execute s:_r.py.cmd 'aurum.get_status(vim.eval("a:repo.path"), '.
-                    \                         revargs.')'
+        execute s:py 'aurum.get_status(vim.eval("a:repo.path"), '.revargs.')'
     endtry
     return d
 endfunction
 function s:hg.dirty(repo, file)
     try
         let r=0
-        execute s:_r.py.cmd 'aurum.dirty(vim.eval("a:repo.path"), '.
-                    \                   'vim.eval("a:file"))'
+        execute s:py 'aurum.dirty(vim.eval("a:repo.path"), '.
+                    \            'vim.eval("a:file"))'
         return r
     endtry
 endfunction
 if s:usepythondriver "▶2
 function s:hg.update(repo, rev, force)
     try
-        execute s:_r.py.cmd 'aurum.update(vim.eval("a:repo.path"), '.
-                    \                    'vim.eval("a:rev"), '.
-                    \                    'int(vim.eval("a:force")))'
+        execute s:py 'aurum.update(vim.eval("a:repo.path"), '.
+                    \             'vim.eval("a:rev"), '.
+                    \             'int(vim.eval("a:force")))'
     endtry
 endfunction
 else "▶2
 let s:usepython=0
 if has_key(s:_r, 'py')
     try
-        execute s:_r.py.cmd 'import json, re'
+        execute s:py 'import json, re'
         let s:usepython=1
     catch
         " s:usepython stays equal to 0, errors are ignored
 if s:usepython "▶2
 function s:hg.ignore(repo, file)
     let d={}
-    execute s:_r.py.cmd 'vim.eval("extend(d, {''pattern'': "+'.
+    execute s:py 'vim.eval("extend(d, {''pattern'': "+'.
                 \              'json.dumps(re.escape(vim.eval("a:file")))+"})")'
     let hgignore=s:_r.os.path.join(a:repo.path, '.hgignore')
     let reline='^'.d.pattern.'$'
 if s:usepythondriver "▶2
 function s:hg.grep(repo, pattern, files, revisions, ignore_case, wdfiles)
     let r=[]
-    execute s:_r.py.cmd 'aurum.grep(vim.eval("a:repo.path"), '.
-                \                  'vim.eval("a:pattern"), '.
-                \                  'vim.eval("a:files"), '.
-                \                  'vim.eval("a:revisions"), '.
-                \                  'bool(int(vim.eval("a:ignore_case"))), '.
-                \                  'bool(int(vim.eval("a:wdfiles"))))'
+    execute s:py 'aurum.grep(vim.eval("a:repo.path"), '.
+                \           'vim.eval("a:pattern"), '.
+                \           'vim.eval("a:files"), '.
+                \           'vim.eval("a:revisions"), '.
+                \           'bool(int(vim.eval("a:ignore_case"))), '.
+                \           'bool(int(vim.eval("a:wdfiles"))))'
     return r
 endfunction
 else "▶2
 function s:hg.readfile(repo, rev, file)
     let r=[]
     try
-        execute s:_r.py.cmd 'aurum.get_file(vim.eval("a:repo.path"), '.
-                    \                      'vim.eval("a:rev"), '.
-                    \                      'vim.eval("a:file"))'
+        execute s:py 'aurum.get_file(vim.eval("a:repo.path"), '.
+                    \               'vim.eval("a:rev"), '.
+                    \               'vim.eval("a:file"))'
     endtry
     return r
 endfunction
 function s:hg.annotate(repo, rev, file)
     let r=[]
     try
-        execute s:_r.py.cmd 'aurum.annotate(vim.eval("a:repo.path"), '.
-                    \                      'vim.eval("a:rev"), '.
-                    \                      'vim.eval("a:file"))'
+        execute s:py 'aurum.annotate(vim.eval("a:repo.path"), '.
+                    \               'vim.eval("a:rev"), '.
+                    \               'vim.eval("a:file"))'
     endtry
     return r
 endfunction
     let r=[]
     let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
     try
-        execute s:_r.py.cmd 'aurum.diff(vim.eval("a:repo.path"), '.
-                    \                  'vim.eval("a:rev1"), '.
-                    \                  'vim.eval("a:rev2"), '.
-                    \                  'vim.eval("a:files"), '.
-                    \                  'vim.eval("diffopts"))'
+        execute s:py 'aurum.diff(vim.eval("a:repo.path"), '.
+                    \           'vim.eval("a:rev1"), '.
+                    \           'vim.eval("a:rev2"), '.
+                    \           'vim.eval("a:files"), '.
+                    \           'vim.eval("diffopts"))'
     endtry
     return r
 endfunction
     endif
     try
         let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
-        execute s:_r.py.cmd 'aurum.diffToBuffer(vim.eval("a:repo.path"), '.
-                    \                          'vim.eval("a:rev1"), '.
-                    \                          'vim.eval("a:rev2"), '.
-                    \                          'vim.eval("a:files"), '.
-                    \                          'vim.eval("diffopts"))'
+        execute s:py 'aurum.diffToBuffer(vim.eval("a:repo.path"), '.
+                    \                   'vim.eval("a:rev1"), '.
+                    \                   'vim.eval("a:rev2"), '.
+                    \                   'vim.eval("a:files"), '.
+                    \                   'vim.eval("diffopts"))'
     finally
         if oldbuf!=a:buf
             execute 'buffer' oldbuf
 function s:hg.getrepoprop(repo, prop)
     let d={}
     try
-        execute s:_r.py.cmd 'aurum.get_repo_prop(vim.eval("a:repo.path"), '.
-                    \                           'vim.eval("a:prop"))'
+        execute s:py 'aurum.get_repo_prop(vim.eval("a:repo.path"), '.
+                    \                    'vim.eval("a:prop"))'
     endtry
     return d[a:prop]
 endfunction
 function s:hg.repo(path)
     let repo={}
     try
-        " execute s:_r.py.cmd 'import cProfile as profile'
-        " execute s:_r.py.cmd 'profile.run("aurum.new_repo(vim.eval(''a:path''))", "python.profile")'
-        execute s:_r.py.cmd 'aurum.new_repo(vim.eval("a:path"))'
+        " execute s:py 'import cProfile as profile'
+        " execute s:py 'profile.run("aurum.new_repo(vim.eval(''a:path''))", "python.profile")'
+        execute s:py 'aurum.new_repo(vim.eval("a:path"))'
     catch /\V\^Frawor:\[^:]\+:norepo:/
         return 0
     endtry
 "▶1 hg.gitrev :: repo, rev → githex
 if s:usepythondriver
 function s:hg.githex(repo, rev)
-    execute s:_r.py.cmd 'aurum.git_hash(vim.eval("a:repo.path"), '.
-                \                      'vim.eval("a:rev"))'
+    execute s:py 'aurum.git_hash(vim.eval("a:repo.path"), '.
+                \               'vim.eval("a:rev"))'
 endfunction
 endif
 "▶1 Register driver