gcommit: unknown error "float division"

Bug #221414 reported by GuilhemBichot on 2008-04-24
22
Affects Status Importance Assigned to Milestone
Bazaar
Undecided
Unassigned
Bazaar GTK+ Frontends
Undecided
Unassigned

Bug Description

When doing "bzr gcommit", after clicking "commit", I get a popup with title "Unknown error" and saying "float division".
I hacked a bit errors.py so that it prints a traceback to stdout (and REALLY, PLEASE, it would be nice if this was done by default) and the traceback is:
Traceback (most recent call last):
  File "/home/guilhem/.bazaar/plugins/gtk/errors.py", line 25, in convert
    unbound(*args, **kwargs)
  File "/home/guilhem/.bazaar/plugins/gtk/commit.py", line 643, in _on_commit_clicked
    self._do_commit()
  File "/home/guilhem/.bazaar/plugins/gtk/commit.py", line 686, in _do_commit
    revprops=revprops)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/workingtree_4.py", line 246, in commit
    result = WorkingTree3.commit(self, message, revprops, *args, **kwargs)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/decorators.py", line 165, in write_locked
    return unbound(self, *args, **kwargs)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/mutabletree.py", line 187, in commit
    revprops=revprops, *args, **kwargs)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/commit.py", line 373, in commit
    self.rev_id = self.builder.commit(self.message)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repository.py", line 139, in commit
    self.repository.commit_write_group()
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repository.py", line 919, in commit_write_group
    self._commit_write_group()
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 2013, in _commit_write_group
    return self._pack_collection._commit_write_group()
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 1666, in _commit_write_group
    if not self.autopack():
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 1231, in autopack
    self._execute_pack_operations(pack_operations)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 1245, in _execute_pack_operations
    _packer_class(self, packs, '.autopack').pack()
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 589, in pack
    return self._create_pack_from_packs()
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 732, in _create_pack_from_packs
    new_pack.signature_index)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 752, in _copy_nodes
    write_index, pb)
  File "/usr/local/lib/python2.5/site-packages/bzrlib/repofmt/pack_repo.py", line 772, in _do_copy_nodes
    pb.update("Copied record", record_index, len(nodes))
  File "/home/guilhem/.bazaar/plugins/gtk/ui.py", line 63, in update
    self.set_fraction(1.0 * current / total)
ZeroDivisionError: float division

See: pb.update() passes len(nodes) (==0) for argument "total", so this code in ui.py line 63:
    def update(self, msg=None, current=None, total=None):
        if msg is not None:
            self.set_text(msg)
        if None not in (current, total):
            self.set_fraction(1.0 * current / total)
happily divides by 0.
There is nothing in .bzr.log, in my opinion this proves the usefulness of having show_bzr_error print the traceback to stdout if the error is unexpected. Something like this:
...
        except errors.BzrError, msg:
            error_dialog(_('Unknown bzr error'), str(msg))
            traceback.print_exc(file=sys.stdout)
        except errors.PermissionDenied:
            error_dialog(_("Permission denied"), _("permission denied."))
        except Exception, msg:
            error_dialog(_('Unknown error'), str(msg))
            traceback.print_exc(file=sys.stdout)

Aaron Bentley (abentley) wrote :

It's not rational to do "update(x, 0)", so the root bug is in Bazaar. But this can be worked around in bzr-gtk. Thus, I assign this to both.

(And I hope you mean stderr, not stdout)

GuilhemBichot (guilhem-bichot) wrote :

stderr would be better I agree. Thanks for looking into this.

Jelmer Vernooij (jelmer) wrote :

What version of bzr-gtk and bzr are you using?

GuilhemBichot (guilhem-bichot) wrote :

I originally had bzr 1.3 (according to "bzr version") and bzr-gtk 0.93.0. But I was hitting https://bugs.launchpad.net/bzr-gtk/+bug/214777 in "bzr gcommit". So, to get the fix for this, I installed the latest branch (as of today). Then I hit the present bug. So my combination is now:
bzr: 1.3
bzr-gtk: latest branch

GuilhemBichot (guilhem-bichot) wrote :

Two colleagues hit this bug in the last few days.

Adrian Wilkins (adrian-wilkins) wrote :

This is still an issue with the tip of bzr-gtk trunk and bzr 1.5.

The attached patch will fix it (probably not in the best way, but enough to be able to commit).

Elliot Murphy (statik) wrote :

proposed Adrian's patch to the bzr-gtk list for merging.

GuilhemBichot (guilhem-bichot) wrote :

one more colleague hit today.

GuilhemBichot wrote:
> one more colleague hit today.
>

This has now been merged. Sorry for the delay.

-elliot

Elliot Murphy (statik) on 2008-06-20
Changed in bzr-gtk:
status: New → Fix Committed
Jelmer Vernooij (jelmer) on 2008-08-04
Changed in bzr-gtk:
status: Fix Committed → Fix Released
Martin Pool (mbp) wrote :

Not a bug in bzr core.

Changed in bzr:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers