Commits

ZyX_I committed e0f8818

@%aurum/drivers/mercurial, tests: Improved support for older versions of mercurial

Comments (0)

Files changed (4)

autoload/aurum/drivers/mercurial.vim

     if empty(cs.phase)
         let cs.phase='unknown'
     endif
+    if empty(cs.branch)
+        let cs.branch='default'
+    endif
     "▶3 List keys: parents, tags, bookmarks, changes, removes
     for [char, key] in s:chars
         let cs[key]=[]
         else
             let r.css=[]
         endif
-        for key in ['tags', 'bookmarks']
+        for key in a:repo.updkeys
             let list=s:F.getkeylist(a:repo, key)
             if cschange
                 call filter(list, 'v:val[1]<'.startrev)
         let revmap={}
         call map(copy(a:repo.changesets), 'extend(revmap, {v:val.rev : v:val})')
         let d={}
-        for key in ['tags', 'bookmarks']
+        for key in a:repo.updkeys
             try
                 let list=s:F.getkeylist(a:repo, key)
             catch
     if !empty(a:repo.mutable.cslist)
         call s:F.removechangesets(a:repo, d.startrev)
     endif
-    for key in ['tags', 'bookmarks']
+    for key in a:repo.updkeys
         call map(a:repo.mutable.cslist, 'extend(v:val, {key : []})')
         for [name, hex] in filter(items(d[key]),
                     \             'has_key(a:repo.changesets, v:val[1])')
 else "▶2
 function s:hg.annotate(repo, rev, file)
     let r=[]
+    " XXX Warning: --follow has the same effect as --file, but is not documented 
+    "              in most recent mercurial
     let lines=s:F.hg(a:repo, 'annotate', ['--', a:file],
-                \    {'rev': ''.a:rev, 'file':1, 'number':1, 'line-number':1},
+                \    {'rev': ''.a:rev, 'follow':1, 'number':1, 'line-number':1},
                 \    1, 'ann', a:rev, a:file)
     for line in lines
         " XXX This won't work for files that start with spaces and also with 
         return s:F.hg(a:repo, 'branch', [], {}, 0, 'b')[0]
     elseif a:prop is# 'tagslist' || a:prop is# 'brancheslist' ||
                 \                   a:prop is# 'bookmarkslist'
+        if a:prop is# 'bookmarkslist' && !a:repo.hasbookmarks
+            return []
+        endif
         return map(copy(s:F.getkeylist(a:repo, a:prop[:-5])), 'v:val[0]')
     elseif a:prop is# 'url'
         let lines=s:F.hg(a:repo, 'showconfig', ['paths'], {}, 0, 'sc')[:-2]
 else "▶2
 function s:F.trycmd(repo, cmd)
     try
-        return !empty(s:F.hg(a:repo, 'help', [a:cmd], {}, 0))
+        call s:F.hg(a:repo, 'help', [a:cmd], {}, 0)
+        return !v:shell_error
     catch
         return 0
     endtry
                 \              'copies', 'renames', 'files', 'description',
                 \              'phase']}
     let repo.hasphases=s:F.trycmd(repo, 'phase')
+    let repo.updkeys=['tags']
     if !s:F.trycmd(repo, 'bookmark')
         call filter(repo.labeltypes, 'v:val isnot# "bookmark"')
         let repo.hasbookmarks=0
     else
         let repo.hasbookmarks=1
+        let repo.updkeys+=['bookmarks']
     endif
     return repo
 endfunction

python/aurum/aumercurial.py

                       'changesets': {},
                          'mutable': {'cslist': []},
                            'local': 1 if repo.local() else 0,
-                      'labeltypes': ['tag', 'bookmark'],
+                      'labeltypes': ['tag',  'bookmark'],
+                         'updkeys': ['tags', 'bookmarks'],
+                    'hasbookmarks': 1,
                        'hasphases': int(hasattr(repo[None], 'phase')),
              }
     if hasattr(repo, '__len__'):
         vim_repo['csnum']=len(repo)+1
+    if not hasattr(commands, 'bookmarks'):
+        vim_repo['labeltypes'].pop()
+        vim_repo['updkeys'].pop()
+        vim_repo['hasbookmarks']=0
     vim_extend(var='repo', val=vim_repo)
 
 @outermethod

test/cmd-other.pre

 #!/bin/zsh
+export HGRCPATH=''
 tar xJf hgtestbranchedrepo.tar.xz
 hg -q clone hgtestbranchedrepo cmd-other-A -r A -r B
 hg -q clone cmd-other-A        cmd-other-B

test/util-add-cloned-repo.zsh

 #!/bin/zsh
+export HGRCPATH=''
 hg -q clone hgtestrepo ${CURTEST}repo