diff options
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r-- | morphlib/localrepocache.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/morphlib/localrepocache.py b/morphlib/localrepocache.py index b8dfea88..a3e28d57 100644 --- a/morphlib/localrepocache.py +++ b/morphlib/localrepocache.py @@ -19,6 +19,7 @@ import os import urllib2 import urlparse import shutil +import string import morphlib @@ -34,6 +35,19 @@ urlparse.uses_fragment.extend(gitscheme) +def quote_url(url): + ''' Convert URIs to strings that only contain digits, letters, % and _. + + NOTE: When changing the code of this function, make sure to also apply + the same to the quote_url() function of lorry. Otherwise the git bundles + generated by lorry may no longer be found by morph. + + ''' + valid_chars = string.digits + string.letters + '%_' + transl = lambda x: x if x in valid_chars else '_' + return ''.join([transl(x) for x in url]) + + class NoRemote(morphlib.Error): def __init__(self, reponame, errors): @@ -151,13 +165,12 @@ class LocalRepoCache(object): def _escape(self, url): '''Escape a URL so it can be used as a basename in a file.''' - # FIXME: The following is a nicer way than what source manager does. - # However, for compatibility, we need to use the same as the source - # manager uses, since that's what the bundle server (set up by - # Lorry) uses. + # FIXME: The following is a nicer way than to do this. + # However, for compatibility, we need to use the same as the + # bundle server (set up by Lorry) uses. # return urllib.quote(url, safe='') - return morphlib.sourcemanager.quote_url(url) + return quote_url(url) def _cache_name(self, url): basename = self._escape(url) |