@@ -273,26 +273,27 @@ class MercurialRepository(BaseRepository
Function will check given url and try to verify if it's a valid
link. Sometimes it may happened that mercurial will issue basic
auth request that can cause whole API to hang when used from python
or other external calls.
On failures it'll raise urllib2.HTTPError, exception is also thrown
when the return code is non 200
"""
# check first if it's not an local url
if os.path.isdir(url) or url.startswith('file:'):
return True
url_prefix = None
if '+' in url[:url.find('://')]:
url = url[url.find('+') + 1:]
url_prefix, url = url.split('+', 1)
handlers = []
url_obj = hg_url(url)
test_uri, authinfo = url_obj.authinfo()
url_obj.passwd = '*****'
cleaned_uri = str(url_obj)
if authinfo:
#create a password manager
passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
passmgr.add_password(*authinfo)
@@ -308,31 +309,32 @@ class MercurialRepository(BaseRepository
qs = '?%s' % urllib.urlencode(q)
cu = "%s%s" % (test_uri, qs)
req = urllib2.Request(cu, None, {})
try:
resp = o.open(req)
if resp.code != 200:
raise Exception('Return Code is not 200')
except Exception, e:
# means it cannot be cloned
raise urllib2.URLError("[%s] org_exc: %s" % (cleaned_uri, e))
# now check if it's a proper hg repo
httppeer(repoui or ui.ui(), url).lookup('tip')
raise urllib2.URLError(
"url [%s] does not look like an hg repo org_exc: %s"
% (cleaned_uri, e))
if not url_prefix: # skip svn+http://... (and git+... too)
def _get_repo(self, create, src_url=None, update_after_clone=False):
Function will check for mercurial repository in given path and return
a localrepo object. If there is no repository in that path it will
raise an exception unless ``create`` parameter is set to True - in
that case repository would be created and returned.
If ``src_url`` is given, would try to clone repository from the
location at given clone_point. Additionally it'll make update to
working copy accordingly to ``update_after_clone`` flag
Status change: