comparison rhodecode/controllers/files.py @ 2977:cff9d4e1d821 beta

Fixed issue when node didn't exists at 'tip' and we tried calculate history based on that assumption. Now fallback to the changeset the node exists in for history calculation
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 04 Nov 2012 13:08:27 +0100
parents 9937afa7f093
children 6cd0f8f8aef1
comparison
equal deleted inserted replaced
2976:45a8e0051280 2977:cff9d4e1d821
43 from rhodecode.lib.base import BaseRepoController, render 43 from rhodecode.lib.base import BaseRepoController, render
44 from rhodecode.lib.vcs.backends.base import EmptyChangeset 44 from rhodecode.lib.vcs.backends.base import EmptyChangeset
45 from rhodecode.lib.vcs.conf import settings 45 from rhodecode.lib.vcs.conf import settings
46 from rhodecode.lib.vcs.exceptions import RepositoryError, \ 46 from rhodecode.lib.vcs.exceptions import RepositoryError, \
47 ChangesetDoesNotExistError, EmptyRepositoryError, \ 47 ChangesetDoesNotExistError, EmptyRepositoryError, \
48 ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError 48 ImproperArchiveTypeError, VCSError, NodeAlreadyExistsError,\
49 NodeDoesNotExistError
49 from rhodecode.lib.vcs.nodes import FileNode 50 from rhodecode.lib.vcs.nodes import FileNode
50 51
51 from rhodecode.model.repo import RepoModel 52 from rhodecode.model.repo import RepoModel
52 from rhodecode.model.scm import ScmModel 53 from rhodecode.model.scm import ScmModel
53 from rhodecode.model.db import Repository 54 from rhodecode.model.db import Repository
158 c.file_changeset = c.changeset 159 c.file_changeset = c.changeset
159 if _hist: 160 if _hist:
160 c.file_changeset = (c.changeset 161 c.file_changeset = (c.changeset
161 if c.changeset.revision < _hist[0].revision 162 if c.changeset.revision < _hist[0].revision
162 else _hist[0]) 163 else _hist[0])
163 c.file_history = self._get_node_history(None, f_path, _hist) 164 c.file_history = self._get_node_history(c.changeset, f_path,
165 _hist)
164 c.authors = [] 166 c.authors = []
165 for a in set([x.author for x in _hist]): 167 for a in set([x.author for x in _hist]):
166 c.authors.append((h.email(a), h.person(a))) 168 c.authors.append((h.email(a), h.person(a)))
167 else: 169 else:
168 c.authors = c.file_history = [] 170 c.authors = c.file_history = []
502 c.changes = [('', node2, diff, cs1, cs2, st,)] 504 c.changes = [('', node2, diff, cs1, cs2, st,)]
503 505
504 return render('files/file_diff.html') 506 return render('files/file_diff.html')
505 507
506 def _get_node_history(self, cs, f_path, changesets=None): 508 def _get_node_history(self, cs, f_path, changesets=None):
507 if cs is None: 509 """
508 # if we pass empty CS calculate history based on tip 510 get changesets history for given node
509 cs = c.rhodecode_repo.get_changeset() 511
512 :param cs: changeset to calculate history
513 :param f_path: path for node to calculate history for
514 :param changesets: if passed don't calculate history and take
515 changesets defined in this list
516 """
517 # calculate history based on tip
518 tip_cs = c.rhodecode_repo.get_changeset()
510 if changesets is None: 519 if changesets is None:
511 changesets = cs.get_file_history(f_path) 520 try:
521 changesets = tip_cs.get_file_history(f_path)
522 except NodeDoesNotExistError:
523 #this node is not present at tip !
524 changesets = cs.get_file_history(f_path)
512 525
513 hist_l = [] 526 hist_l = []
514 527
515 changesets_group = ([], _("Changesets")) 528 changesets_group = ([], _("Changesets"))
516 branches_group = ([], _("Branches")) 529 branches_group = ([], _("Branches"))