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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 else: | 77 else: |
78 components = url.rsplit('@', 1) | 78 components = url.rsplit('@', 1) |
79 if re.match(r'^\w+\@', url) and '@' not in components[0]: | 79 if re.match(r'^\w+\@', url) and '@' not in components[0]: |
80 components = [url] | 80 components = [url] |
81 | 81 |
82 if len(components) == 1: | 82 if len(components) == 1: |
83 components += [None] | 83 components += [None] |
84 return tuple(components) | 84 return tuple(components) |
85 | 85 |
86 | 86 |
| 87 def IsGitSha(revision): |
| 88 """Returns true if the given string is a valid hex-encoded sha""" |
| 89 return re.match('^[a-fA-F0-9]{6,40}$', revision) is not None |
| 90 |
| 91 |
87 def IsDateRevision(revision): | 92 def IsDateRevision(revision): |
88 """Returns true if the given revision is of the form "{ ... }".""" | 93 """Returns true if the given revision is of the form "{ ... }".""" |
89 return bool(revision and re.match(r'^\{.+\}$', str(revision))) | 94 return bool(revision and re.match(r'^\{.+\}$', str(revision))) |
90 | 95 |
91 | 96 |
92 def MakeDateRevision(date): | 97 def MakeDateRevision(date): |
93 """Returns a revision representing the latest revision before the given | 98 """Returns a revision representing the latest revision before the given |
94 date.""" | 99 date.""" |
95 return "{" + date + "}" | 100 return "{" + date + "}" |
96 | 101 |
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 def DefaultIndexPackConfig(url=''): | 1134 def DefaultIndexPackConfig(url=''): |
1130 """Return reasonable default values for configuring git-index-pack. | 1135 """Return reasonable default values for configuring git-index-pack. |
1131 | 1136 |
1132 Experiments suggest that higher values for pack.threads don't improve | 1137 Experiments suggest that higher values for pack.threads don't improve |
1133 performance.""" | 1138 performance.""" |
1134 cache_limit = DefaultDeltaBaseCacheLimit() | 1139 cache_limit = DefaultDeltaBaseCacheLimit() |
1135 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | 1140 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] |
1136 if url in THREADED_INDEX_PACK_BLACKLIST: | 1141 if url in THREADED_INDEX_PACK_BLACKLIST: |
1137 result.extend(['-c', 'pack.threads=1']) | 1142 result.extend(['-c', 'pack.threads=1']) |
1138 return result | 1143 return result |
OLD | NEW |