diff --git a/hggit/__init__.py b/hggit/__init__.py index b46639f34ff66857fc4cf29eb4dddbb5e696b779_aGdnaXQvX19pbml0X18ucHk=..dbe317d59de0b49b1426430dc4ba3646d39086a6_aGdnaXQvX19pbml0X18ucHk= 100644 --- a/hggit/__init__.py +++ b/hggit/__init__.py @@ -145,8 +145,6 @@ exchange, extensions, hg, - ui as hgui, - util as hgutil, localrepo, manifest, pycompat, @@ -201,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) @@ -521,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): @@ -539,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 b46639f34ff66857fc4cf29eb4dddbb5e696b779_aGdnaXQvY29tcGF0LnB5..dbe317d59de0b49b1426430dc4ba3646d39086a6_aGdnaXQvY29tcGF0LnB5 100644 --- a/hggit/compat.py +++ b/hggit/compat.py @@ -4,6 +4,8 @@ from mercurial import ( error, pycompat, + ui, + util as hgutil, ) try: @@ -7,6 +9,17 @@ ) 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 b46639f34ff66857fc4cf29eb4dddbb5e696b779_aGdnaXQvZ2l0X2hhbmRsZXIucHk=..dbe317d59de0b49b1426430dc4ba3646d39086a6_aGdnaXQvZ2l0X2hhbmRsZXIucHk= 100644 --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -33,6 +33,7 @@ ) from . import _ssh +from . import compat from . import git2hg from . import hg2git from . import util @@ -1851,7 +1852,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, @@ -1885,7 +1886,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 b46639f34ff66857fc4cf29eb4dddbb5e696b779_aGdnaXQvZ2l0cmVwby5weQ==..dbe317d59de0b49b1426430dc4ba3646d39086a6_aGdnaXQvZ2l0cmVwby5weQ== 100644 --- a/hggit/gitrepo.py +++ b/hggit/gitrepo.py @@ -1,5 +1,6 @@ from __future__ import generator_stop from .util import isgitsshuri +from . import compat from mercurial import ( error, @@ -4,6 +5,5 @@ from mercurial import ( error, - util ) from mercurial.wireprotov1peer import ( batchable, @@ -140,5 +140,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 b46639f34ff66857fc4cf29eb4dddbb5e696b779_dGVzdHMvdGVzdC1uZXR3b3JraW5nLnQ=..dbe317d59de0b49b1426430dc4ba3646d39086a6_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