mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
sync: cleanup output when not doing GC
Do not use a progress bar when not doing GC, and restrict activity in that case to only repairing preciousObject state. This also includes additional cleanup based on review comments from previous changes. Change-Id: I48581c9d25da358bc7ae15f40e98d55bec142331 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353514 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
55b7125d6a
commit
43549d8d08
@ -775,19 +775,18 @@ later is required to fix a server side protocol bug.
|
||||
print(f'\r{relpath}: project not found in manifest.', file=sys.stderr)
|
||||
return False
|
||||
|
||||
def _RepairPreciousObjectsState(self, project: Project, opt):
|
||||
def _SetPreciousObjectsState(self, project: Project, opt):
|
||||
"""Correct the preciousObjects state for the project.
|
||||
|
||||
Args:
|
||||
project (Project): the project to examine, and possibly correct.
|
||||
opt (optparse.Values): options given to sync.
|
||||
project: the project to examine, and possibly correct.
|
||||
opt: options given to sync.
|
||||
"""
|
||||
expected = self._GetPreciousObjectsState(project, opt)
|
||||
actual = project.config.GetBoolean('extensions.preciousObjects') or False
|
||||
relpath = project.RelPath(local = opt.this_manifest_only)
|
||||
relpath = project.RelPath(local=opt.this_manifest_only)
|
||||
|
||||
if (expected != actual and
|
||||
not project.config.GetBoolean('repo.preservePreciousObjects')):
|
||||
if expected != actual:
|
||||
# If this is unexpected, log it and repair.
|
||||
Trace(f'{relpath} expected preciousObjects={expected}, got {actual}')
|
||||
if expected:
|
||||
@ -816,13 +815,19 @@ later is required to fix a server side protocol bug.
|
||||
to potentially mark objects precious, so that `git gc` does not discard
|
||||
shared objects.
|
||||
"""
|
||||
pm = Progress(f'{"" if opt.auto_gc else "NOT "}Garbage collecting',
|
||||
len(projects), delay=False, quiet=opt.quiet)
|
||||
if not opt.auto_gc:
|
||||
# Just repair preciousObjects state, and return.
|
||||
for project in projects:
|
||||
self._SetPreciousObjectsState(project, opt)
|
||||
return
|
||||
|
||||
pm = Progress('Garbage collecting', len(projects), delay=False,
|
||||
quiet=opt.quiet)
|
||||
pm.update(inc=0, msg='prescan')
|
||||
|
||||
tidy_dirs = {}
|
||||
for project in projects:
|
||||
self._RepairPreciousObjectsState(project, opt)
|
||||
self._SetPreciousObjectsState(project, opt)
|
||||
|
||||
project.config.SetString('gc.autoDetach', 'false')
|
||||
# Only call git gc once per objdir, but call pack-refs for the remainder.
|
||||
@ -837,10 +842,6 @@ later is required to fix a server side protocol bug.
|
||||
project.bare_git,
|
||||
)
|
||||
|
||||
if not opt.auto_gc:
|
||||
pm.end()
|
||||
return
|
||||
|
||||
jobs = opt.jobs
|
||||
|
||||
if jobs < 2:
|
||||
|
Loading…
Reference in New Issue
Block a user