Marcin Kuzminski avatar Marcin Kuzminski committed 6c0f763

fix for issue #450. Rhodecode no longer will crash when bad revision is present in journal data.

Comments (0)

Files changed (1)

rhodecode/lib/helpers.py

 from rhodecode.lib.utils2 import str2bool, safe_unicode, safe_str, \
     get_changeset_safe
 from rhodecode.lib.markup_renderer import MarkupRenderer
+from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
+from rhodecode.lib.vcs.backends.base import BaseChangeset
 
 log = logging.getLogger(__name__)
 
 
         repo = user_log.repository.scm_instance
 
-        message = lambda rev: rev.message
-        lnk = lambda rev, repo_name: (
-            link_to('r%s:%s' % (rev.revision, rev.short_id),
-                    url('changeset_home', repo_name=repo_name,
-                        revision=rev.raw_id),
-                    title=tooltip(message(rev)), class_='tooltip')
-        )
+        def lnk(rev, repo_name):
+
+            if isinstance(rev, BaseChangeset):
+                lbl = 'r%s:%s' % (rev.revision, rev.short_id)
+                _url = url('changeset_home', repo_name=repo_name, 
+                           revision=rev.raw_id)
+                title = tooltip(rev.message)
+            else:
+                lbl = '%s' % rev
+                _url = '#'
+                title = _('Changeset not found')
+
+            return link_to(lbl, _url, title=title, class_='tooltip',)
 
         revs = []
         if len(filter(lambda v: v != '', revs_ids)) > 0:
-            # get only max revs_top_limit of changeset for performance/ui reasons
-            revs = [
-                x for x in repo.get_changesets(revs_ids[0],
-                                               revs_ids[:revs_top_limit][-1])
-            ]
-
+            for rev in revs_ids[:revs_top_limit]:
+                try:
+                    rev = repo.get_changeset(rev)
+                    revs.append(rev)
+                except ChangesetDoesNotExistError:
+                    log.error('cannot find revision %s in this repo' % rev)
+                    revs.append(rev)
+                    continue
         cs_links = []
         cs_links.append(" " + ', '.join(
             [lnk(rev, repo_name) for rev in revs[:revs_limit]]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.