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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 _WARNINGS.append(msg) | 68 _WARNINGS.append(msg) |
69 | 69 |
70 | 70 |
71 def SplitUrlRevision(url): | 71 def SplitUrlRevision(url): |
72 """Splits url and returns a two-tuple: url, rev""" | 72 """Splits url and returns a two-tuple: url, rev""" |
73 if url.startswith('ssh:'): | 73 if url.startswith('ssh:'): |
74 # Make sure ssh://user-name@example.com/~/test.git@stable works | 74 # Make sure ssh://user-name@example.com/~/test.git@stable works |
75 regex = r'(ssh://(?:[-.\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' | 75 regex = r'(ssh://(?:[-.\w]+@)?[-\w:\.]+/[-~\w\./]+)(?:@(.+))?' |
76 components = re.search(regex, url).groups() | 76 components = re.search(regex, url).groups() |
77 else: | 77 else: |
78 components = url.split('@', 1) | 78 components = url.split('@', 1) |
bradn
2014/04/10 22:19:27
Couldn't you just change this to use rsplit instea
Sheridan Rawlins
2014/04/11 01:05:46
Well, the code handles urls that don't lock the DE
| |
79 if url.startswith('git@'): | |
bradn
2014/04/10 22:19:27
Technically can't these be any username?
Though wi
Sheridan Rawlins
2014/04/11 01:05:46
Yes; Done.
| |
80 components = components[1].split('@', 1) | |
81 components[0] = 'git@' + components[0] | |
82 | |
79 if len(components) == 1: | 83 if len(components) == 1: |
80 components += [None] | 84 components += [None] |
81 return tuple(components) | 85 return tuple(components) |
82 | 86 |
83 | 87 |
84 def IsDateRevision(revision): | 88 def IsDateRevision(revision): |
85 """Returns true if the given revision is of the form "{ ... }".""" | 89 """Returns true if the given revision is of the form "{ ... }".""" |
86 return bool(revision and re.match(r'^\{.+\}$', str(revision))) | 90 return bool(revision and re.match(r'^\{.+\}$', str(revision))) |
87 | 91 |
88 | 92 |
(...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 def DefaultIndexPackConfig(url=''): | 1081 def DefaultIndexPackConfig(url=''): |
1078 """Return reasonable default values for configuring git-index-pack. | 1082 """Return reasonable default values for configuring git-index-pack. |
1079 | 1083 |
1080 Experiments suggest that higher values for pack.threads don't improve | 1084 Experiments suggest that higher values for pack.threads don't improve |
1081 performance.""" | 1085 performance.""" |
1082 cache_limit = DefaultDeltaBaseCacheLimit() | 1086 cache_limit = DefaultDeltaBaseCacheLimit() |
1083 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] | 1087 result = ['-c', 'core.deltaBaseCacheLimit=%s' % cache_limit] |
1084 if url in THREADED_INDEX_PACK_BLACKLIST: | 1088 if url in THREADED_INDEX_PACK_BLACKLIST: |
1085 result.extend(['-c', 'pack.threads=1']) | 1089 result.extend(['-c', 'pack.threads=1']) |
1086 return result | 1090 return result |
OLD | NEW |