From dc7f4153ae6f74fe747117154e02a2198be6e8c2 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 2 May 2012 18:03:44 +0100 Subject: Get rid of the old internal morph APIs --- morphlib/localrepocache.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'morphlib/localrepocache.py') 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) -- cgit v1.2.1