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
diff --git a/git_cl.py b/git_cl.py
index 65e6413..ce626ef 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -442,11 +442,17 @@
     Return is a string suitable for passing to gcl with the --cc flag.
     """
     if self.cc is None:
-      base_cc = settings  .GetDefaultCCList()
+      base_cc = settings.GetDefaultCCList()
       more_cc = ','.join(self.watchers)
       self.cc = ','.join(filter(None, (base_cc, more_cc))) or ''
     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):
     """Set the list of email addresses that should be cc'd based on the changed
        files in this CL.
@@ -1421,7 +1427,18 @@
       if not change_desc.get_reviewers():
         DieWithError("Must specify reviewers to send email.")
       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:
       upload_args.extend(['--cc', cc])