Commits

ZyX_I committed ae80512

@%aurum/drivers/mercurial: Further improvements on old mercurial versions support:
- Fixed absense of branch in mercurial-1.2
- Made reverse diff option be ignored if absent

Comments (0)

Files changed (4)

autoload/aurum/drivers/mercurial.vim

                 \           '*vim.eval("a:args"), '.
                 \           '**vim.eval("a:kwargs"))'
 endfunction
+"▶2 trycmd :: repo, attr → Bool
+function s:F.trycmd(repo, cmd)
+    execute s:py 'vim.command("let r="+str(int(hasattr('.s:pp.',"'.a:cmd.'"))))'
+    return r
+endfunction
 "▲2
 else "▶1
 "▶2 addchangesets :: repo, [cs] → _ + repo
     endif
     let line+=1
     "▶3 Simple keys: rev, hex, branch, time, user
-    let cs.rev    = str2nr(a:csdata[line])    | let line+=1
-    let cs.hex    = a:csdata[line]            | let line+=1
-    let cs.phase  = a:csdata[line]            | let line+=1
-    let cs.branch = s:F.unesc(a:csdata[line]) | let line+=1
-    let cs.time   = str2nr(a:csdata[line])    | let line+=1
-    let cs.user   = s:F.unesc(a:csdata[line]) | let line+=1
+    let null=''
+    let cs.rev    = str2nr(a:csdata[line])       | let line+=1
+    let cs.hex    = a:csdata[line]               | let line+=1
+    let cs.phase  = a:csdata[line]               | let line+=1
+    let cs.branch = s:F.unesc(a:csdata[line])[0] | let line+=1
+    let cs.time   = str2nr(a:csdata[line])       | let line+=1
+    let cs.user   = s:F.unesc(a:csdata[line])    | let line+=1
     if empty(cs.phase)
         let cs.phase='unknown'
     endif
 function s:F.runcmd(repo, attr, args, kwargs, ...)
     return s:F.runshellcmd(a:repo, a:attr, a:args, a:kwargs)
 endfunction
+"▶2 trycmd :: repo, attr → Bool
+function s:F.trycmd(repo, cmd)
+    try
+        call s:F.hg(a:repo, 'help', [a:cmd], {}, 0)
+        return !v:shell_error
+    catch
+        return 0
+    endtry
+endfunction
 "▲2
 endif
+"▶1 trycmdcached :: repo, attr → Bool
+function s:F.trycmdcached(repo, cmd)
+    if !has_key(a:repo.mutable.commands, a:cmd)
+        let a:repo.mutable.commands[a:cmd]=s:F.trycmd(a:repo, a:cmd)
+    endif
+    return a:repo.mutable.commands[a:cmd]
+endfunction
 "▶1 getcs :: repo, rev → cs
 if s:usepythondriver "▶2
     function s:F.getcs(repo, rev)
 endfunction
 "▶1 hg.forget :: repo, file → + FS
 function s:hg.forget(repo, ...)
-    return s:F.runcmd(a:repo, 'forget', a:000, {})
+    " XXX “hg rm --after --force” works like forget, but this behavior is not 
+    "     documented in “hg help remove”. Using it in order to support older 
+    "     mercurial versions
+    return s:F.runcmd(a:repo, 'remove', a:000, {'after': 1, 'force': 1})
 endfunction
 "▶1 hg.remove :: repo, file → + FS
 function s:hg.remove(repo, ...)
             let kwargs[tr(o, '_', '-')]=1
         endif
     endfor
+    if has_key(kwargs, 'reverse') &&
+                \(!has_key(a:repo.mutable, 'noreverse') ||
+                \ empty(filter(s:F.hg(a:repo, 'help', 'diff', [], {}, 0, 0),
+                \              'stridx(v:val, "--reverse")!=-1')))
+        let a:repo.mutable.noreverse=1
+        unlet kwargs.reverse
+    endif
     if !empty(a:files)
         let args+=['--']+a:files
     endif
     return repo
 endfunction
 else "▶2
-function s:F.trycmd(repo, cmd)
-    try
-        call s:F.hg(a:repo, 'help', [a:cmd], {}, 0)
-        return !v:shell_error
-    catch
-        return 0
-    endtry
-endfunction
 function s:hg.repo(path)
-    let repo={'path': a:path, 'changesets': {}, 'mutable': {'cslist': []},
+    let repo={'path': a:path, 'changesets': {}, 'mutable': {'cslist': [],
+                \                                         'commands': {}},
                 \'local': (stridx(a:path, '://')==-1),
                 \'labeltypes': ['tag', 'bookmark'],
                 \'has_octopus_merges': 0, 'requires_sort': 0,
 |aurum-rf-grep|: For non-python driver filenames that look like 
     {smth}:{num>=0}:{num>0} are not supported and will lead to invalid 
     results.
+|aurum-rf-diff| requires at least mercurial-1.4 to support reverse diff 
+    option.
 *aurum-rf-svnrev* exists and produces svn revision number out of repository 
     object and mercurial revision specification.
 *aurum-rf-githex* exists and produces git sha1 out of repository object and 

misc/map-cmdline.csinfo

-changeset = ':\n{rev}\n{node}\n{phase}\n{branch|json}\n{date}\n{author|json}\n{parents}{tags}{bookmarks}{files}{file_dels}{file_copies}\t{desc|json}\n'
+changeset = ':\n{rev}\n{node}\n{phase}\n{branches|json}\n{date}\n{author|json}\n{parents}{tags}{bookmarks}{files}{file_dels}{file_copies}\t{desc|json}\n'
 parent    = 'P{node|json}\n'
 tag       = 'T{tag|json}\n'
 bookmark  = 'B{bookmark|json}\n'

python/aurum/aumercurial.py

     vim_repo={'has_octopus_merges': 0,
                    'requires_sort': 0,
                       'changesets': {},
-                         'mutable': {'cslist': []},
+                         'mutable': {'cslist': [], 'commands': {}},
                            'local': 1 if repo.local() else 0,
                       'labeltypes': ['tag',  'bookmark'],
                          'updkeys': ['tags', 'bookmarks'],