diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -148,7 +148,8 @@ def churn(ui, repo, *pats, **opts): sortkey = ((not opts.get('sort')) and (lambda x: -x[1]) or None) rate.sort(key=sortkey) - maxcount = float(max([v for k, v in rate])) + # Be careful not to have a zero maxcount (issue833) + maxcount = float(max([v for k, v in rate])) or 1.0 maxname = max([len(k) for k, v in rate]) ttywidth = util.termwidth() diff --git a/tests/test-churn b/tests/test-churn --- a/tests/test-churn +++ b/tests/test-churn @@ -50,3 +50,13 @@ COLUMNS=40 hg churn echo % churn by hour hg churn -f '%H' -s +cd .. + +# issue 833: ZeroDivisionError +hg init issue-833 +cd issue-833 +touch foo +hg ci -Am foo +# this was failing with a ZeroDivisionError +hg churn +cd .. diff --git a/tests/test-churn.out b/tests/test-churn.out --- a/tests/test-churn.out +++ b/tests/test-churn.out @@ -28,3 +28,5 @@ 06 1 **************** 09 2 ********************************* 12 4 ****************************************************************** 13 1 **************** +adding foo +test 0