##// END OF EJS Templates
hg: support Mercurial 6.1 without util.url
Mads Kiilerich -
r8704:da519b97 stable
parent child Browse files
Show More
@@ -19,7 +19,12 b' import urllib.parse'
19 import urllib.request
19 import urllib.request
20 from collections import OrderedDict
20 from collections import OrderedDict
21
21
22 import mercurial.util # import url as hg_url
22
23 try:
24 from mercurial.utils.urlutil import url as hg_url
25 except ImportError: # urlutil was introduced in Mercurial 5.8
26 from mercurial.util import url as hg_url
27
23 from dulwich.client import SubprocessGitClient
28 from dulwich.client import SubprocessGitClient
24 from dulwich.config import ConfigFile
29 from dulwich.config import ConfigFile
25 from dulwich.objects import Tag
30 from dulwich.objects import Tag
@@ -226,7 +231,7 b' class GitRepository(BaseRepository):'
226 if parsed_url.scheme not in ['http', 'https']:
231 if parsed_url.scheme not in ['http', 'https']:
227 raise urllib.error.URLError("Unsupported protocol in URL %r" % url)
232 raise urllib.error.URLError("Unsupported protocol in URL %r" % url)
228
233
229 url_obj = mercurial.util.url(safe_bytes(url))
234 url_obj = hg_url(safe_bytes(url))
230 test_uri, handlers = get_urllib_request_handlers(url_obj)
235 test_uri, handlers = get_urllib_request_handlers(url_obj)
231 if not test_uri.endswith(b'info/refs'):
236 if not test_uri.endswith(b'info/refs'):
232 test_uri = test_uri.rstrip(b'/') + b'/info/refs'
237 test_uri = test_uri.rstrip(b'/') + b'/info/refs'
@@ -34,7 +34,12 b' import mercurial.sshpeer'
34 import mercurial.tags
34 import mercurial.tags
35 import mercurial.ui
35 import mercurial.ui
36 import mercurial.unionrepo
36 import mercurial.unionrepo
37 import mercurial.util
37
38
39 try:
40 from mercurial.utils.urlutil import url as hg_url
41 except ImportError: # urlutil was introduced in Mercurial 5.8
42 from mercurial.util import url as hg_url
38
43
39 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
44 from kallithea.lib.vcs.backends.base import BaseRepository, CollectionGenerator
40 from kallithea.lib.vcs.exceptions import (BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError,
45 from kallithea.lib.vcs.exceptions import (BranchDoesNotExistError, ChangesetDoesNotExistError, EmptyRepositoryError, RepositoryError, TagAlreadyExistError,
@@ -336,7 +341,7 b' class MercurialRepository(BaseRepository'
336 if '+' in parsed_url.scheme: # strip 'git+' for hg-git URLs
341 if '+' in parsed_url.scheme: # strip 'git+' for hg-git URLs
337 url = url.split(b'+', 1)[1]
342 url = url.split(b'+', 1)[1]
338
343
339 url_obj = mercurial.util.url(url)
344 url_obj = hg_url(url)
340 test_uri, handlers = get_urllib_request_handlers(url_obj)
345 test_uri, handlers = get_urllib_request_handlers(url_obj)
341
346
342 url_obj.passwd = b'*****'
347 url_obj.passwd = b'*****'
@@ -245,7 +245,7 b' def get_urllib_request_handlers(url_obj)'
245 if authinfo:
245 if authinfo:
246 # authinfo is a tuple (realm, uris, user, password) where 'uris' itself
246 # authinfo is a tuple (realm, uris, user, password) where 'uris' itself
247 # is a tuple of URIs.
247 # is a tuple of URIs.
248 # If url_obj is obtained via mercurial.util.url, the obtained authinfo
248 # If url_obj is obtained via mercurial urlutil, the obtained authinfo
249 # values will be bytes, e.g.
249 # values will be bytes, e.g.
250 # (None, (b'http://127.0.0.1/repo', b'127.0.0.1'), b'user', b'pass')
250 # (None, (b'http://127.0.0.1/repo', b'127.0.0.1'), b'user', b'pass')
251 # However, urllib expects strings, not bytes, so we must convert them.
251 # However, urllib expects strings, not bytes, so we must convert them.
General Comments 0
You need to be logged in to leave comments. Login now