Changeset - 1c4007ec86e8
[Not reviewed]
default
0 2 0
Mads Kiilerich - 7 years ago 2018-12-23 21:16:06
mads@kiilerich.com
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.
2 files changed with 4 insertions and 7 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/backends/hg/repository.py
Show inline comments
 
@@ -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"
kallithea/lib/vcs/utils/hgcompat.py
Show inline comments
 
@@ -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
0 comments (0 inline, 0 general)