git cl set-commit: allow forcing code review system

Also default to latest patchset if no other one is specified locally.

BUG=600945

Review-Url: https://codereview.chromium.org/2230883002
diff --git a/git_cl.py b/git_cl.py
index a8eb59f..0fa2dc9 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1731,21 +1731,18 @@
 
   def SetFlags(self, flags):
     """Sets flags on this CL/patchset in Rietveld.
-
-    The latest patchset in Rietveld must be the same as latest known locally.
     """
-    if not self.GetPatchset():
-      DieWithError('The patchset needs to match. Send another patchset.')
+    patchset = self.GetPatchset() or self.GetMostRecentPatchset()
     try:
       return self.RpcServer().set_flags(
-          self.GetIssue(), self.GetPatchset(), flags)
+          self.GetIssue(), patchset, flags)
     except urllib2.HTTPError as e:
       if e.code == 404:
         DieWithError('The issue %s doesn\'t exist.' % self.GetIssue())
       if e.code == 403:
         DieWithError(
             ('Access denied to issue %s. Maybe the patchset %s doesn\'t '
-             'match?') % (self.GetIssue(), self.GetPatchset()))
+             'match?') % (self.GetIssue(), patchset))
       raise
 
   def RpcServer(self):
@@ -4725,7 +4722,9 @@
   parser.add_option('-c', '--clear', action='store_true',
                     help='stop CQ run, if any')
   auth.add_auth_options(parser)
+  _add_codereview_select_options(parser)
   options, args = parser.parse_args(args)
+  _process_codereview_select_options(parser, options)
   auth_config = auth.extract_auth_config_from_options(options)
   if args:
     parser.error('Unrecognized args: %s' % ' '.join(args))