Ignore CC_LIST when private flag is specified.

This prevents private CLs to be automatically CC-ed to public mailing lists
unintentionally.

Review URL: https://chromiumcodereview.appspot.com/24257014

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@225925 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
tyoshino@chromium.org 12 years ago
parent 8d65ab6f97
commit 99918abbe7

@ -878,7 +878,17 @@ def CMDupload(change_info, args):
watchlist = watchlists.Watchlists(change_info.GetLocalRoot()) watchlist = watchlists.Watchlists(change_info.GetLocalRoot())
watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames()) watchers = watchlist.GetWatchersForPaths(change_info.GetFileNames())
cc_list = GetCodeReviewSetting("CC_LIST") # We check this before applying the "PRIVATE" parameter of codereview
# settings assuming that the author of the settings file has put
# addresses which we can send private CLs to, and so we should ignore
# CC_LIST only when --private is specified explicitly on the command
# line.
if "--private" in upload_arg:
Warn("WARNING: CC_LIST is ignored since private flag is specified. "
"You need to review and add them manually if necessary.")
cc_list = ""
else:
cc_list = GetCodeReviewSetting("CC_LIST")
if not no_watchlists and watchers: if not no_watchlists and watchers:
# Filter out all empty elements and join by ',' # Filter out all empty elements and join by ','
cc_list = ','.join(filter(None, [cc_list] + watchers)) cc_list = ','.join(filter(None, [cc_list] + watchers))

@ -442,11 +442,17 @@ class Changelist(object):
Return is a string suitable for passing to gcl with the --cc flag. Return is a string suitable for passing to gcl with the --cc flag.
""" """
if self.cc is None: if self.cc is None:
base_cc = settings .GetDefaultCCList() base_cc = settings.GetDefaultCCList()
more_cc = ','.join(self.watchers) more_cc = ','.join(self.watchers)
self.cc = ','.join(filter(None, (base_cc, more_cc))) or '' self.cc = ','.join(filter(None, (base_cc, more_cc))) or ''
return self.cc return self.cc
def GetCCListWithoutDefault(self):
"""Return the users cc'd on this CL excluding default ones."""
if self.cc is None:
self.cc = ','.join(self.watchers)
return self.cc
def SetWatchers(self, watchers): def SetWatchers(self, watchers):
"""Set the list of email addresses that should be cc'd based on the changed """Set the list of email addresses that should be cc'd based on the changed
files in this CL. files in this CL.
@ -1421,7 +1427,18 @@ def RietveldUpload(options, args, cl):
if not change_desc.get_reviewers(): if not change_desc.get_reviewers():
DieWithError("Must specify reviewers to send email.") DieWithError("Must specify reviewers to send email.")
upload_args.append('--send_mail') upload_args.append('--send_mail')
cc = ','.join(filter(None, (cl.GetCCList(), ','.join(options.cc))))
# We check this before applying rietveld.private assuming that in
# rietveld.cc only addresses which we can send private CLs to are listed
# if rietveld.private is set, and so we should ignore rietveld.cc only when
# --private is specified explicitly on the command line.
if options.private:
logging.warn('rietveld.cc is ignored since private flag is specified. '
'You need to review and add them manually if necessary.')
cc = cl.GetCCListWithoutDefault()
else:
cc = cl.GetCCList()
cc = ','.join(filter(None, (cc, ','.join(options.cc))))
if cc: if cc:
upload_args.extend(['--cc', cc]) upload_args.extend(['--cc', cc])

@ -188,15 +188,16 @@ class TestGitCl(TestCase):
@classmethod @classmethod
def _git_upload_calls(cls, private): def _git_upload_calls(cls, private):
if private: if private:
cc_call = []
private_call = [] private_call = []
else: else:
cc_call = [((['git', 'config', 'rietveld.cc'],), '')]
private_call = [ private_call = [
((['git', 'config', 'rietveld.private'],), '')] ((['git', 'config', 'rietveld.private'],), '')]
return [ return [
((['git', 'config', 'core.editor'],), ''), ((['git', 'config', 'core.editor'],), ''),
((['git', 'config', 'rietveld.cc'],), '') ] + cc_call + private_call + [
] + private_call + [
((['git', 'config', 'branch.master.base-url'],), ''), ((['git', 'config', 'branch.master.base-url'],), ''),
((['git', ((['git',
'config', '--local', '--get-regexp', '^svn-remote\\.'],), 'config', '--local', '--get-regexp', '^svn-remote\\.'],),

Loading…
Cancel
Save