diff --git a/hggit/__init__.py b/hggit/__init__.py
index 96dbd036ef7e5c6a25cd7981f8482560d130cd0e_aGdnaXQvX19pbml0X18ucHk=..ada43aa3bf76218d8ee80e2c9ba18ba117842861_aGdnaXQvX19pbml0X18ucHk= 100644
--- a/hggit/__init__.py
+++ b/hggit/__init__.py
@@ -127,7 +127,6 @@
     exchange,
     extensions,
     hg,
-    ui as hgui,
     util as hgutil,
     localrepo,
     manifest,
@@ -200,7 +199,7 @@
 
 
 def _local(path):
-    p = hgutil.url(path).localpath()
+    p = compat.url(path).localpath()
     if _isgitdir(p):
         return gitrepo
     # detect git ssh urls (which mercurial thinks is a file-like path)
@@ -520,9 +519,15 @@
     return orig(self, path) or _isgitdir(path)
 
 
-if (hgutil.safehasattr(hgui, b'path') and
-    hgutil.safehasattr(hgui.path, b'_isvalidlocalpath')):
-    extensions.wrapfunction(hgui.path, b'_isvalidlocalpath', isvalidlocalpath)
+extensions.wrapfunction(compat.path, b'_isvalidlocalpath', isvalidlocalpath)
+
+
+def isurllocal(orig, path):
+    # recognise git scp-style paths when cloning
+    return orig(path) and not util.isgitsshuri(path._origpath)
+
+
+extensions.wrapfunction(compat.url, b'islocal', isurllocal)
 
 
 def islocal(orig, path):
@@ -538,7 +543,7 @@
     return orig(path) or util.isgitsshuri(path)
 
 
-extensions.wrapfunction(hgutil, b'hasscheme', hasscheme)
+extensions.wrapfunction(compat.urlutil, b'hasscheme', hasscheme)
 
 
 @util.transform_notgit
diff --git a/hggit/compat.py b/hggit/compat.py
index 96dbd036ef7e5c6a25cd7981f8482560d130cd0e_aGdnaXQvY29tcGF0LnB5..ada43aa3bf76218d8ee80e2c9ba18ba117842861_aGdnaXQvY29tcGF0LnB5 100644
--- a/hggit/compat.py
+++ b/hggit/compat.py
@@ -49,6 +49,17 @@
     itervalues = lambda x: x.itervalues()
 
 try:
+    # added in 5.8
+    from mercurial.utils import urlutil
+
+    url = urlutil.url
+    path = urlutil.path
+except ImportError:
+    urlutil = hgutil
+    url = hgutil.url
+    path = ui.path
+
+try:
     from mercurial.cmdutil import check_at_most_one_arg
 except (ImportError, AttributeError):
     # added in 5.3
diff --git a/hggit/git_handler.py b/hggit/git_handler.py
index 96dbd036ef7e5c6a25cd7981f8482560d130cd0e_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..ada43aa3bf76218d8ee80e2c9ba18ba117842861_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644
--- a/hggit/git_handler.py
+++ b/hggit/git_handler.py
@@ -1860,7 +1860,7 @@
 
             # not available in dulwich 0.19, used on Python 2.7
             if hasattr(client, 'get_credentials_from_store'):
-                urlobj = hgutil.url(uri)
+                urlobj = compat.url(uri)
                 auth = client.get_credentials_from_store(
                     urlobj.scheme,
                     urlobj.host,
@@ -1894,7 +1894,7 @@
             )
 
         if uri.startswith(b'file://'):
-            return client.LocalGitClient(), hgutil.url(uri).path
+            return client.LocalGitClient(), compat.url(uri).path
 
         # if its not git or git+ssh, try a local url..
         return client.SubprocessGitClient(), uri
diff --git a/hggit/gitrepo.py b/hggit/gitrepo.py
index 96dbd036ef7e5c6a25cd7981f8482560d130cd0e_aGdnaXQvZ2l0cmVwby5weQ==..ada43aa3bf76218d8ee80e2c9ba18ba117842861_aGdnaXQvZ2l0cmVwby5weQ== 100644
--- a/hggit/gitrepo.py
+++ b/hggit/gitrepo.py
@@ -3,7 +3,6 @@
 from .util import isgitsshuri
 from mercurial import (
     error,
-    util
 )
 
 from . import compat
@@ -158,5 +157,5 @@
     if isgitsshuri(path):
         return True
 
-    u = util.url(path)
+    u = compat.url(path)
     return not u.scheme or u.scheme == b'file'
diff --git a/tests/test-networking.t b/tests/test-networking.t
index 96dbd036ef7e5c6a25cd7981f8482560d130cd0e_dGVzdHMvdGVzdC1uZXR3b3JraW5nLnQ=..ada43aa3bf76218d8ee80e2c9ba18ba117842861_dGVzdHMvdGVzdC1uZXR3b3JraW5nLnQ= 100644
--- a/tests/test-networking.t
+++ b/tests/test-networking.t
@@ -88,6 +88,8 @@
   $ hg add thefile
   $ fn_hg_commit -m 'add the file'
   $ hg book -r tip master
+  $ hg path default
+  git@git-server:/srv/repo.git
   $ hg push
   Warning: Permanently added * (glob) (?)
   pushing to git@git-server:/srv/repo.git