コード例 #1
0
    def url_handler(repo_type, url, ui):
        if repo_type == 'hg':
            from kallithea.lib.vcs.backends.hg.repository import MercurialRepository
            if url.startswith('http') or url.startswith('ssh'):
                # initially check if it's at least the proper URL
                # or does it pass basic auth
                MercurialRepository._check_url(url, ui)
            elif url.startswith('svn+http'):
                from hgsubversion.svnrepo import svnremoterepo
                svnremoterepo(ui, url).svn.uuid
            elif url.startswith('git+http'):
                raise NotImplementedError()
            else:
                raise Exception('clone from URI %s not allowed' % (url,))

        elif repo_type == 'git':
            from kallithea.lib.vcs.backends.git.repository import GitRepository
            if url.startswith('http') or url.startswith('git'):
                # initially check if it's at least the proper URL
                # or does it pass basic auth
                GitRepository._check_url(url)
            elif url.startswith('svn+http'):
                raise NotImplementedError()
            elif url.startswith('hg+http'):
                raise NotImplementedError()
            else:
                raise Exception('clone from URI %s not allowed' % (url))
コード例 #2
0
    def url_handler(repo_type, url, ui=None):
        if repo_type == 'hg':
            from rhodecode.lib.vcs.backends.hg.repository import MercurialRepository
            from mercurial.httppeer import httppeer
            if url.startswith('http'):
                ## initially check if it's at least the proper URL
                ## or does it pass basic auth
                MercurialRepository._check_url(url)
                httppeer(ui, url)._capabilities()
            elif url.startswith('svn+http'):
                from hgsubversion.svnrepo import svnremoterepo
                svnremoterepo(ui, url).capabilities
            elif url.startswith('git+http'):
                raise NotImplementedError()
            else:
                raise Exception('clone from URI %s not allowed' % (url))

        elif repo_type == 'git':
            from rhodecode.lib.vcs.backends.git.repository import GitRepository
            if url.startswith('http'):
                ## initially check if it's at least the proper URL
                ## or does it pass basic auth
                GitRepository._check_url(url)
            elif url.startswith('svn+http'):
                raise NotImplementedError()
            elif url.startswith('hg+http'):
                raise NotImplementedError()
            else:
                raise Exception('clone from URI %s not allowed' % (url))
コード例 #3
0
    def url_handler(repo_type, url, ui):
        if repo_type == 'hg':
            from kallithea.lib.vcs.backends.hg.repository import MercurialRepository
            if url.startswith('http') or url.startswith('ssh'):
                # initially check if it's at least the proper URL
                # or does it pass basic auth
                MercurialRepository._check_url(url, ui)
            elif url.startswith('svn+http'):
                try:
                    from hgsubversion.svnrepo import svnremoterepo
                except ImportError:
                    raise HgsubversionImportError(
                        _('Unable to activate hgsubversion support. '
                          'The "hgsubversion" library is missing'))
                svnremoterepo(ui, url).svn.uuid
            elif url.startswith('git+http'):
                raise NotImplementedError()
            else:
                raise Exception('clone from URI %s not allowed' % (url, ))

        elif repo_type == 'git':
            from kallithea.lib.vcs.backends.git.repository import GitRepository
            if url.startswith('http') or url.startswith('git'):
                # initially check if it's at least the proper URL
                # or does it pass basic auth
                GitRepository._check_url(url)
            elif url.startswith('svn+http'):
                raise NotImplementedError()
            elif url.startswith('hg+http'):
                raise NotImplementedError()
            else:
                raise Exception('clone from URI %s not allowed' % (url))
コード例 #4
0
ファイル: test_urls.py プロジェクト: bulwinkel/dot-files
    def test_url_rewriting(self):
        ui = test_util.ui.ui()
        ui.setconfig('hgsubversion', 'username', 'bob')
        repo = svnrepo.svnremoterepo(ui, 'svn+ssh://joe@foo/bar')
        self.assertEqual('svn+ssh://bob@foo/bar', repo.svnauth[0])

        repo = svnrepo.svnremoterepo(ui, 'svn+http://joe@foo/bar')
        self.assertEqual(('http://foo/bar', 'bob', None), repo.svnauth)

        repo = svnrepo.svnremoterepo(ui, 'svn+https://joe@foo/bar')
        self.assertEqual(('https://foo/bar', 'bob', None), repo.svnauth)
コード例 #5
0
    def test_quoting(self):
        ui = self.ui()
        repo_path = self.load_svndump('non_ascii_path_1.svndump')

        repo_url = test_util.fileurl(repo_path)
        subdir = '/b\xC3\xB8b'
        quoted_subdir = urllib.quote(subdir)

        repo1 = svnrepo.svnremoterepo(ui, repo_url + subdir)
        repo2 = svnrepo.svnremoterepo(ui, repo_url + quoted_subdir)
        self.assertEqual(repo1.svnurl, repo2.svnurl)
コード例 #6
0
ファイル: test_urls.py プロジェクト: fuzzball81/dotfiles
    def test_quoting(self):
        ui = self.ui()
        repo_path = self.load_svndump('non_ascii_path_1.svndump')

        repo_url = test_util.fileurl(repo_path)
        subdir = '/b\xC3\xB8b'
        quoted_subdir = urllib.quote(subdir)

        repo1 = svnrepo.svnremoterepo(ui, repo_url + subdir)
        repo2 = svnrepo.svnremoterepo(ui, repo_url + quoted_subdir)
        self.assertEqual(repo1.svnurl, repo2.svnurl)
コード例 #7
0
ファイル: svn.py プロジェクト: rhodecode/rhodecode-vcsserver
    def check_url(self, url, config_items):
        # this can throw exception if not installed, but we detect this
        from hgsubversion import svnrepo

        baseui = self._hg_factory._create_config(config_items)
        # uuid function get's only valid UUID from proper repo, else
        # throws exception
        try:
            svnrepo.svnremoterepo(baseui, url).svn.uuid
        except:
            log.debug("Invalid svn url: %s", url)
            raise URLError(
                '"%s" is not a valid Subversion source url.' % (url, ))
        return True
コード例 #8
0
    def test_url_rewriting(self):
        ui = test_util.testui()
        ui.setconfig('hgsubversion', 'username', 'bob')
        repo = svnrepo.svnremoterepo(ui, 'svn+ssh://joe@foo/bar')
        self.assertEqual('svn+ssh://bob@foo/bar', repo.svnauth[0])
        self.assertEqual('svn+ssh://bob@foo/bar', repo.svnurl)

        repo = svnrepo.svnremoterepo(ui, 'svn+http://joe@foo/bar')
        self.assertEqual(('http://foo/bar', 'bob', None), repo.svnauth)
        self.assertEqual('http://foo/bar', repo.svnurl)

        repo = svnrepo.svnremoterepo(ui, 'svn+https://joe@foo/bar')
        self.assertEqual(('https://foo/bar', 'bob', None), repo.svnauth)
        self.assertEqual('https://foo/bar', repo.svnurl)
コード例 #9
0
ファイル: svn.py プロジェクト: greyltc/rhodecode-vcsserver
    def check_url(self, url, config_items):
        # this can throw exception if not installed, but we detect this
        from hgsubversion import svnrepo

        baseui = self._hg_factory._create_config(config_items)
        # uuid function get's only valid UUID from proper repo, else
        # throws exception
        try:
            svnrepo.svnremoterepo(baseui, url).svn.uuid
        except Exception:
            tb = traceback.format_exc()
            log.debug("Invalid Subversion url: `%s`, tb: %s", url, tb)
            raise URLError('"%s" is not a valid Subversion source url.' %
                           (url, ))
        return True
コード例 #10
0
def is_valid_repo_uri(repo_type, url, ui):
    """Check if the url seems like a valid remote repo location
    Raise InvalidCloneUriException if any problems"""
    if repo_type == 'hg':
        if url.startswith('http') or url.startswith('ssh'):
            # initially check if it's at least the proper URL
            # or does it pass basic auth
            try:
                MercurialRepository._check_url(url, ui)
            except urllib.error.URLError as e:
                raise InvalidCloneUriException('URI %s URLError: %s' %
                                               (url, e))
            except mercurial.error.RepoError as e:
                raise InvalidCloneUriException(
                    'Mercurial %s: %s' %
                    (type(e).__name__, safe_str(bytes(e))))
        elif url.startswith('svn+http'):
            try:
                from hgsubversion.svnrepo import svnremoterepo
            except ImportError:
                raise InvalidCloneUriException(
                    'URI type %s not supported - hgsubversion is not available'
                    % (url, ))
            svnremoterepo(ui, url).svn.uuid
        elif url.startswith('git+http'):
            raise InvalidCloneUriException('URI type %s not implemented' %
                                           (url, ))
        else:
            raise InvalidCloneUriException('URI %s not allowed' % (url, ))

    elif repo_type == 'git':
        if url.startswith('http') or url.startswith('git'):
            # initially check if it's at least the proper URL
            # or does it pass basic auth
            try:
                GitRepository._check_url(url)
            except urllib.error.URLError as e:
                raise InvalidCloneUriException('URI %s URLError: %s' %
                                               (url, e))
        elif url.startswith('svn+http'):
            raise InvalidCloneUriException('URI type %s not implemented' %
                                           (url, ))
        elif url.startswith('hg+http'):
            raise InvalidCloneUriException('URI type %s not implemented' %
                                           (url, ))
        else:
            raise InvalidCloneUriException('URI %s not allowed' % (url))
コード例 #11
0
    def svnlog(self, repo=None):
        '''log of the remote Subversion repository corresponding to repo

        In order to make the format suitable for direct comparison in
        tests, we exclude dates and convert the path operations into
        a tuple.
        '''

        if repo is None:
            repo = self.repo

        return [(r.revnum, r.message,
                 dict((p, (op.action, op.copyfrom_path, int(op.copyfrom_rev)))
                      for (p, op) in r.paths.items()))
                for r in svnrepo.svnremoterepo(repo.ui).svn.revisions()]
コード例 #12
0
 def check_parse_url(self, expected, args):
     self.assertEqual(expected, parse_url(*args))
     if len(args) == 1:
         repo = svnrepo.svnremoterepo(self.ui(), path=args[0])
         self.assertEqual(expected[2], repo.svnauth[0])
         self.assertEqual(expected[2], repo.svnurl)