# HG changeset patch # User Dirkjan Ochtman # Date 1251284751 -7200 # Node ID 7cca980317c5d99301679efae279f524c37ef0eb # Parent 20ed9909dbd9251f76cacb463c480488eebf736b# Parent f7968bba2307e25ba8d8731ca43e990b6e6ea0a3 merge with crew-stable diff -r 20ed9909dbd9 -r 7cca980317c5 hgext/churn.py --- a/hgext/churn.py Sat Aug 22 19:40:15 2009 +0200 +++ b/hgext/churn.py Wed Aug 26 13:05:51 2009 +0200 @@ -148,7 +148,8 @@ 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 -r 20ed9909dbd9 -r 7cca980317c5 tests/test-churn --- a/tests/test-churn Sat Aug 22 19:40:15 2009 +0200 +++ b/tests/test-churn Wed Aug 26 13:05:51 2009 +0200 @@ -50,3 +50,13 @@ 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 -r 20ed9909dbd9 -r 7cca980317c5 tests/test-churn.out --- a/tests/test-churn.out Sat Aug 22 19:40:15 2009 +0200 +++ b/tests/test-churn.out Wed Aug 26 13:05:51 2009 +0200 @@ -28,3 +28,5 @@ 09 2 ********************************* 12 4 ****************************************************************** 13 1 **************** +adding foo +test 0