diff options
author | Anthony King <anthonydking@slimroms.net> | 2015-03-28 23:26:04 +0000 |
---|---|---|
committer | Conley Owens <cco3@android.com> | 2015-03-31 20:12:44 +0000 |
commit | cb07ba7e3d466a98d0af0771b4f3e21116d69898 (patch) | |
tree | b8c33b2bc0d4f1324cae8e223d64f5a1c7ffcbcd /manifest_xml.py | |
parent | 23ff7df6a759fcc7b52928d0b009beb9ba1310a6 (diff) | |
download | git-repo-cb07ba7e3d466a98d0af0771b4f3e21116d69898.tar.gz |
Resolve fetch urls more efficiently
Instead of using regex, append the netloc and relative
scheme lists with the custom scheme.
The schemes will only be appended when needed, instead
of passing X amount of regex replaces.
see http://bugs.python.org/issue18828 for more details.
Change-Id: I10d26d5ddc32e7ed04c5a412bdd6e13ec59eb70f
Diffstat (limited to 'manifest_xml.py')
-rw-r--r-- | manifest_xml.py | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/manifest_xml.py b/manifest_xml.py index 890c954d..8b57bf52 100644 --- a/manifest_xml.py +++ b/manifest_xml.py | |||
@@ -38,8 +38,9 @@ MANIFEST_FILE_NAME = 'manifest.xml' | |||
38 | LOCAL_MANIFEST_NAME = 'local_manifest.xml' | 38 | LOCAL_MANIFEST_NAME = 'local_manifest.xml' |
39 | LOCAL_MANIFESTS_DIR_NAME = 'local_manifests' | 39 | LOCAL_MANIFESTS_DIR_NAME = 'local_manifests' |
40 | 40 | ||
41 | urllib.parse.uses_relative.extend(['ssh', 'git']) | 41 | # urljoin gets confused if the scheme is not known. |
42 | urllib.parse.uses_netloc.extend(['ssh', 'git']) | 42 | urllib.parse.uses_relative.extend(['ssh', 'git', 'persistent-https', 'rpc']) |
43 | urllib.parse.uses_netloc.extend(['ssh', 'git', 'persistent-https', 'rpc']) | ||
43 | 44 | ||
44 | class _Default(object): | 45 | class _Default(object): |
45 | """Project defaults within the manifest.""" | 46 | """Project defaults within the manifest.""" |
@@ -85,21 +86,13 @@ class _XmlRemote(object): | |||
85 | # urljoin will gets confused over quite a few things. The ones we care | 86 | # urljoin will gets confused over quite a few things. The ones we care |
86 | # about here are: | 87 | # about here are: |
87 | # * no scheme in the base url, like <hostname:port> | 88 | # * no scheme in the base url, like <hostname:port> |
88 | # * persistent-https:// | 89 | # We handle no scheme by replacing it with an obscure protocol, gopher |
89 | # * rpc:// | 90 | # and then replacing it with the original when we are done. |
90 | # We handle this by replacing these with obscure protocols | 91 | |
91 | # and then replacing them with the original when we are done. | ||
92 | # gopher -> <none> | ||
93 | # wais -> persistent-https | ||
94 | # nntp -> rpc | ||
95 | if manifestUrl.find(':') != manifestUrl.find('/') - 1: | 92 | if manifestUrl.find(':') != manifestUrl.find('/') - 1: |
96 | manifestUrl = 'gopher://' + manifestUrl | 93 | url = urllib.parse.urljoin('gopher://' + manifestUrl, url)[9:] |
97 | manifestUrl = re.sub(r'^persistent-https://', 'wais://', manifestUrl) | 94 | else: |
98 | manifestUrl = re.sub(r'^rpc://', 'nntp://', manifestUrl) | 95 | url = urllib.parse.urljoin(manifestUrl, url) |
99 | url = urllib.parse.urljoin(manifestUrl, url) | ||
100 | url = re.sub(r'^gopher://', '', url) | ||
101 | url = re.sub(r'^wais://', 'persistent-https://', url) | ||
102 | url = re.sub(r'^nntp://', 'rpc://', url) | ||
103 | return url | 96 | return url |
104 | 97 | ||
105 | def ToRemoteSpec(self, projectName): | 98 | def ToRemoteSpec(self, projectName): |