diff options
author | Aravind Vasudevan <aravindvasudev@google.com> | 2023-09-14 08:46:44 +0000 |
---|---|---|
committer | LUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-09-14 17:13:37 +0000 |
commit | c993c5068e0f7e22124b1bfb17ad0425fe2b8c83 (patch) | |
tree | 7e1dadd9b04a42ebfd438e41f35c176f0f0578da /subcmds/upload.py | |
parent | c3d7c8536c408a54c7af1486f0beec7a1b0eb0ad (diff) | |
download | git-repo-c993c5068e0f7e22124b1bfb17ad0425fe2b8c83.tar.gz |
subcmds: Use repo logger
Bug: b/292704435
Change-Id: Ia3a45d87fc0bf0d4a1ba53050d9c3cd2dba20e55
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386236
Reviewed-by: Jason Chang <jasonnc@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Tested-by: Aravind Vasudevan <aravindvasudev@google.com>
Diffstat (limited to 'subcmds/upload.py')
-rw-r--r-- | subcmds/upload.py | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/subcmds/upload.py b/subcmds/upload.py index ec89ad43..618a10e1 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -29,10 +29,12 @@ from git_command import GitCommand | |||
29 | from git_refs import R_HEADS | 29 | from git_refs import R_HEADS |
30 | from hooks import RepoHook | 30 | from hooks import RepoHook |
31 | from project import ReviewableBranch | 31 | from project import ReviewableBranch |
32 | from repo_logging import RepoLogger | ||
32 | from subcmds.sync import LocalSyncState | 33 | from subcmds.sync import LocalSyncState |
33 | 34 | ||
34 | 35 | ||
35 | _DEFAULT_UNUSUAL_COMMIT_THRESHOLD = 5 | 36 | _DEFAULT_UNUSUAL_COMMIT_THRESHOLD = 5 |
37 | logger = RepoLogger(__file__) | ||
36 | 38 | ||
37 | 39 | ||
38 | class UploadExitError(SilentRepoExitError): | 40 | class UploadExitError(SilentRepoExitError): |
@@ -70,16 +72,16 @@ def _VerifyPendingCommits(branches: List[ReviewableBranch]) -> bool: | |||
70 | # If any branch has many commits, prompt the user. | 72 | # If any branch has many commits, prompt the user. |
71 | if many_commits: | 73 | if many_commits: |
72 | if len(branches) > 1: | 74 | if len(branches) > 1: |
73 | print( | 75 | logger.warn( |
74 | "ATTENTION: One or more branches has an unusually high number " | 76 | "ATTENTION: One or more branches has an unusually high number " |
75 | "of commits." | 77 | "of commits." |
76 | ) | 78 | ) |
77 | else: | 79 | else: |
78 | print( | 80 | logger.warn( |
79 | "ATTENTION: You are uploading an unusually high number of " | 81 | "ATTENTION: You are uploading an unusually high number of " |
80 | "commits." | 82 | "commits." |
81 | ) | 83 | ) |
82 | print( | 84 | logger.warn( |
83 | "YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across " | 85 | "YOU PROBABLY DO NOT MEAN TO DO THIS. (Did you rebase across " |
84 | "branches?)" | 86 | "branches?)" |
85 | ) | 87 | ) |
@@ -93,7 +95,7 @@ def _VerifyPendingCommits(branches: List[ReviewableBranch]) -> bool: | |||
93 | 95 | ||
94 | def _die(fmt, *args): | 96 | def _die(fmt, *args): |
95 | msg = fmt % args | 97 | msg = fmt % args |
96 | print("error: %s" % msg, file=sys.stderr) | 98 | logger.error("error: %s", msg) |
97 | raise UploadExitError(msg) | 99 | raise UploadExitError(msg) |
98 | 100 | ||
99 | 101 | ||
@@ -748,16 +750,13 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
748 | for result in results: | 750 | for result in results: |
749 | project, avail = result | 751 | project, avail = result |
750 | if avail is None: | 752 | if avail is None: |
751 | print( | 753 | logger.error( |
752 | 'repo: error: %s: Unable to upload branch "%s". ' | 754 | 'repo: error: %s: Unable to upload branch "%s". ' |
753 | "You might be able to fix the branch by running:\n" | 755 | "You might be able to fix the branch by running:\n" |
754 | " git branch --set-upstream-to m/%s" | 756 | " git branch --set-upstream-to m/%s", |
755 | % ( | 757 | project.RelPath(local=opt.this_manifest_only), |
756 | project.RelPath(local=opt.this_manifest_only), | 758 | project.CurrentBranch, |
757 | project.CurrentBranch, | 759 | project.manifest.branch, |
758 | project.manifest.branch, | ||
759 | ), | ||
760 | file=sys.stderr, | ||
761 | ) | 760 | ) |
762 | elif avail: | 761 | elif avail: |
763 | pending.append(result) | 762 | pending.append(result) |
@@ -772,14 +771,11 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
772 | 771 | ||
773 | if not pending: | 772 | if not pending: |
774 | if opt.branch is None: | 773 | if opt.branch is None: |
775 | print( | 774 | logger.error("repo: error: no branches ready for upload") |
776 | "repo: error: no branches ready for upload", file=sys.stderr | ||
777 | ) | ||
778 | else: | 775 | else: |
779 | print( | 776 | logger.error( |
780 | 'repo: error: no branches named "%s" ready for upload' | 777 | 'repo: error: no branches named "%s" ready for upload', |
781 | % (opt.branch,), | 778 | opt.branch, |
782 | file=sys.stderr, | ||
783 | ) | 779 | ) |
784 | return 1 | 780 | return 1 |
785 | 781 | ||
@@ -809,10 +805,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/ | |||
809 | project_list=pending_proj_names, worktree_list=pending_worktrees | 805 | project_list=pending_proj_names, worktree_list=pending_worktrees |
810 | ): | 806 | ): |
811 | if LocalSyncState(manifest).IsPartiallySynced(): | 807 | if LocalSyncState(manifest).IsPartiallySynced(): |
812 | print( | 808 | logger.error( |
813 | "Partially synced tree detected. Syncing all projects " | 809 | "Partially synced tree detected. Syncing all projects " |
814 | "may resolve issues you're seeing.", | 810 | "may resolve issues you're seeing." |
815 | file=sys.stderr, | ||
816 | ) | 811 | ) |
817 | ret = 1 | 812 | ret = 1 |
818 | if ret: | 813 | if ret: |