Commits

ZyX_I committed 015a5c3

@%aurum/drivers/mercurial: Improved rf-diff() and rf-difftobuffer() arguments handling

  • Participants
  • Parent commits 89e7fe5

Comments (0)

Files changed (2)

File autoload/aurum/drivers/mercurial.vim

             \    'dates': 'nodates',
         \}
 if s:usepythondriver "▶2
+function s:F.getdiffargs(repo, rev1, rev2, files, opts)
+    return       'vim.eval("a:repo.path"), '.
+                \(empty(a:rev1)  ? 'None' : 'vim.eval("a:rev1")' ).', '.
+                \(empty(a:rev2)  ? 'None' : 'vim.eval("a:rev2")' ).', '.
+                \(empty(a:files) ? '[]'   : 'vim.eval("a:files")').', '.
+                \'vim.eval("diffopts")'
+endfunction
 function s:hg.diff(repo, rev1, rev2, files, opts)
     let r=[]
     let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
     try
-        execute s:pya.'diff(vim.eval("a:repo.path"), '.
-                    \      'vim.eval("a:rev1"), '.
-                    \      'vim.eval("a:rev2"), '.
-                    \      'vim.eval("a:files"), '.
-                    \      'vim.eval("diffopts"))'
+        execute s:pya.'diff('.s:F.getdiffargs(a:repo, a:rev1, a:rev2, a:files,
+                    \                         a:opts).')'
     endtry
     return r
 endfunction
     endif
     try
         let diffopts=s:_r.utils.diffopts(a:opts, a:repo.diffopts, s:difftrans)
-        execute s:pya.'diffToBuffer(vim.eval("a:repo.path"), '.
-                    \              'vim.eval("a:rev1"), '.
-                    \              'vim.eval("a:rev2"), '.
-                    \              'vim.eval("a:files"), '.
-                    \              'vim.eval("diffopts"))'
+        execute s:pya.'diffToBuffer('.s:F.getdiffargs(a:repo, a:rev1, a:rev2,
+                    \                                 a:files, a:opts).')'
     finally
         if oldbuf!=a:buf
             execute 'buffer' oldbuf

File python/aurum/aumercurial.py

     args=[ui, repo]+files
     kwargs=opts
     if rev2:
-        kwargs["rev"]=[rev2]
+        kwargs['rev']=[rev2]
         if rev1:
-            kwargs["rev"].append(rev1)
+            kwargs['rev'].append(rev1)
     else:
         if rev1:
-            kwargs["change"]=rev1
+            kwargs['change']=rev1
     run_in_dir(repo.root, commands.diff, *args, **kwargs)
 
 @outermethod