summaryrefslogtreecommitdiffstats
path: root/progress.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2019-08-26 15:32:06 -0400
committerMike Frysinger <vapier@google.com>2019-11-12 23:33:51 +0000
commit3538dd224d6d48c60b140103f25d94f0e5f76160 (patch)
tree37b3c16bec3b7d7228c3040ba800377ec068e077 /progress.py
parentb610b850ac2d791e193383dd77501565fca60aa4 (diff)
downloadgit-repo-3538dd224d6d48c60b140103f25d94f0e5f76160.tar.gz
sync: merge project updates with status bar
The current sync output displays "Fetching project" and "Checking out project" messages and progress bar updates independently leading to a lot of spam. Lets merge these periodic outputs with the status bar to get a little bit tighter output in the normal case. This doesn't solve all our problems, but gets us closer. Bug: https://crbug.com/gerrit/11293 Change-Id: Icd627830af4dd934a9355b7ace754b56dc96cfef Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/244934 Reviewed-by: David Pursehouse <dpursehouse@collab.net> Tested-by: Mike Frysinger <vapier@google.com>
Diffstat (limited to 'progress.py')
-rw-r--r--progress.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/progress.py b/progress.py
index 1eff04ac..d2ed4bae 100644
--- a/progress.py
+++ b/progress.py
@@ -39,7 +39,7 @@ class Progress(object):
39 self._print_newline = print_newline 39 self._print_newline = print_newline
40 self._always_print_percentage = always_print_percentage 40 self._always_print_percentage = always_print_percentage
41 41
42 def update(self, inc=1): 42 def update(self, inc=1, msg=''):
43 self._done += inc 43 self._done += inc
44 44
45 if _NOT_TTY or IsTrace(): 45 if _NOT_TTY or IsTrace():
@@ -62,12 +62,13 @@ class Progress(object):
62 62
63 if self._lastp != p or self._always_print_percentage: 63 if self._lastp != p or self._always_print_percentage:
64 self._lastp = p 64 self._lastp = p
65 sys.stderr.write('%s\r%s: %3d%% (%d%s/%d%s)%s' % ( 65 sys.stderr.write('%s\r%s: %3d%% (%d%s/%d%s)%s%s%s' % (
66 CSI_ERASE_LINE, 66 CSI_ERASE_LINE,
67 self._title, 67 self._title,
68 p, 68 p,
69 self._done, self._units, 69 self._done, self._units,
70 self._total, self._units, 70 self._total, self._units,
71 ' ' if msg else '', msg,
71 "\n" if self._print_newline else "")) 72 "\n" if self._print_newline else ""))
72 sys.stderr.flush() 73 sys.stderr.flush()
73 74