Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/scmutil.py @ 17649:f65c6a5f256c
scmutil: rename classes from "opener" to "vfs"
For backwards compatibility, aliases for the old names are added,
except for "abstractopener", "statichttpopener" and "_fncacheopener",
because these are not used in Mercurial core implementation after this
patch.
"_fncacheopener" was only referred in "fncachestore" constructor, so
this patch also renames from "_fncacheopener" to "_fncachevfs" there.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 31 Aug 2012 02:06:29 +0900 |
parents | 4647aa33ad81 |
children | 8575f4a2126e |
comparison
equal
deleted
inserted
replaced
17648:07f1ac17b722 | 17649:f65c6a5f256c |
---|---|
165 self.audited.add(normpath) | 165 self.audited.add(normpath) |
166 # only add prefixes to the cache after checking everything: we don't | 166 # only add prefixes to the cache after checking everything: we don't |
167 # want to add "foo/bar/baz" before checking if there's a "foo/.hg" | 167 # want to add "foo/bar/baz" before checking if there's a "foo/.hg" |
168 self.auditeddir.update(prefixes) | 168 self.auditeddir.update(prefixes) |
169 | 169 |
170 class abstractopener(object): | 170 class abstractvfs(object): |
171 """Abstract base class; cannot be instantiated""" | 171 """Abstract base class; cannot be instantiated""" |
172 | 172 |
173 def __init__(self, *args, **kwargs): | 173 def __init__(self, *args, **kwargs): |
174 '''Prevent instantiation; don't call this from subclasses.''' | 174 '''Prevent instantiation; don't call this from subclasses.''' |
175 raise NotImplementedError('attempted instantiating ' + str(type(self))) | 175 raise NotImplementedError('attempted instantiating ' + str(type(self))) |
217 return util.makedir(self.join(path), notindexed) | 217 return util.makedir(self.join(path), notindexed) |
218 | 218 |
219 def makedirs(self, path=None, mode=None): | 219 def makedirs(self, path=None, mode=None): |
220 return util.makedirs(self.join(path), mode) | 220 return util.makedirs(self.join(path), mode) |
221 | 221 |
222 class opener(abstractopener): | 222 class vfs(abstractvfs): |
223 '''Open files relative to a base directory | 223 '''Operate files relative to a base directory |
224 | 224 |
225 This class is used to hide the details of COW semantics and | 225 This class is used to hide the details of COW semantics and |
226 remote file access from higher level code. | 226 remote file access from higher level code. |
227 ''' | 227 ''' |
228 def __init__(self, base, audit=True, expand=False): | 228 def __init__(self, base, audit=True, expand=False): |
333 def join(self, path): | 333 def join(self, path): |
334 if path: | 334 if path: |
335 return path.startswith('/') and path or (self.basesep + path) | 335 return path.startswith('/') and path or (self.basesep + path) |
336 return self.base | 336 return self.base |
337 | 337 |
338 class filteropener(abstractopener): | 338 opener = vfs |
339 '''Wrapper opener for filtering filenames with a function.''' | 339 |
340 class filtervfs(abstractvfs): | |
341 '''Wrapper vfs for filtering filenames with a function.''' | |
340 | 342 |
341 def __init__(self, opener, filter): | 343 def __init__(self, opener, filter): |
342 self._filter = filter | 344 self._filter = filter |
343 self._orig = opener | 345 self._orig = opener |
344 | 346 |
345 def __call__(self, path, *args, **kwargs): | 347 def __call__(self, path, *args, **kwargs): |
346 return self._orig(self._filter(path), *args, **kwargs) | 348 return self._orig(self._filter(path), *args, **kwargs) |
349 | |
350 filteropener = filtervfs | |
347 | 351 |
348 def canonpath(root, cwd, myname, auditor=None): | 352 def canonpath(root, cwd, myname, auditor=None): |
349 '''return the canonical path of myname, given cwd and root''' | 353 '''return the canonical path of myname, given cwd and root''' |
350 if util.endswithsep(root): | 354 if util.endswithsep(root): |
351 rootsep = root | 355 rootsep = root |