calling "annotate --show-ids" for an empty file leads to an exception

Bug #314525 reported by Anne Mohsen
2
Affects Status Importance Assigned to Milestone
Bazaar
Fix Released
High
Anne Mohsen

Bug Description

Bazaar version used :

Bazaar (bzr) 1.11dev
  from bzr checkout /home/mysql_src/logiciels/bzr_versions/dev
    revision: 3923
    revid: <email address hidden>
    branch nick: dev

Steps to reproduce:

bzr init
touch bar
bzr add bar
bzr commit -m bar
bzr annotate --show-ids bar

Traceback (most recent call last):

  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/commands.py", line 893, in run_bzr_catch_errors
    return run_bzr(argv)
  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/commands.py", line 839, in run_bzr
    ret = run(*run_argv)
  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/commands.py", line 539, in run_argv_aliases
    return self.run(**all_cmd_args)
  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/commands.py", line 853, in ignore_pipe
    result = func(*args, **kwargs)
  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/builtins.py", line 3708, in run
    show_ids=show_ids)
  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/annotate.py", line 91, in annotate_file_tree
    return _show_id_annotations(annotations, to_file, full)
  File "/home/mysql_src/logiciels/bzr_versions/dev/bzrlib/annotate.py", line 155, in _show_id_annotations
    max_origin_len = max(len(origin) for origin, text in annotations)
ValueError: max() arg is an empty sequence

A way to correct it is to add in annotate.py :

--- bzrlib/annotate.py 2008-09-02 01:26:52 +0000
+++ bzrlib/annotate.py 2009-01-06 21:31:53 +0000
@@ -151,6 +151,8 @@

 def _show_id_annotations(annotations, to_file, full):
+ if not annotations:
+ return
     last_rev_id = None
     max_origin_len = max(len(origin) for origin, text in annotations)
     for origin, text in annotations:

Revision history for this message
Martin Pool (mbp) wrote : Re: [Bug 314525] [NEW] calling "annotate --show-ids" for an empty file leads to an exception

  status confirmed
  importance high
  tags mysql patch
  assigned me

--
Martin <http://launchpad.net/~mbp>

Changed in bzr:
importance: Undecided → High
status: New → Confirmed
Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 314525] [NEW] calling "annotate --show-ids" for an empty file leads to an exception

 status confirmed

Looks like a solid fix to me. A test would be ideal.

-Rob

Revision history for this message
Anne Mohsen (anne-mohsen) wrote :

I am attaching a patch with the fix and a test.

Vincent Ladeuil (vila)
Changed in bzr:
assignee: nobody → anne-mohsen
milestone: none → 1.12rc1
status: Confirmed → Fix Committed
Vincent Ladeuil (vila)
Changed in bzr:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.