summaryrefslogtreecommitdiffstats
path: root/subcmds/sync.py
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2022-11-30 19:55:30 +0000
committerLaMont Jones <lamontjones@google.com>2022-12-02 22:50:23 +0000
commit43549d8d08ed206c1c5cb85bd6884d3bfd344d4c (patch)
tree9345aab9913749206044c084060234a183d6f242 /subcmds/sync.py
parent55b7125d6a4e9ff35bf45b8ea32fad9528a1a9d3 (diff)
downloadgit-repo-43549d8d08ed206c1c5cb85bd6884d3bfd344d4c.tar.gz
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>
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r--subcmds/sync.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py
index 8cd1bcac..75512031 100644
--- a/subcmds/sync.py
+++ b/subcmds/sync.py
@@ -775,19 +775,18 @@ later is required to fix a server side protocol bug.
775 print(f'\r{relpath}: project not found in manifest.', file=sys.stderr) 775 print(f'\r{relpath}: project not found in manifest.', file=sys.stderr)
776 return False 776 return False
777 777
778 def _RepairPreciousObjectsState(self, project: Project, opt): 778 def _SetPreciousObjectsState(self, project: Project, opt):
779 """Correct the preciousObjects state for the project. 779 """Correct the preciousObjects state for the project.
780 780
781 Args: 781 Args:
782 project (Project): the project to examine, and possibly correct. 782 project: the project to examine, and possibly correct.
783 opt (optparse.Values): options given to sync. 783 opt: options given to sync.
784 """ 784 """
785 expected = self._GetPreciousObjectsState(project, opt) 785 expected = self._GetPreciousObjectsState(project, opt)
786 actual = project.config.GetBoolean('extensions.preciousObjects') or False 786 actual = project.config.GetBoolean('extensions.preciousObjects') or False
787 relpath = project.RelPath(local = opt.this_manifest_only) 787 relpath = project.RelPath(local=opt.this_manifest_only)
788 788
789 if (expected != actual and 789 if expected != actual:
790 not project.config.GetBoolean('repo.preservePreciousObjects')):
791 # If this is unexpected, log it and repair. 790 # If this is unexpected, log it and repair.
792 Trace(f'{relpath} expected preciousObjects={expected}, got {actual}') 791 Trace(f'{relpath} expected preciousObjects={expected}, got {actual}')
793 if expected: 792 if expected:
@@ -816,13 +815,19 @@ later is required to fix a server side protocol bug.
816 to potentially mark objects precious, so that `git gc` does not discard 815 to potentially mark objects precious, so that `git gc` does not discard
817 shared objects. 816 shared objects.
818 """ 817 """
819 pm = Progress(f'{"" if opt.auto_gc else "NOT "}Garbage collecting', 818 if not opt.auto_gc:
820 len(projects), delay=False, quiet=opt.quiet) 819 # Just repair preciousObjects state, and return.
820 for project in projects:
821 self._SetPreciousObjectsState(project, opt)
822 return
823
824 pm = Progress('Garbage collecting', len(projects), delay=False,
825 quiet=opt.quiet)
821 pm.update(inc=0, msg='prescan') 826 pm.update(inc=0, msg='prescan')
822 827
823 tidy_dirs = {} 828 tidy_dirs = {}
824 for project in projects: 829 for project in projects:
825 self._RepairPreciousObjectsState(project, opt) 830 self._SetPreciousObjectsState(project, opt)
826 831
827 project.config.SetString('gc.autoDetach', 'false') 832 project.config.SetString('gc.autoDetach', 'false')
828 # Only call git gc once per objdir, but call pack-refs for the remainder. 833 # 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.
837 project.bare_git, 842 project.bare_git,
838 ) 843 )
839 844
840 if not opt.auto_gc:
841 pm.end()
842 return
843
844 jobs = opt.jobs 845 jobs = opt.jobs
845 846
846 if jobs < 2: 847 if jobs < 2: