diff mbox series

[v3,2/2] git-p4: show progress as an integer

Message ID 20220104124307.2524-3-jholdsworth@nvidia.com (mailing list archive)
State Accepted
Commit 0f829620e6f2ccc441aef1ffd6c0a546b949ee39
Headers show
Series git-p4: improve formatting of numeric values | expand

Commit Message

Joel Holdsworth Jan. 4, 2022, 12:43 p.m. UTC
When importing files from Perforce, git-p4 periodically logs the
progress of file transfers as a percentage. However, the value is
printed as a float with an excessive number of decimal places.

For example a typical update might contain the following message:

Importing revision 12345 (26.199617677553135%)

This patch simply rounds the value down to the nearest integer
percentage value, greatly improving readability.

Signed-off-by: Joel Holdsworth <jholdsworth@nvidia.com>
Acked-by: Luke Diamand <luke@diamand.org>
---
 git-p4.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/git-p4.py b/git-p4.py
index 74834736fa..a625077b83 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -3637,7 +3637,8 @@  def importChanges(self, changes, origin_revision=0):
             self.updateOptionDict(description)
 
             if not self.silent:
-                sys.stdout.write("\rImporting revision %s (%s%%)" % (change, cnt * 100 / len(changes)))
+                sys.stdout.write("\rImporting revision %s (%d%%)" % (
+                    change, (cnt * 100) // len(changes)))
                 sys.stdout.flush()
             cnt = cnt + 1