Commit 87884cc0 authored by pgervais@chromium.org's avatar pgervais@chromium.org

Added --(de)activate-update options

These options have been added to the 'git cl config' subcommand.
--deactivate-update tells git cl not to update the values inside
.git/config from the codereview.settings file. --activate-update does
the opposite.

This is designed for testing/development purposes only, for example, to
be able to change the rietveld URL.

BUG=327901

Review URL: https://codereview.chromium.org/104043008

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@242943 0039d316-1c4b-4281-b951-d872f2087c98
parent f7d31f52
......@@ -267,9 +267,17 @@ class Settings(object):
def LazyUpdateIfNeeded(self):
"""Updates the settings from a codereview.settings file, if available."""
if not self.updated:
# The only value that actually changes the behavior is
# autoupdate = "false". Everything else means "true".
autoupdate = RunGit(['config', 'rietveld.autoupdate'],
error_ok=True
).strip().lower()
cr_settings_file = FindCodereviewSettingsFile()
if cr_settings_file:
if autoupdate != 'false' and cr_settings_file:
LoadCodereviewSettingsFromFile(cr_settings_file)
# set updated to True to avoid infinite calling loop
# through DownloadHooks
self.updated = True
DownloadHooks(False)
self.updated = True
......@@ -1084,7 +1092,22 @@ def DownloadHooks(force):
def CMDconfig(parser, args):
"""Edits configuration for this tree."""
_, args = parser.parse_args(args)
parser.add_option('--activate-update', action='store_true',
help='activate auto-updating [rietveld] section in '
'.git/config')
parser.add_option('--deactivate-update', action='store_true',
help='deactivate auto-updating [rietveld] section in '
'.git/config')
options, args = parser.parse_args(args)
if options.deactivate_update:
RunGit(['config', 'rietveld.autoupdate', 'false'])
return
if options.activate_update:
RunGit(['config', '--unset', 'rietveld.autoupdate'])
return
if len(args) == 0:
GetCodereviewSettingsInteractively()
DownloadHooks(True)
......
......@@ -146,6 +146,7 @@ class TestGitCl(TestCase):
'-M'+similarity, 'fake_ancestor_sha', 'HEAD'],), '+dat')
return [
((['git', 'config', 'rietveld.autoupdate'],), ''),
((['git', 'config', 'rietveld.server'],),
'codereview.example.com'),
((['git', 'symbolic-ref', 'HEAD'],), 'master'),
......@@ -250,6 +251,8 @@ class TestGitCl(TestCase):
'svn-remote.svn.fetch trunk/src:refs/remotes/origin/master'),
None),
0)),
((['git', 'config', 'rietveld.autoupdate'],),
''),
((['git',
'config', 'rietveld.server'],), 'codereview.example.com'),
((['git', 'symbolic-ref', 'HEAD'],), 'refs/heads/working'),
......@@ -382,6 +385,7 @@ class TestGitCl(TestCase):
private = '--private' in upload_args
self.calls = self._upload_calls(similarity, find_copies, private)
def RunEditor(desc, _, **kwargs):
self.assertEquals(
'# Enter a description of the change.\n'
......@@ -393,12 +397,14 @@ class TestGitCl(TestCase):
desc)
return returned_description
self.mock(git_cl.gclient_utils, 'RunEditor', RunEditor)
def check_upload(args):
cmd_line = self._cmd_line(final_description, reviewers, similarity,
find_copies, private)
self.assertEquals(cmd_line, args)
return 1, 2
self.mock(git_cl.upload, 'RealMain', check_upload)
git_cl.main(['upload'] + upload_args)
def test_no_reviewer(self):
......@@ -515,6 +521,8 @@ class TestGitCl(TestCase):
@classmethod
def _gerrit_base_calls(cls):
return [
((['git', 'config', 'rietveld.autoupdate'],),
''),
((['git',
'config', 'rietveld.server'],), 'codereview.example.com'),
((['git', 'symbolic-ref', 'HEAD'],), 'master'),
......@@ -651,6 +659,8 @@ class TestGitCl(TestCase):
self.mock(git_cl, 'urlretrieve', self._mocked_call)
self.mock(git_cl, 'hasSheBang', self._mocked_call)
self.calls = [
((['git', 'config', 'rietveld.autoupdate'],),
''),
((['git', 'config', 'rietveld.server',
'gerrit.chromium.org'],), ''),
((['git', 'config', '--unset-all', 'rietveld.cc'],), ''),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment