--- a/mercurial/scmutil.py Sat Apr 30 19:36:48 2011 +0200
+++ b/mercurial/scmutil.py Sat Apr 30 19:37:13 2011 +0200
@@ -231,6 +231,16 @@
f.close()
self._fixfilemode(dst)
+class filteropener(abstractopener):
+ '''Wrapper opener for filtering filenames with a function.'''
+
+ def __init__(self, opener, filter):
+ self._filter = filter
+ self._orig = opener
+
+ def __call__(self, path, *args, **kwargs):
+ return self._orig(self._filter(path), *args, **kwargs)
+
def canonpath(root, cwd, myname, auditor=None):
'''return the canonical path of myname, given cwd and root'''
if util.endswithsep(root):
--- a/mercurial/store.py Sat Apr 30 19:36:48 2011 +0200
+++ b/mercurial/store.py Sat Apr 30 19:37:13 2011 +0200
@@ -6,7 +6,7 @@
# GNU General Public License version 2 or any later version.
from i18n import _
-import osutil, util
+import osutil, scmutil, util
import os, stat
_sha = util.sha1
@@ -241,7 +241,7 @@
self.createmode = _calcmode(path)
op = opener(self.path)
op.createmode = self.createmode
- self.opener = lambda f, *args, **kw: op(encodedir(f), *args, **kw)
+ self.opener = scmutil.filteropener(op, encodedir)
def join(self, f):
return self.path + '/' + encodedir(f)
@@ -290,7 +290,7 @@
self.createmode = _calcmode(self.path)
op = opener(self.path)
op.createmode = self.createmode
- self.opener = lambda f, *args, **kw: op(encodefilename(f), *args, **kw)
+ self.opener = scmutil.filteropener(op, encodefilename)
def datafiles(self):
for a, b, size in self._walk('data', True):