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 if (not re.match(r'^[0-9a-fA-F]{40}$', revision) or |
| 357 not scm.GIT.IsValidRevision(cwd=self.checkout_path, rev=revision)): |
357 # Update the remotes first so we have all the refs. | 358 # Update the remotes first so we have all the refs. |
358 backoff_time = 5 | 359 backoff_time = 5 |
359 for _ in range(10): | 360 for _ in range(10): |
360 try: | 361 try: |
361 remote_output = scm.GIT.Capture( | 362 remote_output = scm.GIT.Capture( |
362 ['remote'] + verbose + ['update'], | 363 ['remote'] + verbose + ['update'], |
363 cwd=self.checkout_path) | 364 cwd=self.checkout_path) |
364 break | 365 break |
365 except subprocess2.CalledProcessError, e: | 366 except subprocess2.CalledProcessError, e: |
366 # Hackish but at that point, git is known to work so just checking for | 367 # Hackish but at that point, git is known to work so just checking for |
(...skipping 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1194 new_command.append('--force') | 1195 new_command.append('--force') |
1195 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1196 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1196 new_command.extend(('--accept', 'theirs-conflict')) | 1197 new_command.extend(('--accept', 'theirs-conflict')) |
1197 elif options.manually_grab_svn_rev: | 1198 elif options.manually_grab_svn_rev: |
1198 new_command.append('--force') | 1199 new_command.append('--force') |
1199 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1200 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1200 new_command.extend(('--accept', 'postpone')) | 1201 new_command.extend(('--accept', 'postpone')) |
1201 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: | 1202 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: |
1202 new_command.extend(('--accept', 'postpone')) | 1203 new_command.extend(('--accept', 'postpone')) |
1203 return new_command | 1204 return new_command |
OLD | NEW |