summaryrefslogtreecommitdiff
path: root/morphlib/localrepocache.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-05-02 18:03:44 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-05-02 18:03:44 +0100
commitdc7f4153ae6f74fe747117154e02a2198be6e8c2 (patch)
tree5ce9a2af402565749ecb8dd32e1c115d254be8d1 /morphlib/localrepocache.py
parentc70d96187f13d63a06f36ec96be2a6033e507e41 (diff)
downloadmorph-dc7f4153ae6f74fe747117154e02a2198be6e8c2.tar.gz
Get rid of the old internal morph APIs
Diffstat (limited to 'morphlib/localrepocache.py')
-rw-r--r--morphlib/localrepocache.py23
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)