From 8ef7ab251cadd77ee161b438c648104e37146568 Mon Sep 17 00:00:00 2001 From: "ukai@chromium.org" Date: Wed, 28 Nov 2012 04:24:52 +0000 Subject: [PATCH] Don't call settings.GetIsGerrit() before parser.parse_args() settings.GetIsGerrit() would invoke logging.basicConfig() and preemtps the basicConfig for verbose option in parser.parse_args. R=maruel@chromium.org,ilevy@chromium.org BUG=162600 Review URL: https://chromiumcodereview.appspot.com/11418171 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@169843 0039d316-1c4b-4281-b951-d872f2087c98 --- git_cl.py | 9 ++++++--- tests/git_cl_test.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/git_cl.py b/git_cl.py index c374a10cf6..08ea2a3134 100755 --- a/git_cl.py +++ b/git_cl.py @@ -1245,12 +1245,15 @@ def CMDupload(parser, args): help="Emulate Subversion's auto properties feature.") parser.add_option('-c', '--use-commit-queue', action='store_true', help='tell the commit queue to commit this patchset') - if settings.GetIsGerrit(): - parser.add_option('--target_branch', dest='target_branch', default='master', - help='target branch to upload') + parser.add_option('--target_branch', + help='When uploading to gerrit, remote branch to ' + 'use for CL. Default: master') add_git_similarity(parser) (options, args) = parser.parse_args(args) + if options.target_branch and not settings.GetIsGerrit(): + parser.error('Use --target_branch for non gerrit repository.') + # Print warning if the user used the -m/--message argument. This will soon # change to -t/--title. if options.message: diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index ce3761cd82..4b089b3deb 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -126,7 +126,6 @@ class TestGitCl(TestCase): '-M'+similarity, 'fake_ancestor_sha'],), '+dat') return [ - ((['git', 'config', 'gerrit.host'],), ''), ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'), similarity_call, @@ -149,6 +148,7 @@ class TestGitCl(TestCase): 'foo'), ((['git', 'config', 'user.email'],), 'me@example.com'), stat_call, + ((['git', 'config', 'gerrit.host'],), ''), ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), 'desc\n'), ] @@ -433,7 +433,6 @@ class TestGitCl(TestCase): @classmethod def _gerrit_base_calls(cls): return [ - ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), ((['git', 'config', 'rietveld.server'],), 'codereview.example.com'), ((['git', 'symbolic-ref', 'HEAD'],), 'master'), ((['git', 'config', '--int', '--get', @@ -465,6 +464,7 @@ class TestGitCl(TestCase): @staticmethod def _gerrit_upload_calls(description, reviewers): calls = [ + ((['git', 'config', 'gerrit.host'],), 'gerrit.example.com'), ((['git', 'log', '--pretty=format:%s\n\n%b', 'fake_ancestor_sha..'],), description) ]