Exemple #1
0
    def test_get_repo(self):
        alias = 'hg'
        path = TEST_HG_REPO
        backend = get_backend(alias)
        repo = backend(path)

        self.assertEqual(repo.__class__, get_repo(path, alias).__class__)
        self.assertEqual(repo.path, get_repo(path, alias).path)
Exemple #2
0
    def test_get_repo_autoalias_hg(self):
        alias = 'hg'
        path = TEST_HG_REPO
        backend = get_backend(alias)
        repo = backend(path)

        self.assertEqual(repo.__class__, get_repo(path).__class__)
        self.assertEqual(repo.path, get_repo(path).path)
Exemple #3
0
    def test_get_repo_autoalias_git(self):
        alias = 'git'
        path = TEST_GIT_REPO
        backend = get_backend(alias)
        repo = backend(safe_str(path))

        self.assertEqual(repo.__class__, get_repo(safe_str(path)).__class__)
        self.assertEqual(repo.path, get_repo(safe_str(path)).path)
Exemple #4
0
    def test_get_repo_autoalias_hg(self):
        alias = 'hg'
        path = TEST_HG_REPO
        backend = get_backend(alias)
        repo = backend(safe_str(path))

        self.assertEqual(repo.__class__, get_repo(safe_str(path)).__class__)
        self.assertEqual(repo.path, get_repo(safe_str(path)).path)
Exemple #5
0
    def test_get_repo_autoalias_hg(self):
        alias = 'hg'
        path = TEST_HG_REPO
        backend = get_backend(alias)
        repo = backend(path)

        assert repo.__class__ == get_repo(path).__class__
        assert repo.path == get_repo(path).path
Exemple #6
0
    def test_get_repo_autoalias_git(self):
        alias = 'git'
        path = TEST_GIT_REPO
        backend = get_backend(alias)
        repo = backend(path)

        assert repo.__class__ == get_repo(path).__class__
        assert repo.path == get_repo(path).path
Exemple #7
0
    def test_get_repo(self):
        alias = 'hg'
        path = TEST_HG_REPO
        backend = get_backend(alias)
        repo = backend(safe_str(path))

        self.assertEqual(repo.__class__, get_repo(safe_str(path), alias).__class__)
        self.assertEqual(repo.path, get_repo(safe_str(path), alias).path)
Exemple #8
0
    def test_get_repo_autoalias_git(self):
        alias = 'git'
        path = TEST_GIT_REPO
        backend = get_backend(alias)
        repo = backend(path)

        self.assertEqual(repo.__class__, get_repo(path).__class__)
        self.assertEqual(repo.path, get_repo(path).path)
Exemple #9
0
    def __get_instance(self):
        repo_full_path = self.repo_full_path
        try:
            alias = get_scm(repo_full_path)[0]
            log.debug('Creating instance of %s repository' % alias)
            backend = get_backend(alias)
        except VCSError:
            log.error(traceback.format_exc())
            log.error('Perhaps this repository is in db and not in '
                      'filesystem run rescan repositories with '
                      '"destroy old data " option from admin panel')
            return

        if alias == 'hg':

            repo = backend(safe_str(repo_full_path), create=False,
                           baseui=self._ui)
        else:
            repo = backend(repo_full_path, create=False)

        return repo
Exemple #10
0
    def repo_scan(self, repos_path=None):
        """
        Listing of repositories in given path. This path should not be a
        repository itself. Return a dictionary of repository objects mapping to
        vcs instances.

        :param repos_path: path to directory containing repositories
        """

        if repos_path is None:
            repos_path = self.repos_path

        log.info('scanning for repositories in %s', repos_path)

        baseui = make_ui()
        repos = {}

        for name, path in get_filesystem_repos(repos_path):
            # name need to be decomposed and put back together using the /
            # since this is internal storage separator for kallithea
            name = Repository.normalize_repo_name(name)

            try:
                if name in repos:
                    raise RepositoryError('Duplicate repository name %s '
                                          'found in %s' % (name, path))
                else:

                    klass = get_backend(path[0])

                    if path[0] == 'hg' and path[0] in BACKENDS:
                        repos[name] = klass(path[1], baseui=baseui)

                    if path[0] == 'git' and path[0] in BACKENDS:
                        repos[name] = klass(path[1])
            except OSError:
                continue
        log.debug('found %s paths with repositories', len(repos))
        return repos
Exemple #11
0
    def repo_scan(self, repos_path=None):
        """
        Listing of repositories in given path. This path should not be a
        repository itself. Return a dictionary of repository objects

        :param repos_path: path to directory containing repositories
        """

        if repos_path is None:
            repos_path = self.repos_path

        log.info('scanning for repositories in %s' % repos_path)

        baseui = make_ui('db')
        repos = {}

        for name, path in get_filesystem_repos(repos_path, recursive=True):
            # name need to be decomposed and put back together using the /
            # since this is internal storage separator for kallithea
            name = Repository.normalize_repo_name(name)

            try:
                if name in repos:
                    raise RepositoryError('Duplicate repository name %s '
                                          'found in %s' % (name, path))
                else:

                    klass = get_backend(path[0])

                    if path[0] == 'hg' and path[0] in BACKENDS.keys():
                        repos[name] = klass(safe_str(path[1]), baseui=baseui)

                    if path[0] == 'git' and path[0] in BACKENDS.keys():
                        repos[name] = klass(path[1])
            except OSError:
                continue
        log.debug('found %s paths with repositories' % (len(repos)))
        return repos
Exemple #12
0
 def get_backend(self):
     return vcs.get_backend(self.backend_alias)
Exemple #13
0
 def test_get_backend(self):
     hg = get_backend('hg')
     self.assertEqual(hg, MercurialRepository)
Exemple #14
0
 def test_wrong_alias(self):
     alias = 'wrong_alias'
     with pytest.raises(VCSError):
         get_backend(alias)
Exemple #15
0
 def test_alias_detect_git(self):
     alias = 'git'
     path = TEST_GIT_REPO
     backend = get_backend(alias)
     repo = backend(path)
     assert 'git' == repo.alias
Exemple #16
0
 def test_alias_detect_hg(self):
     alias = 'hg'
     path = TEST_HG_REPO
     backend = get_backend(alias)
     repo = backend(path)
     assert 'hg' == repo.alias
Exemple #17
0
 def test_get_backend(self):
     hg = get_backend('hg')
     self.assertEqual(hg, MercurialRepository)
Exemple #18
0
 def _configure_backend(self, request):
     Backend = vcs.get_backend(self.backend_alias)
     type(self).backend_class = Backend
     type(self).setup_repo(Backend)
 def get_backend(self):
     return vcs.get_backend(self.backend_alias)
Exemple #20
0
 def get_backend(cls):
     return vcs.get_backend(cls.backend_alias)
Exemple #21
0
 def test_alias_detect_hg(self):
     alias = 'hg'
     path = TEST_HG_REPO
     backend = get_backend(alias)
     repo = backend(safe_str(path))
     self.assertEqual('hg',repo.alias)
Exemple #22
0
 def test_alias_detect_git(self):
     alias = 'git'
     path = TEST_GIT_REPO
     backend = get_backend(alias)
     repo = backend(path)
     self.assertEqual('git', repo.alias)
Exemple #23
0
 def test_alias_detect_hg(self):
     alias = 'hg'
     path = TEST_HG_REPO
     backend = get_backend(alias)
     repo = backend(path)
     self.assertEqual('hg', repo.alias)
Exemple #24
0
 def get_backend(cls):
     return vcs.get_backend(cls.backend_alias)
Exemple #25
0
 def test_get_backend(self):
     hg = get_backend('hg')
     assert hg == MercurialRepository
Exemple #26
0
 def test_alias_detect_git(self):
     alias = 'git'
     path = TEST_GIT_REPO
     backend = get_backend(alias)
     repo = backend(safe_str(path))
     self.assertEqual('git',repo.alias)