gclient: Add '--auto_rebase' sync option.

This adds the '--auto_rebase' sync option, enabling parallel updates to
automatically rebase local Git branches during sync.

BUG=None
TEST=local

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294151 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient.py b/gclient.py
index 22a4eb9..5f9dac5 100755
--- a/gclient.py
+++ b/gclient.py
@@ -2003,6 +2003,9 @@
   parser.add_option('-M', '--merge', action='store_true',
                     help='merge upstream changes instead of trying to '
                          'fast-forward or rebase')
+  parser.add_option('-A', '--auto_rebase', action='store_true',
+                    help='Automatically rebase repositories against local '
+                         'checkout during update (git only).')
   parser.add_option('--deps', dest='deps_os', metavar='OS_LIST',
                     help='override deps for the specified (comma-separated) '
                          'platform(s); \'all\' will process all deps_os '
diff --git a/gclient_scm.py b/gclient_scm.py
index 243387b..24064f9 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -606,15 +606,16 @@
             self.Print('_____ %s%s' % (self.relpath, rev_str), timestamp=False)
             printed_path = True
           while True:
-            try:
-              action = self._AskForData(
-                  'Cannot %s, attempt to rebase? '
-                  '(y)es / (q)uit / (s)kip : ' %
-                      ('merge' if options.merge else 'fast-forward merge'),
-                  options)
-            except ValueError:
-              raise gclient_utils.Error('Invalid Character')
-            if re.match(r'yes|y', action, re.I):
+            if not options.auto_rebase:
+              try:
+                action = self._AskForData(
+                    'Cannot %s, attempt to rebase? '
+                    '(y)es / (q)uit / (s)kip : ' %
+                        ('merge' if options.merge else 'fast-forward merge'),
+                    options)
+              except ValueError:
+                raise gclient_utils.Error('Invalid Character')
+            if options.auto_rebase or re.match(r'yes|y', action, re.I):
               self._AttemptRebase(upstream_branch, files, options,
                                   printed_path=printed_path, merge=False)
               printed_path = True
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index 967d360..03a87fd 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -804,6 +804,7 @@
   """This class doesn't use pymox."""
   class OptionsObject(object):
     def __init__(self, verbose=False, revision=None):
+      self.auto_rebase = False
       self.verbose = verbose
       self.revision = revision
       self.manually_grab_svn_rev = True