D5063: churn: use integer division consistently

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sat Oct 13 10:06:55 UTC 2018


durin42 created this revision.
Herald added a reviewer: pulkit.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D5063

AFFECTED FILES
  contrib/python3-whitelist
  hgext/churn.py
  tests/test-churn.t

CHANGE DETAILS

diff --git a/tests/test-churn.t b/tests/test-churn.t
--- a/tests/test-churn.t
+++ b/tests/test-churn.t
@@ -52,7 +52,7 @@
 
   $ hg churn -r :2
   user2      2 ***************************************************************
-  user1      1 ********************************
+  user1      1 *******************************
   $ cd ..
 
 churn with aliases
@@ -83,36 +83,36 @@
 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
 
   $ 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)
 
 
 changeset number churn
 
   $ hg churn -c
   user1      4 ***************************************************************
   user3      3 ***********************************************
-  user2      2 ********************************
+  user2      2 *******************************
 
   $ echo 'with space = no-space' >> ../aliases
   $ echo a >> a
@@ -154,39 +154,39 @@
   [user4 at x.com]
   $ hg churn -c
   user1            4 *********************************************************
-  user3            3 *******************************************
-  user2            2 *****************************
-  user4 at x.com      2 *****************************
+  user3            3 ******************************************
+  user2            2 ****************************
+  user4 at x.com      2 ****************************
   with space       1 **************
 
 Test multibyte sequences in names
 
   $ echo bar >> bar
   $ hg --encoding utf-8 ci -m'changed bar' -u 'El Niño <nino at 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'
diff --git a/hgext/churn.py b/hgext/churn.py
--- a/hgext/churn.py
+++ b/hgext/churn.py
@@ -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))
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -67,6 +67,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



To: durin42, pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list