Commits

ZyX_I  committed 8e1f8c4

Remove tentry.to_object as it was removed from pygit2

  • Participants
  • Parent commits dd6f0ec

Comments (0)

Files changed (2)

File autoload/aurum/drivers/git.vim

 endfunction
 "▶1 git.getrevhex :: repo, rev → hex
 let s:prevrevhex={}
+if s:usepythondriver
+function s:git.getrevhex(repo, rev)
+    let d={}
+    try
+        execute s:pya.'getrevhex(vim.eval("a:repo.path"), vim.eval("a:rev"))'
+    endtry
+    return d.hex
+endfunction
+else
 function s:git.getrevhex(repo, rev)
     if a:rev=~#'\v^[0-9a-f]{40}$'
         if has_key(s:prevrevhex, a:repo.path)
     let s:prevrevhex[a:repo.path]=[a:rev, r]
     return r
 endfunction
+endif
 "▶1 git.getworkhex :: repo → hex
 function s:git.getworkhex(repo)
     return a:repo.functions.getrevhex(a:repo, 'HEAD')

File python/aurum/augit.py

 def flush(repo):
     pass
 
-# TODO Maybe cache repo and cs? It seems that unlike with mercurial it is supported in pygit2
-
 def g_repo(path):
     try:
         return git.Repository(path)
 autoexportmethod = autoexportmethodgen(g_repo, globals())
 
 def g_cs(repo, rev):
-    if hasattr(repo, 'revparse_single'):
-        try:
-            # TODO Check this. Currently it works only in development branch
-            r = repo.revparse_single(rev)
-        except Exception: # FIXME be more specific
-            vim_throw('norev', rev, repo.path)
-    else:
-        try:
-            ref = repo.lookup_reference(rev)
-            r = repo[ref.resolve().oid]
-        except KeyError:
-            try:
-                r = repo[unicode(rev, 'utf-8')]
-            except KeyError:
-                vim_throw('norev', rev, repo.path)
+    try:
+        # TODO Check this. Currently it works only in development branch
+        r = repo.revparse_single(rev)
+    except Exception: # FIXME be more specific
+        vim_throw('norev', rev, repo.path)
 
     while not isinstance(r, git.Commit):
         if isinstance(r, git.Tag):
 
 get_repo_prop = outermethod(autoexportmethod()(get_repo_prop_gen(repo_props)))
 
-def list_tree_files(tree, prefix=None):
+def list_tree_files(repo, tree, prefix=None):
     for tentry in tree:
         fname = prefix+'/'+tentry.name if prefix else tentry.name
-        ntree = tentry.to_object()
+        ntree = repo[tentry.oid]
         if isinstance(ntree, git.Tree):
-            for nfname in list_tree_files(ntree, prefix=fname):
+            for nfname in list_tree_files(repo, ntree, prefix=fname):
                 yield nfname
         else:
             yield fname
 
 @outermethod
 @autoexportmethod()
+def getrevhex(repo, rev):
+    cs = g_cs(repo, rev)
+    return {'hex': cs.hex}
+
+@outermethod
+@autoexportmethod()
 def get_status(repo, files=None, clean=None, ignored=None):
     r = emptystatdct()
     if files:
         status = repo.status()
         statuses = status.iteritems()
         if clean:
-            r['clean'] = [fname for fname in list_tree_files(g_cs(repo, 'HEAD').tree)
+            r['clean'] = [fname for fname in list_tree_files(repo, g_cs(repo, 'HEAD').tree)
                           if fname not in status]
     while True:
         try: