diff --git a/hgext/git/__init__.py b/hgext/git/__init__.py
--- a/hgext/git/__init__.py
+++ b/hgext/git/__init__.py
@@ -4,6 +4,8 @@
 firstborn a la Rumpelstiltskin, etc.
 """
 
+from __future__ import absolute_import
+
 import os
 
 from mercurial import (
diff --git a/hgext/git/dirstate.py b/hgext/git/dirstate.py
--- a/hgext/git/dirstate.py
+++ b/hgext/git/dirstate.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+
 import errno
 import os
 import stat
@@ -18,7 +20,7 @@
 
 
 def readpatternfile(orig, filepath, warn, sourceinfo=False):
-    if not ('info/exclude' in fp.name or fp.name.endswith('.gitignore')):
+    if not ('info/exclude' in filepath or filepath.endswith('.gitignore')):
         return orig(filepath, warn, sourceinfo=False)
     result = []
     warnings = []
@@ -270,7 +272,7 @@
 
             # git stores symlinks with a mode of 000, we need it to be 777
             if mode == stat.S_IFLNK:
-                mode = mode | 0777
+                mode = mode | 0o777
 
             # this is a crude hack, but makes 'hg forget' work
             if p not in p1:
diff --git a/hgext/git/gitlog.py b/hgext/git/gitlog.py
--- a/hgext/git/gitlog.py
+++ b/hgext/git/gitlog.py
@@ -1,3 +1,7 @@
+from __future__ import absolute_import
+
+from mercurial.i18n import _
+
 from mercurial import (
     ancestor,
     changelog as hgchangelog,
@@ -24,7 +28,7 @@
             'SELECT rev FROM changelog WHERE node = ?',
             (nodemod.hex(n),)).fetchone()
         if t is None:
-            raise error.LookupError(node, '00changelog.i', _('no node'))
+            raise error.LookupError(n, '00changelog.i', _('no node'))
         return t[0]
 
     def node(self, r):
@@ -34,7 +38,7 @@
             'SELECT node FROM changelog WHERE rev = ?',
             (r,)).fetchone()
         if t is None:
-            raise error.LookupError(node, '00changelog.i', _('no node'))
+            raise error.LookupError(r, '00changelog.i', _('no node'))
         return nodemod.bin(t[0])
 
 
@@ -112,7 +116,7 @@
         if c.parents:
             p1 = self.rev(c.parents[0].id.raw)
             if len(c.parents) > 2:
-                raise util.Abort('TODO octopus merge handling')
+                raise error.Abort('TODO octopus merge handling')
             if len(c.parents) == 2:
                 p2 = self.rev(c.parents[0].id.raw)
         return p1, p2
@@ -172,7 +176,7 @@
             parts = relpath.split('/')
             for p in parts:
                 te = t[p]
-                t = repo[te.id]
+                t = self.gitrepo[te.id]
         return gittreemanifestctx(t)
 
 class filelog(baselog):
diff --git a/hgext/git/index.py b/hgext/git/index.py
--- a/hgext/git/index.py
+++ b/hgext/git/index.py
@@ -1,8 +1,13 @@
+from __future__ import absolute_import
+
 import os
 import sqlite3
 
+from mercurial.i18n import _
+
 from mercurial import (
     encoding,
+    error,
     node as nodemod,
 )