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

Re: [PATCH v2 00/14] git-p4: python3 compatibility

From
Yang Zhao <yang.zhao@skyboxlabs.com>
Date
Feb 4, 2020, 01:35 UTC
Message-ID
<CABvFv3KPZ9ibx9+WDkgWJ9Zn1_VyuoX_KiOPxYSvL2AwRVsMxg@mail.gmail.com>
In-Reply-To
<CABvFv3KcpmCXsM2hSaHTzrb0Lz9BAD23sVcNsjO4uf8xCLDh5g@mail.gmail.com>
On Mon, Feb 3, 2020 at 10:11 AM Yang Zhao <yang.zhao@skyboxlabs.com> wrote:
Show 19 quoted lines
>
> On Mon, Feb 3, 2020 at 4:54 AM Luke Diamand <luke@diamand.org> wrote:
> > One very small bug report:
> >
> > When doing "git p4 sync" it prints out the percent complete. It looks
> > like it's no longer rounding it sensibly, so where before it would say
> > 77%, now it says 77.7777777%.
> >
> > It's this line:
> >
> >    sys.stdout.write("\rImporting revision %s (%s%%)" % (change, cnt *
> > 100 / len(changes)))
> >
> > I think / just needs replacing with //.
>
> Good catch.
>
> The patch below should do the trick, and be more explicit about how
> we're formatting things.
Oops, missed a line. Below is more correct (pardon the webmail patch clobbering)
diff --git a/git-p4.py b/git-p4.py
index ca0a874501..da3a5aa684 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -2959,8 +2959,8 @@ def streamP4FilesCb(self, marshalled):
             'depotFile' in self.stream_file):
             size = int(self.stream_file["fileSize"])
             if size > 0:
-                progress = 100*self.stream_file['streamContentSize']/size
-                sys.stdout.write('\r%s %d%% (%i MB)' %
(self.stream_file['depotFile'], progress, int(size/1024/1024)))
+                progress = self.stream_file['streamContentSize']/size
+                sys.stdout.write('\r{} {:.0%} ({}
MB)'.format(self.stream_file['depotFile'], progress,
int(size/1024/1024)))
                 sys.stdout.flush()

         self.stream_have_file_info = True
@@ -3435,7 +3435,7 @@ 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 {}
({:.0%})".format(change, cnt / len(changes)))
                 sys.stdout.flush()
             cnt = cnt + 1
Previous: Yang ZhaoNext: Yang Zhao
Message 7 of 22 in “git-p4: python3 compatibility”
  1. 00/14 git-p4: python3 compatibilityYang Zhao, Dec 13, 2019
  2. Yang ZhaoJan 17, 2020
  3. Luke DiamandJan 24, 2020
  4. Luke DiamandJan 30, 2020
  5. Luke DiamandFeb 3, 2020
  6. Yang ZhaoFeb 3, 2020
  7. Yang ZhaoFeb 4, 2020
  8. 01/14 git-p4: make python2.7 the oldest supported versionYang Zhao, Dec 13, 2019
  9. 02/14 git-p4: change the expansion test from basestring to listYang Zhao, Dec 13, 2019
  10. 05/14 git-p4: encode/decode communication with git for python3Yang Zhao, Dec 13, 2019
  11. 03/14 git-p4: remove string type aliasingYang Zhao, Dec 13, 2019
  12. 04/14 git-p4: encode/decode communication with p4 for python3Yang Zhao, Dec 13, 2019
  13. Junio C HamanoDec 17, 2019
  14. 08/14 git-p4: use marshal format version 2 when sending to p4Yang Zhao, Dec 13, 2019
  15. 07/14 git-p4: open .gitp4-usercache.txt in text modeYang Zhao, Dec 13, 2019
  16. 06/14 git-p4: convert path to unicode before processing themYang Zhao, Dec 13, 2019
  17. 09/14 git-p4: fix freezing while waiting for fast-import progressYang Zhao, Dec 13, 2019
  18. 10/14 git-p4: use functools.reduce instead of reduceYang Zhao, Dec 13, 2019
  19. 12/14 git-p4: simplify regex pattern generation for parsing diff-treeYang Zhao, Dec 13, 2019
  20. 11/14 git-p4: use dict.items() iteration for python3 compatibilityYang Zhao, Dec 13, 2019
  21. 14/14 ci: also run linux-gcc pipeline with python3.5 environmentYang Zhao, Dec 13, 2019
  22. 13/14 git-p4: use python3's input() everywhereYang Zhao, Dec 13, 2019

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.