Changeset - 0d7a127e6449
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2011-03-31 08:00:24
marcin@python-works.com
use cs get history instead of node.history, node history have to much reference calls
1 file changed with 10 insertions and 12 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/files.py
Show inline comments
 
@@ -126,26 +126,29 @@ class FilesController(BaseRepoController
 
        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.files_list = c.changeset.get_node(f_path)
 
            c.file_history = self._get_history(c.rhodecode_repo,
 
                                               c.files_list, f_path)
 

	
 
            if c.files_list.is_file():
 
                c.file_history = self._get_node_history(c.changeset, f_path)
 
            else:
 
                c.file_history = []
 
        except RepositoryError, e:
 
            h.flash(str(e), category='warning')
 
            redirect(h.url('files_home', repo_name=repo_name,
 
                           revision=revision))
 

	
 

	
 
        return render('files/files.html')
 

	
 
    def rawfile(self, repo_name, revision, f_path):
 
        cs = self.__get_cs_or_redirect(revision, repo_name)
 
        file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path)
 

	
 
@@ -154,32 +157,29 @@ class FilesController(BaseRepoController
 

	
 
        response.content_type = file_node.mimetype
 
        return file_node.content
 

	
 
    def raw(self, repo_name, revision, f_path):
 
        cs = self.__get_cs_or_redirect(revision, repo_name)
 
        file_node = self.__get_filenode_or_redirect(repo_name, cs, f_path)
 

	
 
        response.content_type = 'text/plain'
 
        return file_node.content
 

	
 
    def annotate(self, repo_name, revision, f_path):
 
        cs = self.__get_cs_or_redirect(revision, repo_name)
 
        c.file = self.__get_filenode_or_redirect(repo_name, cs, f_path)
 
        c.cs = self.__get_cs_or_redirect(revision, repo_name)
 
        c.file = self.__get_filenode_or_redirect(repo_name, c.cs, f_path)
 

	
 
        c.file_history = self._get_history(c.rhodecode_repo,
 
                                           c.file, f_path)
 
        c.cs = cs
 
        c.file_history = self._get_node_history(c.cs, f_path)
 
        c.f_path = f_path
 

	
 
        return render('files/files_annotate.html')
 

	
 
    def archivefile(self, repo_name, fname):
 

	
 
        fileformat = None
 
        revision = None
 
        ext = None
 

	
 
        for a_type, ext_data in ARCHIVE_SPECS.items():
 
            archive_spec = fname.split(ext_data[1])
 
            if len(archive_spec) == 2 and archive_spec[1] == '':
 
                fileformat = a_type or ext_data[1]
 
@@ -266,28 +266,26 @@ class FilesController(BaseRepoController
 
                c.cur_diff = _('Binary file')
 
            elif node1.size > self.cut_off_limit or node2.size > self.cut_off_limit:
 
                c.cur_diff = _('Diff is too big to display')
 
            else:
 
                diff = differ.DiffProcessor(differ.get_gitdiff(node1, node2),
 
                                        format='gitdiff')
 
                c.cur_diff = diff.as_html()
 

	
 
        if not c.cur_diff:
 
            c.no_changes = True
 
        return render('files/file_diff.html')
 

	
 
    def _get_history(self, repo, node, f_path):
 
        if not node.is_file():
 
            return []
 
        changesets = node.history
 
    def _get_node_history(self, cs, f_path):
 
        changesets = cs.get_file_history(f_path)
 
        hist_l = []
 

	
 
        changesets_group = ([], _("Changesets"))
 
        branches_group = ([], _("Branches"))
 
        tags_group = ([], _("Tags"))
 

	
 
        for chs in changesets:
 
            n_desc = 'r%s:%s' % (chs.revision, chs.short_id)
 
            changesets_group[0].append((chs.raw_id, n_desc,))
 

	
 
        hist_l.append(changesets_group)
 

	
0 comments (0 inline, 0 general)