git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/2] git-p4: show progress as an integer

From
Joel Holdsworth <jholdsworth@nvidia.com>
Date
Dec 17, 2021, 20:38 UTC
Message-ID
<20211217203856.2339161-3-jholdsworth@nvidia.com>
In-Reply-To
<20211217203856.2339161-1-jholdsworth@nvidia.com>

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>
---
 git-p4.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/git-p4.py b/git-p4.py
index 4d8a249b85..3c621a6efd 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -3635,7 +3635,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
 
-- 
2.34.1
Previous: Luke DiamandNext: Luke Diamand
Message 5 of 7 in “git-p4: improve formatting of numeric values”
  1. 0/2 git-p4: improve formatting of numeric valuesJoel Holdsworth, Dec 17, 2021
  2. 1/2 git-p4: print size values in appropriate unitsJoel Holdsworth, Dec 17, 2021
  3. Joachim KuebartDec 18, 2021
  4. Luke DiamandDec 18, 2021
  5. 2/2 git-p4: show progress as an integerJoel Holdsworth, Dec 17, 2021
  6. Luke DiamandDec 18, 2021
  7. Junio C HamanoDec 20, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.