Commits

ZyX_I committed 0244a89

Added support for diff options (git, reverse, ignore-all-sapce, ignore-space-change, ignore-blank-lines, unified)

Comments (0)

Files changed (2)

ftplugin/aurumannotate.vim

             endif
             execute 'edit '.fnameescape('aurum://diff:'.epath.':'.
                         \               rev1.':'.rev2.':'.
-                        \               ((a:0&&a:1)?(''):(bvar.file)))
+                        \               ((a:0&&a:1)?(''):(escape(bvar.file,
+                        \                                        '\:*?['))))
         endif
     elseif a:action is# 'open'
         let file=s:F.getfile(cs)
                 \                  '@/python': '0.0',
                 \            '@/autocommands': '0.0',
                 \               '@/resources': '0.0',
-                \                     '@/fwc': '0.0',}, 0)
+                \                     '@/fwc': '0.0',
+                \                 '@/options': '0.0',}, 0)
     call map(['hg', 'comm', 'graph', 'glog'], 'extend(s:F, {v:val : {}})')
     lockvar 1 s:F
     "▶2 Команды
 endif
 "▶1 Вторая загрузка
 let s:repos={}
+let s:_options={
+            \'diffopts': {'default': {},
+            \             'checker': 'dict {numlines         range 0 inf '.
+            \                              '?key hgdiffopts  bool}'},
+        \}
 "▶1 Вторая загрузка — функции
 "▶2 hg
 execute s:_r.py.cmd 'import aurum'
         return a:cs.renames
     endif
 endfunction
+"▶3 hg.diffopts :: opts → diffopts
+let s:hgdiffopts={
+            \      'git': 'git',
+            \  'reverse': 'reverse',
+            \ 'ignorews': 'ignore_all_space',
+            \'iwsamount': 'ignore_space_change',
+            \  'iblanks': 'ignore_blank_lines',
+            \ 'numlines': 'unified',
+        \}
+let s:diffoptsstr=join(map(keys(s:hgdiffopts), '"!?".v:val'))
+function s:F.hg.diffopts(opts)
+    let r=copy(s:_f.getoption('diffopts'))
+    call map(filter(copy(s:hgdiffopts), 'has_key(a:opts, v:key)'),
+            \'extend(r, {v:val : a:opts[v:key]})')
+    return r
+endfunction
 "▶3 hg.diff :: repo, rev1, rev2, [path], opts → [String]
 function s:F.hg.diff(repo, rev1, rev2, files, opts)
     let r=[]
+    let opts=a:repo.functions.diffopts(a:opts)
     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("a:opts"))'
+                \                  'vim.eval("opts"))'
     return r
 endfunction
 "▶3 hg.difftobuffer :: repo, buf, rev1, rev2, [path], opts → [String]
         execute 'buffer' a:buf
     endif
     try
+        let opts=a:repo.functions.diffopts(a:opts)
         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("a:opts"))'
+                    \                          'vim.eval("opts"))'
     finally
         if oldbuf!=a:buf
             execute 'buffer' oldbuf
 "▶3 comm.globtopattern :: glob → pattern
 function s:F.comm.globtopattern(glob)
     " XXX If more metacharacters will be supported, they must be added to 
-    " escape() call in s:F.filehistory
+    " escape() calls in s:F.filehistory and s:F.runmap in ftplugin/aurumannotate
     return '\V\^'.substitute(substitute(substitute(substitute(substitute(
                 \substitute(substitute(a:glob,
                 \'\v\\(.)', '\="\\{".char2nr(submatch(1))."}"', 'g'),
             \           '  !?stat'.
             \           '  !?showfiles'.
             \           '  !?showrenames'.
+            \           s:diffoptsstr.
             \           '}', 'filter']
 call add(s:glogcomp,
             \substitute(substitute(s:glogfunc['@FWC'][0],