churn: use integer division consistently
This results in slight output changes, but it's at least consistent
between Python 2 and 3. Since the output is just bar graphs anyway,
I'm content with the changes.
Differential Revision: https://phab.mercurial-scm.org/D5063
--- a/contrib/python3-whitelist Sat Oct 13 05:58:16 2018 -0400
+++ b/contrib/python3-whitelist Sat Oct 13 06:02:27 2018 -0400
@@ -66,6 +66,7 @@
test-check-pylint.t
test-check-shbang.t
test-children.t
+test-churn.t
test-clone-cgi.t
test-clone-pull-corruption.t
test-clone-r.t
--- a/hgext/churn.py Sat Oct 13 05:58:16 2018 -0400
+++ b/hgext/churn.py Sat Oct 13 06:02:27 2018 -0400
@@ -8,7 +8,7 @@
'''command to display statistics about repository history'''
-from __future__ import absolute_import
+from __future__ import absolute_import, division
import datetime
import os
@@ -205,7 +205,7 @@
'*' * charnum(sum(count)))
def charnum(count):
- return int(round(count * width / maxcount))
+ return int(round(count * width // maxcount))
for name, count in rate:
ui.write(format(name, count))
--- a/tests/test-churn.t Sat Oct 13 05:58:16 2018 -0400
+++ b/tests/test-churn.t Sat Oct 13 06:02:27 2018 -0400
@@ -52,7 +52,7 @@
$ hg churn -r :2
user2 2 ***************************************************************
- user1 1 ********************************
+ user1 1 *******************************
$ cd ..
churn with aliases
@@ -83,10 +83,10 @@
churn by hour
$ hg churn -f '%H' -s
- 06 1 *****************
+ 06 1 ****************
09 2 *********************************
12 4 ******************************************************************
- 13 1 *****************
+ 13 1 ****************
churn with separated added/removed lines
@@ -94,16 +94,16 @@
$ hg rm d/g/f2.txt
$ hg ci -Am "removed d/g/f2.txt" -u user1 -d 14:00 d/g/f2.txt
$ hg churn --diffstat
- user1 +3/-1 +++++++++++++++++++++++++++++++++++++++++--------------
- user3 +3/-0 +++++++++++++++++++++++++++++++++++++++++
+ user1 +3/-1 ++++++++++++++++++++++++++++++++++++++++-------------
+ user3 +3/-0 ++++++++++++++++++++++++++++++++++++++++
user2 +2/-0 +++++++++++++++++++++++++++
churn --diffstat with color
$ hg --config extensions.color= churn --config color.mode=ansi \
> --diffstat --color=always
- user1 +3/-1 \x1b[0;32m+++++++++++++++++++++++++++++++++++++++++\x1b[0m\x1b[0;31m--------------\x1b[0m (esc)
- user3 +3/-0 \x1b[0;32m+++++++++++++++++++++++++++++++++++++++++\x1b[0m (esc)
+ user1 +3/-1 \x1b[0;32m++++++++++++++++++++++++++++++++++++++++\x1b[0m\x1b[0;31m-------------\x1b[0m (esc)
+ user3 +3/-0 \x1b[0;32m++++++++++++++++++++++++++++++++++++++++\x1b[0m (esc)
user2 +2/-0 \x1b[0;32m+++++++++++++++++++++++++++\x1b[0m (esc)
@@ -112,7 +112,7 @@
$ hg churn -c
user1 4 ***************************************************************
user3 3 ***********************************************
- user2 2 ********************************
+ user2 2 *******************************
$ echo 'with space = no-space' >> ../aliases
$ echo a >> a
@@ -154,9 +154,9 @@
[user4@x.com]
$ hg churn -c
user1 4 *********************************************************
- user3 3 *******************************************
- user2 2 *****************************
- user4@x.com 2 *****************************
+ user3 3 ******************************************
+ user2 2 ****************************
+ user4@x.com 2 ****************************
with space 1 **************
Test multibyte sequences in names
@@ -165,28 +165,28 @@
$ hg --encoding utf-8 ci -m'changed bar' -u 'El NiƱo <nino@x.com>'
$ hg --encoding utf-8 churn -ct '{author|person}'
user1 4 **********************************************************
- user3 3 ********************************************
+ user3 3 *******************************************
user2 2 *****************************
user4 2 *****************************
- El Ni\xc3\xb1o 1 *************** (esc)
- with space 1 ***************
+ El Ni\xc3\xb1o 1 ************** (esc)
+ with space 1 **************
Test --template argument, with backwards compatibility
$ hg churn -t '{author|user}'
user1 4 ***************************************************************
user3 3 ***********************************************
- user2 2 ********************************
- nino 1 ****************
- with 1 ****************
+ user2 2 *******************************
+ nino 1 ***************
+ with 1 ***************
0
user4 0
$ hg churn -T '{author|user}'
user1 4 ***************************************************************
user3 3 ***********************************************
- user2 2 ********************************
- nino 1 ****************
- with 1 ****************
+ user2 2 *******************************
+ nino 1 ***************
+ with 1 ***************
0
user4 0
$ hg churn -t 'alltogether'