[PATCH stable] churn: issue833 was reintroduced in 9bc46d069a76, correct it and add a test
Nicolas Dumazet
nicdumz at gmail.com
Tue Aug 25 13:17:57 UTC 2009
# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1251110864 -7200
# Node ID 723cce983d5e4e7f1ae4c21d26d5aa12840b92d5
# Parent 3ac42ca1f3e617438c9fa3732678583ec6888bf6
churn: issue833 was reintroduced in 9bc46d069a76, correct it and add a test
diff --git a/hgext/churn.py b/hgext/churn.py
--- a/hgext/churn.py
+++ b/hgext/churn.py
@@ -146,7 +146,8 @@
sortfn = ((not opts.get('sort')) and (lambda a, b: cmp(b[1], a[1])) or None)
rate.sort(sortfn)
- 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
@@ -48,3 +48,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 --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 @@
09 2 *********************************
12 4 ******************************************************************
13 1 ****************
+adding foo
+test 0
More information about the Mercurial-devel
mailing list