changeset 14091:0aa60e4e0b76

statichttprepo: make the opener a subclass of abstractopener
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sat, 30 Apr 2011 19:41:25 +0200
parents e24b5e3c2f27
children 222c8ec7a274
files mercurial/statichttprepo.py
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/statichttprepo.py	Sat Apr 30 19:37:13 2011 +0200
+++ b/mercurial/statichttprepo.py	Sat Apr 30 19:41:25 2011 +0200
@@ -9,7 +9,7 @@
 
 from i18n import _
 import changelog, byterange, url, error
-import localrepo, manifest, util, store
+import localrepo, manifest, util, scmutil, store
 import urllib, urllib2, errno
 
 class httprangereader(object):
@@ -67,17 +67,17 @@
     urlopener = url.opener(ui, authinfo)
     urlopener.add_handler(byterange.HTTPRangeHandler())
 
-    def opener(base):
-        """return a function that opens files over http"""
-        p = base
-        def o(path, mode="r", atomictemp=None):
+    class statichttpopener(scmutil.abstractopener):
+        def __init__(self, base):
+            self.base = base
+
+        def __call__(self, path, mode="r", atomictemp=None):
             if mode not in ('r', 'rb'):
                 raise IOError('Permission denied')
-            f = "/".join((p, urllib.quote(path)))
+            f = "/".join((self.base, urllib.quote(path)))
             return httprangereader(f, urlopener)
-        return o
 
-    return opener
+    return statichttpopener
 
 class statichttprepository(localrepo.localrepository):
     def __init__(self, ui, path):