| 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 """Generic utils.""" | 5 """Generic utils.""" |
| 6 | 6 |
| 7 import codecs | 7 import codecs |
| 8 import cStringIO | 8 import cStringIO |
| 9 import datetime | 9 import datetime |
| 10 import logging | 10 import logging |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 break | 159 break |
| 160 except OSError: | 160 except OSError: |
| 161 if i == (retries - 1): | 161 if i == (retries - 1): |
| 162 # Give up. | 162 # Give up. |
| 163 raise | 163 raise |
| 164 # retry | 164 # retry |
| 165 logging.debug("Renaming failed from %s to %s. Retrying ..." % (old, new)) | 165 logging.debug("Renaming failed from %s to %s. Retrying ..." % (old, new)) |
| 166 time.sleep(0.1) | 166 time.sleep(0.1) |
| 167 | 167 |
| 168 | 168 |
| 169 def rm_file_or_tree(path): |
| 170 if os.path.isfile(path): |
| 171 os.remove(path) |
| 172 else: |
| 173 rmtree(path) |
| 174 |
| 175 |
| 169 def rmtree(path): | 176 def rmtree(path): |
| 170 """shutil.rmtree() on steroids. | 177 """shutil.rmtree() on steroids. |
| 171 | 178 |
| 172 Recursively removes a directory, even if it's marked read-only. | 179 Recursively removes a directory, even if it's marked read-only. |
| 173 | 180 |
| 174 shutil.rmtree() doesn't work on Windows if any of the files or directories | 181 shutil.rmtree() doesn't work on Windows if any of the files or directories |
| 175 are read-only, which svn repositories and some .svn files are. We need to | 182 are read-only, which svn repositories and some .svn files are. We need to |
| 176 be able to force the files to be writable (i.e., deletable) as we traverse | 183 be able to force the files to be writable (i.e., deletable) as we traverse |
| 177 the tree. | 184 the tree. |
| 178 | 185 |
| (...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1159 def DefaultIndexPackConfig(url=''): | 1166 def DefaultIndexPackConfig(url=''): |
| 1160 """Return reasonable default values for configuring git-index-pack. | 1167 """Return reasonable default values for configuring git-index-pack. |
| 1161 | 1168 |
| 1162 Experiments suggest that higher values for pack.threads don't improve | 1169 Experiments suggest that higher values for pack.threads don't improve |
| 1163 performance.""" | 1170 performance.""" |
| 1164 cache_limit = DefaultDeltaBaseCacheLimit() | 1171 cache_limit = DefaultDeltaBaseCacheLimit() |
| 1165 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | 1172 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] |
| 1166 if url in THREADED_INDEX_PACK_BLACKLIST: | 1173 if url in THREADED_INDEX_PACK_BLACKLIST: |
| 1167 result.extend(['-c', 'pack.threads=1']) | 1174 result.extend(['-c', 'pack.threads=1']) |
| 1168 return result | 1175 return result |
| OLD | NEW |