diff options
author | Tomasz Wasilczyk <twasilczyk@google.com> | 2023-12-08 13:42:17 -0800 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-12-08 23:08:46 +0000 |
commit | 4c80921d22c20a28d531c9e3e8a0ce4433c6509d (patch) | |
tree | 583b21bce8c6b6be7a078d02eb11569dc7321699 | |
parent | f56484c05b545b7b798e025971673f9593dcc51c (diff) | |
download | git-repo-4c80921d22c20a28d531c9e3e8a0ce4433c6509d.tar.gz |
Don't log spam `repo sync` by defaultv2.40
Most times a repo sync after some time (week+) results in a bunch of
messages, which are not very useful for average user:
- discarding 1 commits
- Deleting obsolete checkout.
Bug: N/A
Test: repo sync
Change-Id: I881eab61f9f261e98f3656c09e73ddd159ce288c
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/397038
Reviewed-by: Josip Sokcevic <sokcevic@google.com>
Commit-Queue: Josip Sokcevic <sokcevic@google.com>
Tested-by: Tomasz Wasilczyk <twasilczyk@google.com>
-rw-r--r-- | project.py | 23 | ||||
-rw-r--r-- | subcmds/sync.py | 14 |
2 files changed, 23 insertions, 14 deletions
@@ -1467,7 +1467,12 @@ class Project: | |||
1467 | self.revisionId = revisionId | 1467 | self.revisionId = revisionId |
1468 | 1468 | ||
1469 | def Sync_LocalHalf( | 1469 | def Sync_LocalHalf( |
1470 | self, syncbuf, force_sync=False, submodules=False, errors=None | 1470 | self, |
1471 | syncbuf, | ||
1472 | force_sync=False, | ||
1473 | submodules=False, | ||
1474 | errors=None, | ||
1475 | verbose=False, | ||
1471 | ): | 1476 | ): |
1472 | """Perform only the local IO portion of the sync process. | 1477 | """Perform only the local IO portion of the sync process. |
1473 | 1478 | ||
@@ -1548,7 +1553,7 @@ class Project: | |||
1548 | return | 1553 | return |
1549 | else: | 1554 | else: |
1550 | lost = self._revlist(not_rev(revid), HEAD) | 1555 | lost = self._revlist(not_rev(revid), HEAD) |
1551 | if lost: | 1556 | if lost and verbose: |
1552 | syncbuf.info(self, "discarding %d commits", len(lost)) | 1557 | syncbuf.info(self, "discarding %d commits", len(lost)) |
1553 | 1558 | ||
1554 | try: | 1559 | try: |
@@ -1738,7 +1743,7 @@ class Project: | |||
1738 | self.bare_git.rev_parse("FETCH_HEAD"), | 1743 | self.bare_git.rev_parse("FETCH_HEAD"), |
1739 | ) | 1744 | ) |
1740 | 1745 | ||
1741 | def DeleteWorktree(self, quiet=False, force=False): | 1746 | def DeleteWorktree(self, verbose=False, force=False): |
1742 | """Delete the source checkout and any other housekeeping tasks. | 1747 | """Delete the source checkout and any other housekeeping tasks. |
1743 | 1748 | ||
1744 | This currently leaves behind the internal .repo/ cache state. This | 1749 | This currently leaves behind the internal .repo/ cache state. This |
@@ -1747,7 +1752,7 @@ class Project: | |||
1747 | at some point. | 1752 | at some point. |
1748 | 1753 | ||
1749 | Args: | 1754 | Args: |
1750 | quiet: Whether to hide normal messages. | 1755 | verbose: Whether to show verbose messages. |
1751 | force: Always delete tree even if dirty. | 1756 | force: Always delete tree even if dirty. |
1752 | 1757 | ||
1753 | Returns: | 1758 | Returns: |
@@ -1768,7 +1773,7 @@ class Project: | |||
1768 | logger.error(msg) | 1773 | logger.error(msg) |
1769 | raise DeleteDirtyWorktreeError(msg, project=self) | 1774 | raise DeleteDirtyWorktreeError(msg, project=self) |
1770 | 1775 | ||
1771 | if not quiet: | 1776 | if verbose: |
1772 | print(f"{self.RelPath(local=False)}: Deleting obsolete checkout.") | 1777 | print(f"{self.RelPath(local=False)}: Deleting obsolete checkout.") |
1773 | 1778 | ||
1774 | # Unlock and delink from the main worktree. We don't use git's worktree | 1779 | # Unlock and delink from the main worktree. We don't use git's worktree |
@@ -3900,13 +3905,13 @@ class RepoProject(MetaProject): | |||
3900 | class ManifestProject(MetaProject): | 3905 | class ManifestProject(MetaProject): |
3901 | """The MetaProject for manifests.""" | 3906 | """The MetaProject for manifests.""" |
3902 | 3907 | ||
3903 | def MetaBranchSwitch(self, submodules=False): | 3908 | def MetaBranchSwitch(self, submodules=False, verbose=False): |
3904 | """Prepare for manifest branch switch.""" | 3909 | """Prepare for manifest branch switch.""" |
3905 | 3910 | ||
3906 | # detach and delete manifest branch, allowing a new | 3911 | # detach and delete manifest branch, allowing a new |
3907 | # branch to take over | 3912 | # branch to take over |
3908 | syncbuf = SyncBuffer(self.config, detach_head=True) | 3913 | syncbuf = SyncBuffer(self.config, detach_head=True) |
3909 | self.Sync_LocalHalf(syncbuf, submodules=submodules) | 3914 | self.Sync_LocalHalf(syncbuf, submodules=submodules, verbose=verbose) |
3910 | syncbuf.Finish() | 3915 | syncbuf.Finish() |
3911 | 3916 | ||
3912 | return ( | 3917 | return ( |
@@ -4437,10 +4442,10 @@ class ManifestProject(MetaProject): | |||
4437 | return False | 4442 | return False |
4438 | 4443 | ||
4439 | if manifest_branch: | 4444 | if manifest_branch: |
4440 | self.MetaBranchSwitch(submodules=submodules) | 4445 | self.MetaBranchSwitch(submodules=submodules, verbose=verbose) |
4441 | 4446 | ||
4442 | syncbuf = SyncBuffer(self.config) | 4447 | syncbuf = SyncBuffer(self.config) |
4443 | self.Sync_LocalHalf(syncbuf, submodules=submodules) | 4448 | self.Sync_LocalHalf(syncbuf, submodules=submodules, verbose=verbose) |
4444 | syncbuf.Finish() | 4449 | syncbuf.Finish() |
4445 | 4450 | ||
4446 | if is_new or self.CurrentBranch is None: | 4451 | if is_new or self.CurrentBranch is None: |
diff --git a/subcmds/sync.py b/subcmds/sync.py index b7236629..ac6a451b 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -956,12 +956,13 @@ later is required to fix a server side protocol bug. | |||
956 | 956 | ||
957 | return _FetchMainResult(all_projects) | 957 | return _FetchMainResult(all_projects) |
958 | 958 | ||
959 | def _CheckoutOne(self, detach_head, force_sync, project): | 959 | def _CheckoutOne(self, detach_head, force_sync, verbose, project): |
960 | """Checkout work tree for one project | 960 | """Checkout work tree for one project |
961 | 961 | ||
962 | Args: | 962 | Args: |
963 | detach_head: Whether to leave a detached HEAD. | 963 | detach_head: Whether to leave a detached HEAD. |
964 | force_sync: Force checking out of the repo. | 964 | force_sync: Force checking out of the repo. |
965 | verbose: Whether to show verbose messages. | ||
965 | project: Project object for the project to checkout. | 966 | project: Project object for the project to checkout. |
966 | 967 | ||
967 | Returns: | 968 | Returns: |
@@ -975,7 +976,7 @@ later is required to fix a server side protocol bug. | |||
975 | errors = [] | 976 | errors = [] |
976 | try: | 977 | try: |
977 | project.Sync_LocalHalf( | 978 | project.Sync_LocalHalf( |
978 | syncbuf, force_sync=force_sync, errors=errors | 979 | syncbuf, force_sync=force_sync, errors=errors, verbose=verbose |
979 | ) | 980 | ) |
980 | success = syncbuf.Finish() | 981 | success = syncbuf.Finish() |
981 | except GitError as e: | 982 | except GitError as e: |
@@ -1042,7 +1043,7 @@ later is required to fix a server side protocol bug. | |||
1042 | proc_res = self.ExecuteInParallel( | 1043 | proc_res = self.ExecuteInParallel( |
1043 | opt.jobs_checkout, | 1044 | opt.jobs_checkout, |
1044 | functools.partial( | 1045 | functools.partial( |
1045 | self._CheckoutOne, opt.detach_head, opt.force_sync | 1046 | self._CheckoutOne, opt.detach_head, opt.force_sync, opt.verbose |
1046 | ), | 1047 | ), |
1047 | all_projects, | 1048 | all_projects, |
1048 | callback=_ProcessResults, | 1049 | callback=_ProcessResults, |
@@ -1288,7 +1289,7 @@ later is required to fix a server side protocol bug. | |||
1288 | groups=None, | 1289 | groups=None, |
1289 | ) | 1290 | ) |
1290 | project.DeleteWorktree( | 1291 | project.DeleteWorktree( |
1291 | quiet=opt.quiet, force=opt.force_remove_dirty | 1292 | verbose=opt.verbose, force=opt.force_remove_dirty |
1292 | ) | 1293 | ) |
1293 | 1294 | ||
1294 | new_project_paths.sort() | 1295 | new_project_paths.sort() |
@@ -1533,7 +1534,10 @@ later is required to fix a server side protocol bug. | |||
1533 | syncbuf = SyncBuffer(mp.config) | 1534 | syncbuf = SyncBuffer(mp.config) |
1534 | start = time.time() | 1535 | start = time.time() |
1535 | mp.Sync_LocalHalf( | 1536 | mp.Sync_LocalHalf( |
1536 | syncbuf, submodules=mp.manifest.HasSubmodules, errors=errors | 1537 | syncbuf, |
1538 | submodules=mp.manifest.HasSubmodules, | ||
1539 | errors=errors, | ||
1540 | verbose=opt.verbose, | ||
1537 | ) | 1541 | ) |
1538 | clean = syncbuf.Finish() | 1542 | clean = syncbuf.Finish() |
1539 | self.event_log.AddSync( | 1543 | self.event_log.AddSync( |