diff mercurial/statichttprepo.py @ 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 924c82157d46
children 135e244776f0
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):