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)
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)
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)
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)
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
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
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)
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)
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
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
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
def get_backend(self): return vcs.get_backend(self.backend_alias)
def test_get_backend(self): hg = get_backend('hg') self.assertEqual(hg, MercurialRepository)
def test_wrong_alias(self): alias = 'wrong_alias' with pytest.raises(VCSError): get_backend(alias)
def test_alias_detect_git(self): alias = 'git' path = TEST_GIT_REPO backend = get_backend(alias) repo = backend(path) assert 'git' == repo.alias
def test_alias_detect_hg(self): alias = 'hg' path = TEST_HG_REPO backend = get_backend(alias) repo = backend(path) assert 'hg' == repo.alias
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(cls): return vcs.get_backend(cls.backend_alias)
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)
def test_alias_detect_git(self): alias = 'git' path = TEST_GIT_REPO backend = get_backend(alias) repo = backend(path) self.assertEqual('git', repo.alias)
def test_alias_detect_hg(self): alias = 'hg' path = TEST_HG_REPO backend = get_backend(alias) repo = backend(path) self.assertEqual('hg', repo.alias)
def test_get_backend(self): hg = get_backend('hg') assert hg == MercurialRepository
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)