Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 17161:be016e96117a
localrepo: use file API via vfs while ensuring repository directory
As a part of migration to vfs, this patch invokes some file API
indirectly via vfs, while ensuring repository directory in the
constructor of "localrepository" class.
New file API are added to "scmutil.abstractopener" class, because they
are also used via other derived classes than "scmutil.opener".
But "join()" is not yet defined other than "scmutil.opener" class,
because it should not be used via other opener classes yet.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 06 Jul 2012 18:45:27 +0900 |
parents | 87e8440964a0 |
children | afd75476939e |
comparison
equal
deleted
inserted
replaced
17160:22b9b1d2f5d4 | 17161:be016e96117a |
---|---|
187 fp = self(path, 'ab') | 187 fp = self(path, 'ab') |
188 try: | 188 try: |
189 return fp.write(data) | 189 return fp.write(data) |
190 finally: | 190 finally: |
191 fp.close() | 191 fp.close() |
192 | |
193 def mkdir(self, path=None): | |
194 return os.mkdir(self.join(path)) | |
195 | |
196 def exists(self, path=None): | |
197 return os.path.exists(self.join(path)) | |
198 | |
199 def isdir(self, path=None): | |
200 return os.path.isdir(self.join(path)) | |
201 | |
202 def makedir(self, path=None, notindexed=True): | |
203 return util.makedir(self.join(path), notindexed) | |
204 | |
205 def makedirs(self, path=None, mode=None): | |
206 return util.makedirs(self.join(path), mode) | |
192 | 207 |
193 class opener(abstractopener): | 208 class opener(abstractopener): |
194 '''Open files relative to a base directory | 209 '''Open files relative to a base directory |
195 | 210 |
196 This class is used to hide the details of COW semantics and | 211 This class is used to hide the details of COW semantics and |
291 | 306 |
292 def audit(self, path): | 307 def audit(self, path): |
293 self.auditor(path) | 308 self.auditor(path) |
294 | 309 |
295 def join(self, path): | 310 def join(self, path): |
296 return os.path.join(self.base, path) | 311 if path: |
312 return os.path.join(self.base, path) | |
313 else: | |
314 return self.base | |
297 | 315 |
298 class filteropener(abstractopener): | 316 class filteropener(abstractopener): |
299 '''Wrapper opener for filtering filenames with a function.''' | 317 '''Wrapper opener for filtering filenames with a function.''' |
300 | 318 |
301 def __init__(self, opener, filter): | 319 def __init__(self, opener, filter): |