Example #1
0
    def make_template_context(self, repo, rev, path):
        try:
            repo = current_app.repo_map[repo]
        except KeyError:
            raise NotFound("No such repository %r" % repo)

        if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise NotFound("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise NotFound("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise NotFound("File not found")

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        }
Example #2
0
    def make_template_context(self, repo, rev, path):
        repo, rev, path, commit = _get_repo_and_rev(repo, rev, path)

        try:
            submodule_rev = tree_lookup_path(
                repo.__getitem__, commit.tree, encode_for_git(path))[1]
        except KeyError:
            raise NotFound("Parent path for submodule missing")

        try:
            (submodule_url, submodule_path) = _get_submodule(
                repo, commit, encode_for_git(path))
        except KeyError:
            submodule_url = None
            submodule_path = None

        # TODO(jelmer): Rather than printing an information page,
        # redirect to the page in klaus for the repository at
        # submodule_path, revision submodule_rev.

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'subpaths': list(subpaths(path)) if path else None,
            'submodule_url': force_unicode(submodule_url),
            'submodule_path': force_unicode(submodule_path),
            'submodule_rev': force_unicode(submodule_rev),
            'base_href': None,
        }
Example #3
0
    def make_template_context(self, repo, rev, path):
        try:
            repo = current_app.repo_map[repo]
        except KeyError:
            raise NotFound("No such repository %r" % repo)

        if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise NotFound("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise NotFound("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise NotFound("File not found")

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        }
Example #4
0
    def make_template_context(self, repo, namespace, rev, path):
        repo, rev, path, commit = _get_repo_and_rev(repo, namespace, rev, path)

        try:
            submodule_rev = tree_lookup_path(repo.__getitem__, commit.tree,
                                             encode_for_git(path))[1]
        except KeyError:
            raise NotFound("Parent path for submodule missing")

        try:
            (submodule_url,
             submodule_path) = _get_submodule(repo, commit,
                                              encode_for_git(path))
        except KeyError:
            submodule_url = None
            submodule_path = None

        # TODO(jelmer): Rather than printing an information page,
        # redirect to the page in klaus for the repository at
        # submodule_path, revision submodule_rev.

        self.context = {
            "view": self.view_name,
            "repo": repo,
            "rev": rev,
            "commit": commit,
            "branches": repo.get_branch_names(exclude=rev),
            "tags": repo.get_tag_names(),
            "path": path,
            "subpaths": list(subpaths(path)) if path else None,
            "submodule_url": force_unicode(submodule_url),
            "submodule_path": force_unicode(submodule_path),
            "submodule_rev": force_unicode(submodule_rev),
            "base_href": None,
        }
Example #5
0
    def make_template_context(self, repo, rev, path):
        repo, rev, path, commit = _get_repo_and_rev(repo, rev, path)

        try:
            submodule_rev = tree_lookup_path(repo.__getitem__, commit.tree,
                                             encode_for_git(path))[1]
        except KeyError:
            raise NotFound("Parent path for submodule missing")

        try:
            (submodule_url,
             submodule_path) = _get_submodule(repo, commit,
                                              encode_for_git(path))
        except KeyError:
            submodule_url = None
            submodule_path = None

        # TODO(jelmer): Rather than printing an information page,
        # redirect to the page in klaus for the repository at
        # submodule_path, revision submodule_rev.

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'subpaths': list(subpaths(path)) if path else None,
            'submodule_url': force_unicode(submodule_url),
            'submodule_path': force_unicode(submodule_path),
            'submodule_rev': force_unicode(submodule_rev),
            'base_href': None,
        }
Example #6
0
    def make_template_context(self, repo, rev, path):
        try:
            repo = current_app.repos[repo]
        except KeyError:
            raise NotFound("No such repository %r" % repo)

        if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise NotFound("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise NotFound("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise NotFound("File not found")

        self.context = {
            "view": self.view_name,
            "repo": repo,
            "rev": rev,
            "commit": commit,
            "branches": repo.get_branch_names(exclude=rev),
            "tags": repo.get_tag_names(),
            "path": path,
            "blob_or_tree": blob_or_tree,
            "subpaths": list(subpaths(path)) if path else None,
        }
Example #7
0
    def make_template_context(self, repo, rev, path):
        repo, rev, commit = _get_repo_and_rev(repo, rev)
        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise NotFound("File not found")

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        }
Example #8
0
    def make_template_context(self, repo, rev, path):
        repo, rev, commit = _get_repo_and_rev(repo, rev)
        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise NotFound("File not found")

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        }
Example #9
0
    def make_context(self, repo, commit_id, path):
        try:
            repo = current_app.repo_map[repo]
            if commit_id is None:
                commit_id = repo.get_default_branch()
            commit  = repo.get_ref_or_commit(commit_id)
        except KeyError:
            raise NotFound

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'commit_id': commit_id,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=commit_id),
            'tags': repo.get_tag_names(),
            'path': path,
            'subpaths': list(subpaths(path)) if path else None,
        }
Example #10
0
    def make_context(self, repo, commit_id, path):
        try:
            repo = current_app.repo_map[repo]
            if commit_id is None:
                commit_id = repo.get_default_branch()
            commit = repo.get_ref_or_commit(commit_id)
        except KeyError:
            raise NotFound

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'commit_id': commit_id,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=commit_id),
            'tags': repo.get_tag_names(),
            'path': path,
            'subpaths': list(subpaths(path)) if path else None,
        }
Example #11
0
    def make_template_context(self, repo, namespace, rev, path):
        repo, rev, path, commit = _get_repo_and_rev(repo, namespace, rev, path)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise NotFound("File not found")

        self.context = {
            "view": self.view_name,
            "repo": repo,
            "namespace": namespace,
            "rev": rev,
            "commit": commit,
            "branches": repo.get_branch_names(exclude=rev),
            "tags": repo.get_tag_names(),
            "path": path,
            "blob_or_tree": blob_or_tree,
            "subpaths": list(subpaths(path)) if path else None,
            "base_href": None,
        }
Example #12
0
    def make_context(self, repo, commit_id, path):
        try:
            repo = current_app.repo_map[repo]
            if commit_id is None:
                commit_id = repo.get_default_branch()
            commit  = repo.get_ref_or_commit(commit_id)
        except KeyError:
            raise NotFound
        
        readme = repo.get_tree(commit, "/README.html")

        self.context = {
            'view': self.view_name,
            'repo': repo,
            'commit_id': commit_id,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=commit_id),
            'tags': repo.get_tag_names(),
            'path': path,
            'subpaths': list(subpaths(path)) if path else None,
            'header': readme.data if hasattr(readme, 'data') else "",
        }
Example #13
0
    def get_context_data(self, **ctx):
        context = super(BaseRepoView, self).get_context_data(**ctx)

        repo = RepoManager.get_repo(self.kwargs['repo'])
        rev = self.kwargs.get('rev')
        path = self.kwargs.get('path')
        if isinstance(path, unicode):
            path = path.encode("utf-8")
	if isinstance(rev, unicode):
            rev = rev.encode("utf-8")
        
	if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise RepoException("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise RepoException("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise RepoException("File not found")

        context.update({
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        })

        return context
Example #14
0
    def get_context_data(self, **ctx):
        context = super(BaseRepoView, self).get_context_data(**ctx)

        repo = RepoManager.get_repo(self.kwargs['repo'])
        rev = self.kwargs.get('rev')
        path = self.kwargs.get('path')
        if isinstance(path, unicode):
            path = path.encode("utf-8")

        if rev is None:
            rev = repo.get_default_branch()
            if rev is None:
                raise RepoException("Empty repository")
        try:
            commit = repo.get_commit(rev)
        except KeyError:
            raise RepoException("No such commit %r" % rev)

        try:
            blob_or_tree = repo.get_blob_or_tree(commit, path)
        except KeyError:
            raise RepoException("File not found")

        context.update({
            'view': self.view_name,
            'repo': repo,
            'rev': rev,
            'commit': commit,
            'branches': repo.get_branch_names(exclude=rev),
            'tags': repo.get_tag_names(),
            'path': path,
            'blob_or_tree': blob_or_tree,
            'subpaths': list(subpaths(path)) if path else None,
        })

        return context