@classmethod
    def _check_url(cls, url):
        """
        Functon 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
        """

        # check first if it's not an local url
        if os.path.isdir(url) or url.startswith('file:'):
            return True

        if('+' in url[:url.find('://')]):
            url = url[url.find('+') + 1:]

        handlers = []
        test_uri, authinfo = hg_url(url).authinfo()
        if not test_uri.endswith('info/refs'):
            test_uri = test_uri.rstrip('/') + '/info/refs'
        if authinfo:
            #create a password manager
            passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
            passmgr.add_password(*authinfo)

            handlers.extend((httpbasicauthhandler(passmgr),
                             httpdigestauthhandler(passmgr)))

        o = urllib2.build_opener(*handlers)
        o.addheaders = [('User-Agent', 'git/1.7.8.0')]  # fake some git

        q = {"service": 'git-upload-pack'}
        qs = '?%s' % urllib.urlencode(q)
        cu = "%s%s" % (test_uri, qs)
        req = urllib2.Request(cu, None, {})

        try:
            resp = o.open(req)
            return resp.code == 200
        except Exception, e:
            # means it cannot be cloned
            raise urllib2.URLError("[%s] %s" % (url, e))
dataset/ETHPy150Open codeinn/vcs/vcs/backends/git/repository.py/GitRepository._check_url/original