Merge lp:~pr0gg3d/loggerhead/annotate_zero_size_820065 into lp:loggerhead

Proposed by Francesco Del Degan
Status: Merged
Approved by: Gavin Panella
Approved revision: 456
Merged at revision: 454
Proposed branch: lp:~pr0gg3d/loggerhead/annotate_zero_size_820065
Merge into: lp:loggerhead
Prerequisite: lp:~pr0gg3d/loggerhead/annotate_comment_notpresent_812583
Diff against target: 46 lines (+16/-2)
2 files modified
loggerhead/controllers/annotate_ui.py (+4/-0)
loggerhead/tests/test_controllers.py (+12/-2)
To merge this branch: bzr merge lp:~pr0gg3d/loggerhead/annotate_zero_size_820065
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+70885@code.launchpad.net

This proposal supersedes a proposal from 2011-08-08.

Commit message

Don't break when annotating a zero-sized file.

Description of the change

This fixes #820065

The bug occurs when trying to annotate a zero-sized file.
The last_lineno is None, and an exception is raised at the end of method.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 8/8/2011 11:09 PM, Francesco Del Degan wrote:
> Francesco Del Degan has proposed merging
> lp:~pr0gg3d/loggerhead/annotate_zero_size_820065 into lp:loggerhead.
>
> Requested reviews: Loggerhead Reviewers (loggerhead-reviewers)
> Related bugs: Bug #820065 in loggerhead: "TypeError: unsupported
> operand type(s) for -: 'int' and 'NoneType'"
> https://bugs.launchpad.net/loggerhead/+bug/820065
>
> For more details, see:
> https://code.launchpad.net/~pr0gg3d/loggerhead/annotate_zero_size_820065/+merge/70789
>
> This fixes #820065
>
> The bug occurs when trying to annotate a zero-sized file. The
> last_lineno is None, and an exception is raised at the end of
> method.
>
>

Good change, but again, it would be nice to have a simple test for this.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk5BBXsACgkQJdeBCYSNAAPa1gCgsUeNvuKXWegQldo8I3bNUGGD
iz8AoMPb5kLkd+99xuxXSZRboFZ0rWJA
=wL8n
-----END PGP SIGNATURE-----

456. By Francesco Del Degan

Test fixture

Revision history for this message
Gavin Panella (allenap) wrote :

This seems sane to me. Do you need someone to land it for you?

review: Approve
Revision history for this message
Francesco Del Degan (pr0gg3d) wrote :

Yes, i don't have the rights to merge into main branch, the prerequisite branch has been merged two days ago.

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 2011-08-09 14:12:50 +0000
3+++ loggerhead/controllers/annotate_ui.py 2011-08-09 14:12:50 +0000
4@@ -62,6 +62,10 @@
5 last_lineno = lineno
6 last_line_revid = line_revid
7
8+ # Zero-size file. Return empty revisions.
9+ if last_lineno is None:
10+ return revisions
11+
12 # We never set a revspan for the last revision during the loop above, so set it here.
13 revisions[last_lineno].revspan = lineno - last_lineno + 1
14
15
16=== modified file 'loggerhead/tests/test_controllers.py'
17--- loggerhead/tests/test_controllers.py 2011-08-09 14:12:50 +0000
18+++ loggerhead/tests/test_controllers.py 2011-08-09 14:12:50 +0000
19@@ -137,7 +137,7 @@
20 self.assertEqual(2, len(annotated))
21 self.assertEqual('2', annotated[1].change.revno)
22 self.assertEqual('1', annotated[2].change.revno)
23-
24+
25 def test_annotate_empty_comment(self):
26 # Testing empty comment handling without breaking
27 history = [('rev1', 'old\nold\n', '.'), ('rev2', 'new\nold\n', '')]
28@@ -145,7 +145,17 @@
29 ann_ui.args = ['rev2']
30 annotate_info = ann_ui.get_values('filename',
31 kwargs={'file_id': 'file_id'}, headers={})
32-
33+
34+ def test_annotate_file_zero_sized(self):
35+ # Test against a zero-sized file without breaking. No annotation must be present.
36+ history = [('rev1', '' , '.')]
37+ ann_ui = self.make_annotate_ui_for_file_history('file_id', history)
38+ ann_ui.args = ['rev1']
39+ annotate_info = ann_ui.get_values('filename',
40+ kwargs={'file_id': 'file_id'}, headers={})
41+ annotated = annotate_info['annotated']
42+ self.assertEqual(0, len(annotated))
43+
44 class TestFileDiffUI(BasicTests):
45
46 def make_branch_app_for_filediff_ui(self):

Subscribers

People subscribed via source and target branches