Do not prompt on --dependencies if --force.

At the moment, specifying --dependencies to upload all dependent CLs
will always prompt for confirmation if --force was specified. This
means that there is no way to run this command in a batch way or from
another script, and it's also in contradiction to the --force flag
which is meant to answer 'yes' to all prompts.

This uses a pattern that is used several times in the script, which is
to check 'if not force: prompt()'.

Change-Id: I7d85b02b68d958a5b2d3295a04c4ced023d36ec8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2139700
Auto-Submit: Jose Lopes <jabolopes@google.com>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index c5c1424..ac6756b 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -1424,7 +1424,7 @@
         # Remove the dependencies flag from args so that we do not end up in a
         # loop.
         orig_args.remove('--dependencies')
-        ret = upload_branch_deps(self, orig_args)
+        ret = upload_branch_deps(self, orig_args, options.force)
     return ret
 
   def SetCQState(self, new_state):
@@ -3202,7 +3202,7 @@
     yield (cl, 'error')
 
 
-def upload_branch_deps(cl, args):
+def upload_branch_deps(cl, args, force=False):
   """Uploads CLs of local branches that are dependents of the current branch.
 
   If the local branch dependency tree looks like:
@@ -3266,8 +3266,9 @@
     print('There are no dependent local branches for %s' % root_branch)
     return 0
 
-  confirm_or_exit('This command will checkout all dependent branches and run '
-                  '"git cl upload".', action='continue')
+  if not force:
+    confirm_or_exit('This command will checkout all dependent branches and run '
+                    '"git cl upload".', action='continue')
 
   # Record all dependents that failed to upload.
   failures = {}