Exemple #1
0
    def index(self, repo_name, revision, f_path, annotate=False):
        # redirect to given revision from form if given
        post_revision = request.POST.get('at_rev', None)
        if post_revision:
            cs = self.__get_cs_or_redirect(post_revision, repo_name)

        c.changeset = self.__get_cs_or_redirect(revision, repo_name)
        c.branch = request.GET.get('branch', None)
        c.f_path = f_path
        c.annotate = annotate
        c.changeset = self.__get_cs_or_redirect(revision, repo_name)
        cur_rev = c.changeset.revision

        # prev link
        try:
            prev_rev = c.rhodecode_repo.get_changeset(cur_rev).prev(c.branch)
            c.url_prev = url('files_home', repo_name=c.repo_name,
                         revision=prev_rev.raw_id, f_path=f_path)
            if c.branch:
                c.url_prev += '?branch=%s' % c.branch
        except (ChangesetDoesNotExistError, VCSError):
            c.url_prev = '#'

        # next link
        try:
            next_rev = c.rhodecode_repo.get_changeset(cur_rev).next(c.branch)
            c.url_next = url('files_home', repo_name=c.repo_name,
                     revision=next_rev.raw_id, f_path=f_path)
            if c.branch:
                c.url_next += '?branch=%s' % c.branch
        except (ChangesetDoesNotExistError, VCSError):
            c.url_next = '#'

        # files or dirs
        try:
            c.file = c.changeset.get_node(f_path)

            if c.file.is_file():
                c.load_full_history = False
                file_last_cs = c.file.last_changeset
                c.file_changeset = (c.changeset
                                    if c.changeset.revision < file_last_cs.revision
                                    else file_last_cs)
                #determine if we're on branch head
                _branches = c.rhodecode_repo.branches
                c.on_branch_head = revision in _branches.keys() + _branches.values()
                _hist = []
                c.file_history = []
                if c.load_full_history:
                    c.file_history, _hist = self._get_node_history(c.changeset, f_path)

                c.authors = []
                for a in set([x.author for x in _hist]):
                    c.authors.append((h.email(a), h.person(a)))
            else:
                c.authors = c.file_history = []
        except RepositoryError, e:
            h.flash(str(e), category='error')
            raise HTTPNotFound()
Exemple #2
0
    def index(self, repo_name, revision, f_path, annotate=False):
        # redirect to given revision from form if given
        post_revision = request.POST.get('at_rev', None)
        if post_revision:
            cs = self.__get_cs_or_redirect(post_revision, repo_name)

        c.changeset = self.__get_cs_or_redirect(revision, repo_name)
        c.branch = request.GET.get('branch', None)
        c.f_path = f_path
        c.annotate = annotate
        c.changeset = self.__get_cs_or_redirect(revision, repo_name)
        cur_rev = c.changeset.revision

        # prev link
        try:
            prev_rev = c.rhodecode_repo.get_changeset(cur_rev).prev(c.branch)
            c.url_prev = url('files_home', repo_name=c.repo_name,
                         revision=prev_rev.raw_id, f_path=f_path)
            if c.branch:
                c.url_prev += '?branch=%s' % c.branch
        except (ChangesetDoesNotExistError, VCSError):
            c.url_prev = '#'

        # next link
        try:
            next_rev = c.rhodecode_repo.get_changeset(cur_rev).next(c.branch)
            c.url_next = url('files_home', repo_name=c.repo_name,
                     revision=next_rev.raw_id, f_path=f_path)
            if c.branch:
                c.url_next += '?branch=%s' % c.branch
        except (ChangesetDoesNotExistError, VCSError):
            c.url_next = '#'

        # files or dirs
        try:
            c.file = c.changeset.get_node(f_path)

            if c.file.is_file():
                c.load_full_history = False
                file_last_cs = c.file.last_changeset
                c.file_changeset = (c.changeset
                                    if c.changeset.revision < file_last_cs.revision
                                    else file_last_cs)
                #determine if we're on branch head
                _branches = c.rhodecode_repo.branches
                c.on_branch_head = revision in _branches.keys() + _branches.values()
                _hist = []
                c.file_history = []
                if c.load_full_history:
                    c.file_history, _hist = self._get_node_history(c.changeset, f_path)

                c.authors = []
                for a in set([x.author for x in _hist]):
                    c.authors.append((h.email(a), h.person(a)))
            else:
                c.authors = c.file_history = []
        except RepositoryError, e:
            h.flash(safe_str(e), category='error')
            raise HTTPNotFound()
Exemple #3
0
    def index(self, repo_name, revision, f_path, annotate=False):
        # redirect to given revision from form if given
        post_revision = request.POST.get('at_rev', None)
        if post_revision:
            cs = self.__get_cs_or_redirect(post_revision, repo_name)
            redirect(url('files_home', repo_name=c.repo_name,
                         revision=cs.raw_id, f_path=f_path))

        c.changeset = self.__get_cs_or_redirect(revision, repo_name)
        c.branch = request.GET.get('branch', None)
        c.f_path = f_path
        c.annotate = annotate
        cur_rev = c.changeset.revision

        # prev link
        try:
            prev_rev = c.rhodecode_repo.get_changeset(cur_rev).prev(c.branch)
            c.url_prev = url('files_home', repo_name=c.repo_name,
                         revision=prev_rev.raw_id, f_path=f_path)
            if c.branch:
                c.url_prev += '?branch=%s' % c.branch
        except (ChangesetDoesNotExistError, VCSError):
            c.url_prev = '#'

        # next link
        try:
            next_rev = c.rhodecode_repo.get_changeset(cur_rev).next(c.branch)
            c.url_next = url('files_home', repo_name=c.repo_name,
                     revision=next_rev.raw_id, f_path=f_path)
            if c.branch:
                c.url_next += '?branch=%s' % c.branch
        except (ChangesetDoesNotExistError, VCSError):
            c.url_next = '#'

        # files or dirs
        try:
            c.file = c.changeset.get_node(f_path)

            if c.file.is_file():
                _hist = c.changeset.get_file_history(f_path)
                c.file_history = self._get_node_history(c.changeset, f_path,
                                                        _hist)
                c.authors = []
                for a in set([x.author for x in _hist]):
                    c.authors.append((h.email(a), h.person(a)))
            else:
                c.authors = c.file_history = []
        except RepositoryError, e:
            h.flash(str(e), category='warning')
            redirect(h.url('files_home', repo_name=repo_name,
                           revision='tip'))
Exemple #4
0
 def history(self, repo_name, revision, f_path, annotate=False):
     if request.environ.get("HTTP_X_PARTIAL_XHR"):
         c.changeset = self.__get_cs_or_redirect(revision, repo_name)
         c.f_path = f_path
         c.annotate = annotate
         c.file = c.changeset.get_node(f_path)
         if c.file.is_file():
             file_last_cs = c.file.last_changeset
             c.file_changeset = c.changeset if c.changeset.revision < file_last_cs.revision else file_last_cs
             c.file_history, _hist = self._get_node_history(c.changeset, f_path)
             c.authors = []
             for a in set([x.author for x in _hist]):
                 c.authors.append((h.email(a), h.person(a)))
             return render("files/files_history_box.html")
Exemple #5
0
 def history(self, repo_name, revision, f_path, annotate=False):
     if request.environ.get('HTTP_X_PARTIAL_XHR'):
         c.changeset = self.__get_cs_or_redirect(revision, repo_name)
         c.f_path = f_path
         c.annotate = annotate
         c.file = c.changeset.get_node(f_path)
         if c.file.is_file():
             file_last_cs = c.file.last_changeset
             c.file_changeset = (c.changeset
                                 if c.changeset.revision < file_last_cs.revision
                                 else file_last_cs)
             c.file_history, _hist = self._get_node_history(c.changeset, f_path)
             c.authors = []
             for a in set([x.author for x in _hist]):
                 c.authors.append((h.email(a), h.person(a)))
             return render('files/files_history_box.html')
 def authors(self, repo_name, revision, f_path):
     commit = self.__get_commit_or_redirect(revision, repo_name)
     file_node = commit.get_node(f_path)
     if file_node.is_file():
         c.file_last_commit = file_node.last_commit
         if request.GET.get('annotate') == '1':
             # use _hist from annotation if annotation mode is on
             commit_ids = set(x[1] for x in file_node.annotate)
             _hist = (c.rhodecode_repo.get_commit(commit_id)
                      for commit_id in commit_ids)
         else:
             _f_history, _hist = self._get_node_history(commit, f_path)
         c.file_author = False
         c.authors = []
         for author in set(commit.author for commit in _hist):
             c.authors.append((h.email(author),
                               h.person(author,
                                        'username_or_name_or_email')))
         return render('files/file_authors_box.html')
    def index(self,
              repo_name,
              revision,
              f_path,
              annotate=False,
              rendered=False):
        commit_id = revision

        # redirect to given commit_id from form if given
        get_commit_id = request.GET.get('at_rev', None)
        if get_commit_id:
            self.__get_commit_or_redirect(get_commit_id, repo_name)

        c.commit = self.__get_commit_or_redirect(commit_id, repo_name)
        c.branch = request.GET.get('branch', None)
        c.f_path = f_path
        c.annotate = annotate
        # default is false, but .rst/.md files later are autorendered, we can
        # overwrite autorendering by setting this GET flag
        c.renderer = rendered or not request.GET.get('no-render', False)

        # prev link
        try:
            prev_commit = c.commit.prev(c.branch)
            c.prev_commit = prev_commit
            c.url_prev = url('files_home',
                             repo_name=c.repo_name,
                             revision=prev_commit.raw_id,
                             f_path=f_path)
            if c.branch:
                c.url_prev += '?branch=%s' % c.branch
        except (CommitDoesNotExistError, VCSError):
            c.url_prev = '#'
            c.prev_commit = EmptyCommit()

        # next link
        try:
            next_commit = c.commit.next(c.branch)
            c.next_commit = next_commit
            c.url_next = url('files_home',
                             repo_name=c.repo_name,
                             revision=next_commit.raw_id,
                             f_path=f_path)
            if c.branch:
                c.url_next += '?branch=%s' % c.branch
        except (CommitDoesNotExistError, VCSError):
            c.url_next = '#'
            c.next_commit = EmptyCommit()

        # files or dirs
        try:
            c.file = c.commit.get_node(f_path)
            c.file_author = True
            c.file_tree = ''
            if c.file.is_file():
                c.renderer = (c.renderer
                              and h.renderer_from_filename(c.file.path))
                c.file_last_commit = c.file.last_commit

                c.on_branch_head = self._is_valid_head(commit_id,
                                                       c.rhodecode_repo)
                c.branch_or_raw_id = c.commit.branch or c.commit.raw_id

                author = c.file_last_commit.author
                c.authors = [(h.email(author),
                              h.person(author, 'username_or_name_or_email'))]
            else:
                c.authors = []
                c.file_tree = self._get_tree_at_commit(repo_name,
                                                       c.commit.raw_id, f_path)
        except RepositoryError as e:
            h.flash(safe_str(e), category='error')
            raise HTTPNotFound()

        if request.environ.get('HTTP_X_PJAX'):
            return render('files/files_pjax.html')

        return render('files/files.html')