Commits

ZyX_I committed 578f23c

@aurum/drivers/mercurial: Made it throw human-readable error in case when there
is no git revision associated with mercurial one
Not trying extensions.hg-git now
Now assuming that if option is named extensions.git
then hg-git is named git
Made it not throw an exception in case python driver
is not used when python is available

Comments (0)

Files changed (2)

plugin/aurum/drivers/mercurial.vim

     catch
         " s:usepythondriver stays equal to 0, errors are ignored
     endtry
-    execute s:_r.py.cmd 'reload(aurum)'
+    " FIXME Does not work in python3. Not very problematic as mercurial does not 
+    " do this either, but it will be necessary to review these lines after 
+    " python3 support in mercurial will be finished.
+    if s:usepythondriver
+        execute s:_r.py.cmd 'reload(aurum)'
+    endif
 endif
 let s:_messages={
             \ 'norepo': 'Repository %s not found',
             \ 'nosvnrev': 'Failed to find revision in “hg svn info” output '.
             \             'in the repository %s. Output:%s',
             \ 'nohggitc': 'It appears that hg-git is not enabled '.
-            \             '(tried options extensions.hggit, extensions.hg-git '.
-            \              'and extensions.git)',
+            \             '(tried options extensions.hggit and extensions.git)',
             \  'nohggit': 'It appears that hg-git is not installed '.
             \             '(importing GitHandler threw ImportError)',
+            \ 'nogitrev': 'No git revision associated with revision %s '.
+            \             'in repository %s',
         \}
 let s:nullrev=repeat('0', 40)
 let s:_options={
     try:
         repo=g_repo(path)
         hggitpath=None
-        for hggitname in ['hggit', 'hg-git', 'git']:
+        hggitname=None
+        for hggitname in ['hggit', 'git']:
             hggitpath=repo.ui.config('extensions', hggitname)
             if hggitpath is not None:
                 break
         if hggitpath is None:
             vim_throw('nohggitc')
         import sys
-        sys.path.append(hggitpath)
+        sys.path.insert(0, hggitpath)
         try:
             try:
-                from hggit.git_handler import GitHandler
+                if hggitname=='hggit':
+                    from hggit.git_handler import GitHandler
+                elif hggitname=='git':
+                    from git.git_handler   import GitHandler
             except ImportError:
                 vim_throw('nohggit')
             git=GitHandler(repo, repo.ui)
-            r=git.map_git_get(g_cs(repo, rev).hex())
+            cs=g_cs(repo, rev)
+            r=git.map_git_get(cs.hex())
+            if r is None:
+                vim_throw('nogitrev', cs.hex(), repo.path)
             vim.command('return '+json.dumps(r))
         finally:
-            sys.path.pop()
+            sys.path.pop(0)
     except AurumError:
         pass