Merge lp:~twom/loggerhead/anootate-changes-should-exist into lp:loggerhead

Proposed by Tom Wardill
Status: Merged
Merged at revision: 507
Proposed branch: lp:~twom/loggerhead/anootate-changes-should-exist
Merge into: lp:loggerhead
Diff against target: 25 lines (+7/-1)
1 file modified
loggerhead/controllers/annotate_ui.py (+7/-1)
To merge this branch: bzr merge lp:~twom/loggerhead/anootate-changes-should-exist
Reviewer Review Type Date Requested Status
Colin Watson Approve
Review via email: mp+387384@code.launchpad.net

Commit message

Check changes exist before using them.
Based on patch by lp:~pnutzh4x0r

Description of the change

Changes may not exist in the case of 'ghost revisions', but we assume they do. Check that any changes are retrieved and if not, create an object so we can at least render the page.

Based on the patch provided by lp:~pnutzh4x0r in LP: #376586

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'loggerhead/controllers/annotate_ui.py'
2--- loggerhead/controllers/annotate_ui.py 2020-06-04 20:30:54 +0000
3+++ loggerhead/controllers/annotate_ui.py 2020-07-14 16:45:11 +0000
4@@ -16,6 +16,7 @@
5 # Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
6 #
7
8+from datetime import datetime
9 import itertools
10
11 from ..controllers.view_ui import ViewUI
12@@ -48,7 +49,12 @@
13
14 change = change_cache.get(line_revid, None)
15 if change is None:
16- change = self._history.get_changes([line_revid])[0]
17+ changes = self._history.get_changes([line_revid])
18+ if changes:
19+ change = changes[0]
20+ else:
21+ change = util.Container(
22+ authors='', date=datetime.now(), revno='')
23 change_cache[line_revid] = change
24
25 try:

Subscribers

People subscribed via source and target branches