OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Gclient-specific SCM-specific operations.""" | 5 """Gclient-specific SCM-specific operations.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import posixpath | 9 import posixpath |
10 import re | 10 import re |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path) | 346 upstream_branch = scm.GIT.GetUpstreamBranch(self.checkout_path) |
347 if not upstream_branch or not upstream_branch.startswith('refs/remotes'): | 347 if not upstream_branch or not upstream_branch.startswith('refs/remotes'): |
348 current_type = "hash" | 348 current_type = "hash" |
349 logging.debug("Current branch is not tracking an upstream (remote)" | 349 logging.debug("Current branch is not tracking an upstream (remote)" |
350 " branch.") | 350 " branch.") |
351 elif upstream_branch.startswith('refs/remotes'): | 351 elif upstream_branch.startswith('refs/remotes'): |
352 current_type = "branch" | 352 current_type = "branch" |
353 else: | 353 else: |
354 raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch) | 354 raise gclient_utils.Error('Invalid Upstream: %s' % upstream_branch) |
355 | 355 |
356 if not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=revision): | 356 # Update the remotes first so we have all the refs. |
357 # Update the remotes first so we have all the refs. | 357 backoff_time = 5 |
358 backoff_time = 5 | 358 for _ in range(10): |
359 for _ in range(10): | 359 try: |
360 try: | 360 remote_output = scm.GIT.Capture( |
361 remote_output = scm.GIT.Capture( | 361 ['remote'] + verbose + ['update'], |
362 ['remote'] + verbose + ['update'], | 362 cwd=self.checkout_path) |
363 cwd=self.checkout_path) | 363 break |
364 break | 364 except subprocess2.CalledProcessError, e: |
365 except subprocess2.CalledProcessError, e: | 365 # Hackish but at that point, git is known to work so just checking for |
366 # Hackish but at that point, git is known to work so just checking for | 366 # 502 in stderr should be fine. |
367 # 502 in stderr should be fine. | 367 if '502' in e.stderr: |
368 if '502' in e.stderr: | 368 print(str(e)) |
369 print(str(e)) | 369 print('Sleeping %.1f seconds and retrying...' % backoff_time) |
370 print('Sleeping %.1f seconds and retrying...' % backoff_time) | 370 time.sleep(backoff_time) |
371 time.sleep(backoff_time) | 371 backoff_time *= 1.3 |
372 backoff_time *= 1.3 | 372 continue |
373 continue | 373 raise |
374 raise | |
375 | 374 |
376 if verbose: | 375 if verbose: |
377 print(remote_output.strip()) | 376 print(remote_output.strip()) |
378 | 377 |
379 # This is a big hammer, debatable if it should even be here... | 378 # This is a big hammer, debatable if it should even be here... |
380 if options.force or options.reset: | 379 if options.force or options.reset: |
381 self._Run(['reset', '--hard', 'HEAD'], options) | 380 self._Run(['reset', '--hard', 'HEAD'], options) |
382 | 381 |
383 if current_type == 'detached': | 382 if current_type == 'detached': |
384 # case 0 | 383 # case 0 |
385 self._CheckClean(rev_str) | 384 self._CheckClean(rev_str) |
386 self._CheckDetachedHead(rev_str, options) | 385 self._CheckDetachedHead(rev_str, options) |
387 self._Capture(['checkout', '--quiet', '%s' % revision]) | 386 self._Capture(['checkout', '--quiet', '%s' % revision]) |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 new_command.append('--force') | 1193 new_command.append('--force') |
1195 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1194 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1196 new_command.extend(('--accept', 'theirs-conflict')) | 1195 new_command.extend(('--accept', 'theirs-conflict')) |
1197 elif options.manually_grab_svn_rev: | 1196 elif options.manually_grab_svn_rev: |
1198 new_command.append('--force') | 1197 new_command.append('--force') |
1199 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1198 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1200 new_command.extend(('--accept', 'postpone')) | 1199 new_command.extend(('--accept', 'postpone')) |
1201 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1200 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1202 new_command.extend(('--accept', 'postpone')) | 1201 new_command.extend(('--accept', 'postpone')) |
1203 return new_command | 1202 return new_command |
OLD | NEW |