# HG changeset patch # User Mads Kiilerich # Date 2018-12-23 21:16:06 # Node ID 1c4007ec86e89f8e1071797844fdc2989e662be5 # Parent 7651f0cbca822e9936d7a6b2f37a2656468df4ad hg: fix URL cloning with Mercurial 4.6 and later In 03dfcbe52906, I didn't notice that the API also changed ... and it was not sufficiently tested. Now, instead of using the peer classes directly, use the instance wrapper. There is no automated testing of this, but it was tested manually to also work in the oldest supported Mercurial version. diff --git a/kallithea/lib/vcs/backends/hg/repository.py b/kallithea/lib/vcs/backends/hg/repository.py --- a/kallithea/lib/vcs/backends/hg/repository.py +++ b/kallithea/lib/vcs/backends/hg/repository.py @@ -292,7 +292,7 @@ class MercurialRepository(BaseRepository if url.startswith('ssh:'): # in case of invalid uri or authentication issues, sshpeer will # throw an exception. - sshpeer(repoui or ui.ui(), url).lookup('tip') + sshpeer.instance(repoui or ui.ui(), url, False).lookup('tip') return True url_prefix = None @@ -334,7 +334,7 @@ class MercurialRepository(BaseRepository if not url_prefix: # skip svn+http://... (and git+... too) # now check if it's a proper hg repo try: - httppeer(repoui or ui.ui(), url).lookup('tip') + httppeer.instance(repoui or ui.ui(), url, False).lookup('tip') except Exception as e: raise urllib2.URLError( "url [%s] does not look like an hg repo org_exc: %s" diff --git a/kallithea/lib/vcs/utils/hgcompat.py b/kallithea/lib/vcs/utils/hgcompat.py --- a/kallithea/lib/vcs/utils/hgcompat.py +++ b/kallithea/lib/vcs/utils/hgcompat.py @@ -13,6 +13,8 @@ from mercurial import unionrepo from mercurial import scmutil from mercurial import config from mercurial import tags as tagsmod +from mercurial import httppeer +from mercurial import sshpeer from mercurial.commands import clone, nullid, pull from mercurial.context import memctx, memfilectx from mercurial.error import RepoError, RepoLookupError, Abort @@ -24,11 +26,6 @@ from mercurial.node import hex from mercurial.encoding import tolocal from mercurial.discovery import findcommonoutgoing from mercurial.hg import peer -from mercurial.httppeer import httppeer -try: # sshpeer was renamed in Mercurial 4.6 (625038cb4b1d), but v1 is still good enough - from mercurial.sshpeer import sshv1peer as sshpeer -except ImportError: - from mercurial.sshpeer import sshpeer from mercurial.util import url as hg_url from mercurial.scmutil import revrange from mercurial.node import nullrev