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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 3, 2020 at 10:11 AM Yang Zhao <yang.zhao@xxxxxxxxxxxxxx> wrote:
>
> On Mon, Feb 3, 2020 at 4:54 AM Luke Diamand <luke@xxxxxxxxxxx> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux