mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
progress: hide progress bar when --quiet
We want progress bars in the default output mode, but not when the user specifies --quiet. Add a setting to the Progress bar class so it takes care of not displaying anything itself rather than having to update every subcommand to conditionally setup & call the object. Change-Id: I1134993bffc5437bc22e26be11a512125f10597f Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/303225 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
9180a07b8f
commit
151701e85f
10
progress.py
10
progress.py
@ -42,7 +42,8 @@ def duration_str(total):
|
||||
|
||||
|
||||
class Progress(object):
|
||||
def __init__(self, title, total=0, units='', print_newline=False, delay=True):
|
||||
def __init__(self, title, total=0, units='', print_newline=False, delay=True,
|
||||
quiet=False):
|
||||
self._title = title
|
||||
self._total = total
|
||||
self._done = 0
|
||||
@ -54,6 +55,13 @@ class Progress(object):
|
||||
self._show_jobs = False
|
||||
self._active = 0
|
||||
|
||||
# When quiet, never show any output. It's a bit hacky, but reusing the
|
||||
# existing logic that delays initial output keeps the rest of the class
|
||||
# clean. Basically we set the start time to years in the future.
|
||||
if quiet:
|
||||
self._show = False
|
||||
self._start += 2**32
|
||||
|
||||
def start(self, name):
|
||||
self._active += 1
|
||||
if not self._show_jobs:
|
||||
|
@ -81,7 +81,7 @@ It is equivalent to "git branch -D <branchname>".
|
||||
err[branch].append(project)
|
||||
pm.update()
|
||||
|
||||
pm = Progress('Abandon %s' % nb, len(all_projects))
|
||||
pm = Progress('Abandon %s' % nb, len(all_projects), quiet=opt.quiet)
|
||||
# NB: Multiprocessing is heavy, so don't spin it up for one job.
|
||||
if len(all_projects) == 1 or opt.jobs == 1:
|
||||
_ProcessResults(self._ExecuteOne(opt, nb, x) for x in all_projects)
|
||||
|
@ -59,7 +59,7 @@ The command is equivalent to:
|
||||
err.append(project)
|
||||
pm.update()
|
||||
|
||||
pm = Progress('Checkout %s' % nb, len(all_projects))
|
||||
pm = Progress('Checkout %s' % nb, len(all_projects), quiet=opt.quiet)
|
||||
# NB: Multiprocessing is heavy, so don't spin it up for one job.
|
||||
if len(all_projects) == 1 or opt.jobs == 1:
|
||||
_ProcessResults(self._ExecuteOne(nb, x) for x in all_projects)
|
||||
|
@ -106,7 +106,7 @@ revision specified in the manifest.
|
||||
if not os.path.exists(os.getcwd()):
|
||||
os.chdir(self.manifest.topdir)
|
||||
|
||||
pm = Progress('Syncing %s' % nb, len(all_projects))
|
||||
pm = Progress('Syncing %s' % nb, len(all_projects), quiet=opt.quiet)
|
||||
for project in all_projects:
|
||||
gitc_project = self.gitc_manifest.paths[project.relpath]
|
||||
# Sync projects that have not been opened.
|
||||
@ -129,7 +129,7 @@ revision specified in the manifest.
|
||||
err.append(project)
|
||||
pm.update()
|
||||
|
||||
pm = Progress('Starting %s' % nb, len(all_projects))
|
||||
pm = Progress('Starting %s' % nb, len(all_projects), quiet=opt.quiet)
|
||||
# NB: Multiprocessing is heavy, so don't spin it up for one job.
|
||||
if len(all_projects) == 1 or opt.jobs == 1:
|
||||
_ProcessResults(self._ExecuteOne(opt, nb, x) for x in all_projects)
|
||||
|
@ -367,7 +367,7 @@ later is required to fix a server side protocol bug.
|
||||
|
||||
jobs = opt.jobs_network if opt.jobs_network else self.jobs
|
||||
fetched = set()
|
||||
pm = Progress('Fetching', len(projects), delay=False)
|
||||
pm = Progress('Fetching', len(projects), delay=False, quiet=opt.quiet)
|
||||
|
||||
objdir_project_map = dict()
|
||||
for project in projects:
|
||||
@ -470,7 +470,7 @@ later is required to fix a server side protocol bug.
|
||||
# Only checkout projects with worktrees.
|
||||
all_projects = [x for x in all_projects if x.worktree]
|
||||
|
||||
pm = Progress('Checking out', len(all_projects))
|
||||
pm = Progress('Checking out', len(all_projects), quiet=opt.quiet)
|
||||
|
||||
def _ProcessResults(results):
|
||||
for (success, project, start, finish) in results:
|
||||
@ -504,7 +504,7 @@ later is required to fix a server side protocol bug.
|
||||
return ret and not err_results
|
||||
|
||||
def _GCProjects(self, projects, opt, err_event):
|
||||
pm = Progress('Garbage collecting', len(projects), delay=False)
|
||||
pm = Progress('Garbage collecting', len(projects), delay=False, quiet=opt.quiet)
|
||||
pm.update(inc=0, msg='prescan')
|
||||
|
||||
gc_gitdirs = {}
|
||||
|
Loading…
Reference in New Issue
Block a user