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 # Update the remotes first so we have all the refs. | 356 if not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=revision): |
357 backoff_time = 5 | 357 # Update the remotes first so we have all the refs. |
358 for _ in range(10): | 358 backoff_time = 5 |
359 try: | 359 for _ in range(10): |
360 remote_output = scm.GIT.Capture( | 360 try: |
361 ['remote'] + verbose + ['update'], | 361 remote_output = scm.GIT.Capture( |
362 cwd=self.checkout_path) | 362 ['remote'] + verbose + ['update'], |
363 break | 363 cwd=self.checkout_path) |
364 except subprocess2.CalledProcessError, e: | 364 break |
365 # Hackish but at that point, git is known to work so just checking for | 365 except subprocess2.CalledProcessError, e: |
366 # 502 in stderr should be fine. | 366 # Hackish but at that point, git is known to work so just checking for |
367 if '502' in e.stderr: | 367 # 502 in stderr should be fine. |
368 print(str(e)) | 368 if '502' in e.stderr: |
369 print('Sleeping %.1f seconds and retrying...' % backoff_time) | 369 print(str(e)) |
370 time.sleep(backoff_time) | 370 print('Sleeping %.1f seconds and retrying...' % backoff_time) |
371 backoff_time *= 1.3 | 371 time.sleep(backoff_time) |
372 continue | 372 backoff_time *= 1.3 |
373 raise | 373 continue |
| 374 raise |
374 | 375 |
375 if verbose: | 376 if verbose: |
376 print(remote_output.strip()) | 377 print(remote_output.strip()) |
377 | 378 |
378 # This is a big hammer, debatable if it should even be here... | 379 # This is a big hammer, debatable if it should even be here... |
379 if options.force or options.reset: | 380 if options.force or options.reset: |
380 self._Run(['reset', '--hard', 'HEAD'], options) | 381 self._Run(['reset', '--hard', 'HEAD'], options) |
381 | 382 |
382 if current_type == 'detached': | 383 if current_type == 'detached': |
383 # case 0 | 384 # case 0 |
384 self._CheckClean(rev_str) | 385 self._CheckClean(rev_str) |
385 self._CheckDetachedHead(rev_str, options) | 386 self._CheckDetachedHead(rev_str, options) |
386 self._Capture(['checkout', '--quiet', '%s' % revision]) | 387 self._Capture(['checkout', '--quiet', '%s' % revision]) |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 new_command.append('--force') | 1194 new_command.append('--force') |
1194 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1195 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1195 new_command.extend(('--accept', 'theirs-conflict')) | 1196 new_command.extend(('--accept', 'theirs-conflict')) |
1196 elif options.manually_grab_svn_rev: | 1197 elif options.manually_grab_svn_rev: |
1197 new_command.append('--force') | 1198 new_command.append('--force') |
1198 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1199 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1199 new_command.extend(('--accept', 'postpone')) | 1200 new_command.extend(('--accept', 'postpone')) |
1200 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1201 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1201 new_command.extend(('--accept', 'postpone')) | 1202 new_command.extend(('--accept', 'postpone')) |
1202 return new_command | 1203 return new_command |
OLD | NEW |