| OLD | NEW |
| 1 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2009 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 |
| 11 import subprocess | 11 import subprocess |
| 12 import time |
| 12 | 13 |
| 13 import scm | 14 import scm |
| 14 import gclient_utils | 15 import gclient_utils |
| 15 | 16 |
| 16 | 17 |
| 17 class DiffFilterer(object): | 18 class DiffFilterer(object): |
| 18 """Simple class which tracks which file is being diffed and | 19 """Simple class which tracks which file is being diffed and |
| 19 replaces instances of its file name in the original and | 20 replaces instances of its file name in the original and |
| 20 working copy lines of the svn/git diff output.""" | 21 working copy lines of the svn/git diff output.""" |
| 21 index_string = "Index: " | 22 index_string = "Index: " |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 if not upstream_branch or not upstream_branch.startswith('refs/remotes'): | 246 if not upstream_branch or not upstream_branch.startswith('refs/remotes'): |
| 246 current_type = "hash" | 247 current_type = "hash" |
| 247 logging.debug("Current branch is based off a specific rev and is not " | 248 logging.debug("Current branch is based off a specific rev and is not " |
| 248 "tracking an upstream.") | 249 "tracking an upstream.") |
| 249 elif upstream_branch.startswith('refs/remotes'): | 250 elif upstream_branch.startswith('refs/remotes'): |
| 250 current_type = "branch" | 251 current_type = "branch" |
| 251 else: | 252 else: |
| 252 raise gclient_utils.Error('Invalid Upstream') | 253 raise gclient_utils.Error('Invalid Upstream') |
| 253 | 254 |
| 254 # Update the remotes first so we have all the refs. | 255 # Update the remotes first so we have all the refs. |
| 255 for _ in range(3): | 256 for _ in range(10): |
| 256 try: | 257 try: |
| 257 remote_output, remote_err = scm.GIT.Capture( | 258 remote_output, remote_err = scm.GIT.Capture( |
| 258 ['remote'] + verbose + ['update'], | 259 ['remote'] + verbose + ['update'], |
| 259 self.checkout_path, | 260 self.checkout_path, |
| 260 print_error=False) | 261 print_error=False) |
| 261 break | 262 break |
| 262 except gclient_utils.CheckCallError, e: | 263 except gclient_utils.CheckCallError: |
| 263 # Hackish but at that point, git is known to work so just checking for | 264 # Hackish but at that point, git is known to work so just checking for |
| 264 # 502 in stderr should be fine. | 265 # 502 in stderr should be fine. |
| 265 if '502' in e.stderr: | 266 if '502' in e.stderr: |
| 266 print str(e) | 267 print str(e) |
| 267 print "Retrying..." | 268 print "Sleeping 15 seconds and retrying..." |
| 269 time.sleep(15) |
| 268 continue | 270 continue |
| 269 raise e | 271 raise |
| 270 | 272 |
| 271 if verbose: | 273 if verbose: |
| 272 print remote_output.strip() | 274 print remote_output.strip() |
| 273 # git remote update prints to stderr when used with --verbose | 275 # git remote update prints to stderr when used with --verbose |
| 274 print remote_err.strip() | 276 print remote_err.strip() |
| 275 | 277 |
| 276 # This is a big hammer, debatable if it should even be here... | 278 # This is a big hammer, debatable if it should even be here... |
| 277 if options.force or options.reset: | 279 if options.force or options.reset: |
| 278 self._Run(['reset', '--hard', 'HEAD'], redirect_stdout=False) | 280 self._Run(['reset', '--hard', 'HEAD'], redirect_stdout=False) |
| 279 | 281 |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " | 852 print("\n________ couldn't run \'%s\' in \'%s\':\nThe directory " |
| 851 "does not exist." | 853 "does not exist." |
| 852 % (' '.join(command), path)) | 854 % (' '.join(command), path)) |
| 853 # There's no file list to retrieve. | 855 # There's no file list to retrieve. |
| 854 else: | 856 else: |
| 855 scm.SVN.RunAndGetFileList(options, command, path, file_list) | 857 scm.SVN.RunAndGetFileList(options, command, path, file_list) |
| 856 | 858 |
| 857 def FullUrlForRelativeUrl(self, url): | 859 def FullUrlForRelativeUrl(self, url): |
| 858 # Find the forth '/' and strip from there. A bit hackish. | 860 # Find the forth '/' and strip from there. A bit hackish. |
| 859 return '/'.join(self.url.split('/')[:4]) + url | 861 return '/'.join(self.url.split('/')[:4]) + url |
| OLD | NEW |