Mercurial > public > mercurial-scm > hg
diff mercurial/scmutil.py @ 14090:e24b5e3c2f27
add filteropener abstraction for store openers
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Sat, 30 Apr 2011 19:37:13 +0200 |
parents | d3f7e110c3c0 |
children | ca3376f044f8 |
line wrap: on
line diff
--- 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):