summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <dpursehouse@collab.net>2017-08-02 07:01:08 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-08-02 07:01:08 +0000
commit8a6eeed7f5ba12f0aaa0fc9f62063a88039234d4 (patch)
tree89994e0e6a21839532385f029b1784e09a5b9c27
parent3bcd30545e58bc5d6932c9390e8909d57a836617 (diff)
parent7be072efa6522a94ee0bab16539a442cc4713d65 (diff)
downloadgit-repo-8a6eeed7f5ba12f0aaa0fc9f62063a88039234d4.tar.gz
Merge "Always print percentage when syncing quietly"
-rw-r--r--progress.py6
-rw-r--r--subcmds/sync.py3
2 files changed, 6 insertions, 3 deletions
diff --git a/progress.py b/progress.py
index b08f52e5..0dd5d1a8 100644
--- a/progress.py
+++ b/progress.py
@@ -21,7 +21,8 @@ from trace import IsTrace
21_NOT_TTY = not os.isatty(2) 21_NOT_TTY = not os.isatty(2)
22 22
23class Progress(object): 23class Progress(object):
24 def __init__(self, title, total=0, units='', print_newline=False): 24 def __init__(self, title, total=0, units='', print_newline=False,
25 always_print_percentage=False):
25 self._title = title 26 self._title = title
26 self._total = total 27 self._total = total
27 self._done = 0 28 self._done = 0
@@ -30,6 +31,7 @@ class Progress(object):
30 self._show = False 31 self._show = False
31 self._units = units 32 self._units = units
32 self._print_newline = print_newline 33 self._print_newline = print_newline
34 self._always_print_percentage = always_print_percentage
33 35
34 def update(self, inc=1): 36 def update(self, inc=1):
35 self._done += inc 37 self._done += inc
@@ -51,7 +53,7 @@ class Progress(object):
51 else: 53 else:
52 p = (100 * self._done) / self._total 54 p = (100 * self._done) / self._total
53 55
54 if self._lastp != p: 56 if self._lastp != p or self._always_print_percentage:
55 self._lastp = p 57 self._lastp = p
56 sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % ( 58 sys.stderr.write('\r%s: %3d%% (%d%s/%d%s)%s' % (
57 self._title, 59 self._title,
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 8a043d9f..8de730bc 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -357,7 +357,8 @@ later is required to fix a server side protocol bug.
357 fetched = set() 357 fetched = set()
358 lock = _threading.Lock() 358 lock = _threading.Lock()
359 pm = Progress('Fetching projects', len(projects), 359 pm = Progress('Fetching projects', len(projects),
360 print_newline=not(opt.quiet)) 360 print_newline=not(opt.quiet),
361 always_print_percentage=opt.quiet)
361 362
362 objdir_project_map = dict() 363 objdir_project_map = dict()
363 for project in projects: 364 for project in projects: