Changeset - 267bb347d68c
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 12 years ago 2013-06-15 14:37:51
marcin@python-works.com
Added missing __get_cs_or_redirect method for file history.
Fixes issue with displaying a history of file that is not present at tip.
1 file changed with 30 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changelog.py
Show inline comments
 
@@ -29,6 +29,7 @@ import traceback
 
from pylons import request, url, session, tmpl_context as c
 
from pylons.controllers.util import redirect
 
from pylons.i18n.translation import _
 
from webob.exc import HTTPNotFound, HTTPBadRequest
 

	
 
import rhodecode.lib.helpers as h
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
@@ -39,7 +40,7 @@ from rhodecode.lib.graphmod import _colo
 
from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\
 
    ChangesetError, NodeDoesNotExistError, EmptyRepositoryError
 
from rhodecode.lib.utils2 import safe_int
 
from webob.exc import HTTPNotFound
 

	
 

	
 
log = logging.getLogger(__name__)
 

	
 
@@ -68,6 +69,33 @@ class ChangelogController(BaseRepoContro
 
        super(ChangelogController, self).__before__()
 
        c.affected_files_cut_off = 60
 

	
 
    def __get_cs_or_redirect(self, rev, repo, redirect_after=True,
 
                             partial=False):
 
        """
 
        Safe way to get changeset if error occur it redirects to changeset with
 
        proper message. If partial is set then don't do redirect raise Exception
 
        instead
 

	
 
        :param rev: revision to fetch
 
        :param repo: repo instance
 
        """
 

	
 
        try:
 
            return c.rhodecode_repo.get_changeset(rev)
 
        except EmptyRepositoryError, e:
 
            if not redirect_after:
 
                return None
 
            h.flash(h.literal(_('There are no changesets yet')),
 
                    category='warning')
 
            redirect(url('changelog_home', repo_name=repo.repo_name))
 

	
 
        except RepositoryError, e:
 
            log.error(traceback.format_exc())
 
            h.flash(str(e), category='warning')
 
            if not partial:
 
                redirect(h.url('changelog_home', repo_name=repo.repo_name))
 
            raise HTTPBadRequest()
 

	
 
    def _graph(self, repo, revs_int, repo_size, size, p):
 
        """
 
        Generates a DAG graph for repo
 
@@ -120,7 +148,7 @@ class ChangelogController(BaseRepoContro
 
                except (NodeDoesNotExistError, ChangesetError):
 
                    #this node is not present at tip !
 
                    try:
 
                        cs = self.__get_cs_or_redirect(revision, repo_name)
 
                        cs = self.__get_css_or_redirect(revision, repo_name)
 
                        collection = cs.get_file_history(f_path)
 
                    except RepositoryError, e:
 
                        h.flash(str(e), category='warning')
0 comments (0 inline, 0 general)