From 4c72b08fce5faf1b3ad83077dd39712b6248ee03 Mon Sep 17 00:00:00 2001 From: "tandrii@chromium.org" Date: Thu, 31 Mar 2016 22:26:35 +0000 Subject: [PATCH] Gerrit git cl: do per CL check for Gerrit, not repo-wide. The purpose is to allow mixed usage of Rietveld/Gerrit in the same repo. There, a branch can use Gerrit, even though repo's default is Rietveld. The only remaining repo-wide check GetIsGerrit is to determine codereview for a branch which has no uploads yet. This also simplifies future test expectations. R=andybons@chromium.org,bauerb@chromium.org BUG=598681 Review URL: https://codereview.chromium.org/1851663002 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@299603 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 6 +++--- tests/git_cl_test.py | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/git_cl.py b/git_cl.py index 1ffbb308cb..6fe4c6a9b4 100755 --- a/git_cl.py +++ b/git_cl.py @@ -2160,7 +2160,7 @@ def upload_branch_deps(cl, args): ask_for_data('[Press enter to continue or ctrl-C to quit]') # Add a default patchset title to all upload calls in Rietveld. - if not settings.GetIsGerrit(): + if not cl.IsGerrit(): args.extend(['-t', 'Updated patchset dependency']) # Record all dependents that failed to upload. @@ -3068,7 +3068,7 @@ def CMDupload(parser, args): # Make sure authenticated to Rietveld before running expensive hooks. It is # a fast, best efforts check. Rietveld still can reject the authentication # during the actual upload. - if not settings.GetIsGerrit() and auth_config.use_oauth2: + if not cl.IsGerrit() and auth_config.use_oauth2: authenticator = auth.get_authenticator_for_host( cl.GetCodereviewServer(), auth_config) if not authenticator.has_cached_credentials(): @@ -3111,7 +3111,7 @@ def CMDupload(parser, args): ask_for_data('About to upload; enter to confirm.') print_stats(options.similarity, options.find_copies, args) - if settings.GetIsGerrit(): + if cl.IsGerrit(): if options.squash and options.no_squash: DieWithError('Can only use one of --squash or --no-squash') diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index df4a794a6c..2e869a20ea 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -784,9 +784,6 @@ class TestGitCl(TestCase): return '\n'.join(branch_deps) self.mock(git_cl, 'RunGit', mock_run_git) - git_cl.settings = git_cl.Settings() - self.mock(git_cl.settings, 'GetIsGerrit', lambda: False) - class RecordCalls: times_called = 0 record_calls = RecordCalls() @@ -808,6 +805,8 @@ class TestGitCl(TestCase): return '123' def GetPatchset(self): return '1001' + def IsGerrit(self): + return False ret = git_cl.upload_branch_deps(MockChangelist(), []) # CMDupload should have been called 5 times because of 5 dependent branches.