Commits

ZyX_I  committed 6220284

Moved glob->pattern translator into different function, made aurum.diff temporary change working directory

  • Participants
  • Parent commits cecd946

Comments (0)

Files changed (2)

File plugin/aurum.vim

     endfor
     return [repo]+strings+[opts]
 endfunction
+"▶4 comm.globtopattern :: glob → pattern
+function s:F.comm.globtopattern(glob)
+    return '\V\^'.substitute(substitute(substitute(substitute(substitute(
+                \substitute(substitute(a:glob,
+                \'\v\\(.)', '\="\\{".char2nr(submatch(1))."}"', 'g'),
+                \'\V**',    '\\.\\\\{42}',    'g'),
+                \'\V*',     '\\\\{91}^/]\\*', 'g'),
+                \'\V?',     '\\.',            'g'),
+                \'\V[',     '\\[',            'g'),
+                \'\V\\{'.char2nr('\').'}', '\\\\', 'g'),
+                \'\V\\{\(\d\+\)}', '\=nr2char(submatch(1))', 'g').'\$'
+endfunction
 "▲4
 function s:auefunc.function()
     "▶4 Split <amatch> into command and arguments
             endwhile
         endfor
         "▶5 Filter out requested files
+        call map(csfiles, 'join(s:_r.os.path.split(v:val)[1:], "/")')
+        call map(files, 'join(s:_r.os.path.split(v:val)[1:], "/")')
         let filelist=[]
-        for glob in split(files, '\v%(\\@<!\\%(\\\\)*)@<!,')
-            let pattern='\V\^'.substitute(substitute(substitute(substitute(
-                        \substitute(substitute(substitute(glob,
-                        \'\v\\(.)', '\="\\{".char2nr(submatch(1))."}"', 'g'),
-                        \'\V**',    '\\.\\\\{42}',    'g'),
-                        \'\V*',     '\\\\{91}^/]\\*', 'g'),
-                        \'\V?',     '\\.',            'g'),
-                        \'\V[',     '\\[',            'g'),
-                        \'\V\\{'.char2nr('\').'}', '\\\\', 'g'),
-                        \'\V\\{\(\d\+\)}', '\=nr2char(submatch(1))', 'g').'\$'
+        for pattern in map(split(files, '\v%(\\@<!\\%(\\\\)*)@<!,'),
+                    \      's:F.comm.globtopattern(v:val)')
             let filelist+=filter(csfiles, 'v:val=~#pattern && '.
                         \                 'index(filelist, v:val)==-1')
         endfor

File python/aurum.py

 from mercurial import hg, ui, commands
 import vim
 import json
+import os
 
 vim_dumps=json.dumps
 
         kwargs["rev"]=[rev2]
     else:
         kwargs["rev"]=[rev1, rev2]
+    workdir=os.path.abspath('.')
+    try:
+        os.chdir(repo.root)
+    except AttributeError:
+        pass
+    except OSError:
+        pass
     commands.diff(*args, **kwargs)
     vim.eval('extend(r, '+vim_dumps(ui._getCaptured())+')')
+    os.chdir(workdir)