comparison mercurial/scmutil.py @ 18327:4aecdb91443c

scmutil: simplify vfs.audit - drop wrapped vfs.auditor
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 09 Jan 2013 00:01:33 +0100
parents f36375576ed5
children 4f9a52858512
comparison
equal deleted inserted replaced
18326:614f769e6aa7 18327:4aecdb91443c
250 return self._audit 250 return self._audit
251 251
252 def _setmustaudit(self, onoff): 252 def _setmustaudit(self, onoff):
253 self._audit = onoff 253 self._audit = onoff
254 if onoff: 254 if onoff:
255 self.auditor = pathauditor(self.base) 255 self.audit = pathauditor(self.base)
256 else: 256 else:
257 self.auditor = util.always 257 self.audit = util.always
258 258
259 mustaudit = property(_getmustaudit, _setmustaudit) 259 mustaudit = property(_getmustaudit, _setmustaudit)
260 260
261 @util.propertycache 261 @util.propertycache
262 def _cansymlink(self): 262 def _cansymlink(self):
274 def __call__(self, path, mode="r", text=False, atomictemp=False): 274 def __call__(self, path, mode="r", text=False, atomictemp=False):
275 if self._audit: 275 if self._audit:
276 r = util.checkosfilename(path) 276 r = util.checkosfilename(path)
277 if r: 277 if r:
278 raise util.Abort("%s: %r" % (r, path)) 278 raise util.Abort("%s: %r" % (r, path))
279 self.auditor(path) 279 self.audit(path)
280 f = self.join(path) 280 f = self.join(path)
281 281
282 if not text and "b" not in mode: 282 if not text and "b" not in mode:
283 mode += "b" # for that other OS 283 mode += "b" # for that other OS
284 284
319 if nlink == 0: 319 if nlink == 0:
320 self._fixfilemode(f) 320 self._fixfilemode(f)
321 return fp 321 return fp
322 322
323 def symlink(self, src, dst): 323 def symlink(self, src, dst):
324 self.auditor(dst) 324 self.audit(dst)
325 linkname = self.join(dst) 325 linkname = self.join(dst)
326 try: 326 try:
327 os.unlink(linkname) 327 os.unlink(linkname)
328 except OSError: 328 except OSError:
329 pass 329 pass
338 except OSError, err: 338 except OSError, err:
339 raise OSError(err.errno, _('could not symlink to %r: %s') % 339 raise OSError(err.errno, _('could not symlink to %r: %s') %
340 (src, err.strerror), linkname) 340 (src, err.strerror), linkname)
341 else: 341 else:
342 self.write(dst, src) 342 self.write(dst, src)
343
344 def audit(self, path):
345 self.auditor(path)
346 343
347 def join(self, path): 344 def join(self, path):
348 if path: 345 if path:
349 return os.path.join(self.base, path) 346 return os.path.join(self.base, path)
350 else: 347 else: