diff options
author | LaMont Jones <lamontjones@google.com> | 2022-12-01 21:17:15 +0000 |
---|---|---|
committer | LaMont Jones <lamontjones@google.com> | 2022-12-02 22:40:06 +0000 |
commit | 55b7125d6a4e9ff35bf45b8ea32fad9528a1a9d3 (patch) | |
tree | 57d2397772308b7fcf411176cf13d08d044dff67 | |
parent | d793553804c76677444709ebefd70f6e01c29525 (diff) | |
download | git-repo-55b7125d6a4e9ff35bf45b8ea32fad9528a1a9d3.tar.gz |
Revert "sync: save any cruft after calling git gc."
This bug-cacher related code is no longer needed.
This reverts commit 891e8f72ce3551a19c377456574bbfbeac5c8b8e.
Change-Id: Ia94a2690ff149427fdcafacd39f5008cd60827d5
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/353774
Reviewed-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Sam Saccone <samccone@google.com>
Tested-by: LaMont Jones <lamontjones@google.com>
-rw-r--r-- | subcmds/sync.py | 49 |
1 files changed, 4 insertions, 45 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index 5b41046d..8cd1bcac 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -21,7 +21,6 @@ import multiprocessing | |||
21 | import netrc | 21 | import netrc |
22 | from optparse import SUPPRESS_HELP | 22 | from optparse import SUPPRESS_HELP |
23 | import os | 23 | import os |
24 | import shutil | ||
25 | import socket | 24 | import socket |
26 | import sys | 25 | import sys |
27 | import tempfile | 26 | import tempfile |
@@ -66,9 +65,6 @@ from wrapper import Wrapper | |||
66 | from manifest_xml import GitcManifest | 65 | from manifest_xml import GitcManifest |
67 | 66 | ||
68 | _ONE_DAY_S = 24 * 60 * 60 | 67 | _ONE_DAY_S = 24 * 60 * 60 |
69 | # Env var to implicitly turn off object backups. | ||
70 | REPO_BACKUP_OBJECTS = 'REPO_BACKUP_OBJECTS' | ||
71 | _BACKUP_OBJECTS = os.environ.get(REPO_BACKUP_OBJECTS) != '0' | ||
72 | 68 | ||
73 | # Env var to implicitly turn auto-gc back on. This was added to allow a user to | 69 | # Env var to implicitly turn auto-gc back on. This was added to allow a user to |
74 | # revert a change in default behavior in v2.29.9, and will be removed in a | 70 | # revert a change in default behavior in v2.29.9, and will be removed in a |
@@ -740,33 +736,6 @@ later is required to fix a server side protocol bug. | |||
740 | callback=_ProcessResults, | 736 | callback=_ProcessResults, |
741 | output=Progress('Checking out', len(all_projects), quiet=opt.quiet)) and not err_results | 737 | output=Progress('Checking out', len(all_projects), quiet=opt.quiet)) and not err_results |
742 | 738 | ||
743 | def _backup_cruft(self, bare_git): | ||
744 | """Save a copy of any cruft from `git gc`.""" | ||
745 | # Find any cruft packs in the current gitdir, and save them. | ||
746 | # b/221065125 (repo sync complains that objects are missing). This does | ||
747 | # not prevent that state, but makes it so that the missing objects are | ||
748 | # available. | ||
749 | objdir = bare_git._project.objdir | ||
750 | pack_dir = os.path.join(objdir, 'pack') | ||
751 | bak_dir = os.path.join(objdir, '.repo', 'pack.bak') | ||
752 | if not _BACKUP_OBJECTS or not platform_utils.isdir(pack_dir): | ||
753 | return | ||
754 | files = set(platform_utils.listdir(pack_dir)) | ||
755 | to_backup = [] | ||
756 | for f in files: | ||
757 | base, ext = os.path.splitext(f) | ||
758 | if base + '.mtimes' in files: | ||
759 | to_backup.append(f) | ||
760 | if to_backup: | ||
761 | os.makedirs(bak_dir, exist_ok=True) | ||
762 | for fname in to_backup: | ||
763 | bak_fname = os.path.join(bak_dir, fname) | ||
764 | if not os.path.exists(bak_fname): | ||
765 | with Trace('%s saved %s', bare_git._project.name, fname): | ||
766 | # Use a tmp file so that we are sure of a complete copy. | ||
767 | shutil.copy(os.path.join(pack_dir, fname), bak_fname + '.tmp') | ||
768 | shutil.move(bak_fname + '.tmp', bak_fname) | ||
769 | |||
770 | @staticmethod | 739 | @staticmethod |
771 | def _GetPreciousObjectsState(project: Project, opt): | 740 | def _GetPreciousObjectsState(project: Project, opt): |
772 | """Get the preciousObjects state for the project. | 741 | """Get the preciousObjects state for the project. |
@@ -874,22 +843,14 @@ later is required to fix a server side protocol bug. | |||
874 | 843 | ||
875 | jobs = opt.jobs | 844 | jobs = opt.jobs |
876 | 845 | ||
877 | gc_args = ['--auto'] | ||
878 | backup_cruft = False | ||
879 | if git_require((2, 37, 0)): | ||
880 | gc_args.append('--cruft') | ||
881 | backup_cruft = True | ||
882 | pack_refs_args = () | ||
883 | if jobs < 2: | 846 | if jobs < 2: |
884 | for (run_gc, bare_git) in tidy_dirs.values(): | 847 | for (run_gc, bare_git) in tidy_dirs.values(): |
885 | pm.update(msg=bare_git._project.name) | 848 | pm.update(msg=bare_git._project.name) |
886 | 849 | ||
887 | if run_gc: | 850 | if run_gc: |
888 | bare_git.gc(*gc_args) | 851 | bare_git.gc('--auto') |
889 | else: | 852 | else: |
890 | bare_git.pack_refs(*pack_refs_args) | 853 | bare_git.pack_refs() |
891 | if backup_cruft: | ||
892 | self._backup_cruft(bare_git) | ||
893 | pm.end() | 854 | pm.end() |
894 | return | 855 | return |
895 | 856 | ||
@@ -904,17 +865,15 @@ later is required to fix a server side protocol bug. | |||
904 | try: | 865 | try: |
905 | try: | 866 | try: |
906 | if run_gc: | 867 | if run_gc: |
907 | bare_git.gc(*gc_args, config=config) | 868 | bare_git.gc('--auto', config=config) |
908 | else: | 869 | else: |
909 | bare_git.pack_refs(*pack_refs_args, config=config) | 870 | bare_git.pack_refs(config=config) |
910 | except GitError: | 871 | except GitError: |
911 | err_event.set() | 872 | err_event.set() |
912 | except Exception: | 873 | except Exception: |
913 | err_event.set() | 874 | err_event.set() |
914 | raise | 875 | raise |
915 | finally: | 876 | finally: |
916 | if backup_cruft: | ||
917 | self._backup_cruft(bare_git) | ||
918 | pm.finish(bare_git._project.name) | 877 | pm.finish(bare_git._project.name) |
919 | sem.release() | 878 | sem.release() |
920 | 879 | ||