##// END OF EJS Templates
add filteropener abstraction for store openers
Dan Villiom Podlaski Christiansen -
r14090:e24b5e3c default
parent child Browse files
Show More
@@ -231,6 +231,16 b' class opener(abstractopener):'
231 f.close()
231 f.close()
232 self._fixfilemode(dst)
232 self._fixfilemode(dst)
233
233
234 class filteropener(abstractopener):
235 '''Wrapper opener for filtering filenames with a function.'''
236
237 def __init__(self, opener, filter):
238 self._filter = filter
239 self._orig = opener
240
241 def __call__(self, path, *args, **kwargs):
242 return self._orig(self._filter(path), *args, **kwargs)
243
234 def canonpath(root, cwd, myname, auditor=None):
244 def canonpath(root, cwd, myname, auditor=None):
235 '''return the canonical path of myname, given cwd and root'''
245 '''return the canonical path of myname, given cwd and root'''
236 if util.endswithsep(root):
246 if util.endswithsep(root):
@@ -6,7 +6,7 b''
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import osutil, util
9 import osutil, scmutil, util
10 import os, stat
10 import os, stat
11
11
12 _sha = util.sha1
12 _sha = util.sha1
@@ -241,7 +241,7 b' class basicstore(object):'
241 self.createmode = _calcmode(path)
241 self.createmode = _calcmode(path)
242 op = opener(self.path)
242 op = opener(self.path)
243 op.createmode = self.createmode
243 op.createmode = self.createmode
244 self.opener = lambda f, *args, **kw: op(encodedir(f), *args, **kw)
244 self.opener = scmutil.filteropener(op, encodedir)
245
245
246 def join(self, f):
246 def join(self, f):
247 return self.path + '/' + encodedir(f)
247 return self.path + '/' + encodedir(f)
@@ -290,7 +290,7 b' class encodedstore(basicstore):'
290 self.createmode = _calcmode(self.path)
290 self.createmode = _calcmode(self.path)
291 op = opener(self.path)
291 op = opener(self.path)
292 op.createmode = self.createmode
292 op.createmode = self.createmode
293 self.opener = lambda f, *args, **kw: op(encodefilename(f), *args, **kw)
293 self.opener = scmutil.filteropener(op, encodefilename)
294
294
295 def datafiles(self):
295 def datafiles(self):
296 for a, b, size in self._walk('data', True):
296 for a, b, size in self._walk('data', True):
General Comments 0
You need to be logged in to leave comments. Login now