Mercurial > public > mercurial-scm > hg
comparison mercurial/vfs.py @ 40754:34f15db81cf0
vfs: extract the audit path logic into a submethod
This will make it possible to apply it in more cases.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Sun, 02 Jul 2017 04:06:24 +0200 |
parents | 5fe0b880200e |
children | 03bca908d9fb |
comparison
equal
deleted
inserted
replaced
40753:9199548525fc | 40754:34f15db81cf0 |
---|---|
335 def _fixfilemode(self, name): | 335 def _fixfilemode(self, name): |
336 if self.createmode is None or not self._chmod: | 336 if self.createmode is None or not self._chmod: |
337 return | 337 return |
338 os.chmod(name, self.createmode & 0o666) | 338 os.chmod(name, self.createmode & 0o666) |
339 | 339 |
340 def _auditpath(self, path, mode): | |
341 if self._audit: | |
342 r = util.checkosfilename(path) | |
343 if r: | |
344 raise error.Abort("%s: %r" % (r, path)) | |
345 self.audit(path, mode=mode) | |
346 | |
340 def __call__(self, path, mode="r", atomictemp=False, notindexed=False, | 347 def __call__(self, path, mode="r", atomictemp=False, notindexed=False, |
341 backgroundclose=False, checkambig=False, auditpath=True): | 348 backgroundclose=False, checkambig=False, auditpath=True): |
342 '''Open ``path`` file, which is relative to vfs root. | 349 '''Open ``path`` file, which is relative to vfs root. |
343 | 350 |
344 Newly created directories are marked as "not to be indexed by | 351 Newly created directories are marked as "not to be indexed by |
367 truncation), if it is owned by another. Therefore, use | 374 truncation), if it is owned by another. Therefore, use |
368 combination of append mode and checkambig=True only in limited | 375 combination of append mode and checkambig=True only in limited |
369 cases (see also issue5418 and issue5584 for detail). | 376 cases (see also issue5418 and issue5584 for detail). |
370 ''' | 377 ''' |
371 if auditpath: | 378 if auditpath: |
372 if self._audit: | 379 self._auditpath(path, mode) |
373 r = util.checkosfilename(path) | |
374 if r: | |
375 raise error.Abort("%s: %r" % (r, path)) | |
376 self.audit(path, mode=mode) | |
377 f = self.join(path) | 380 f = self.join(path) |
378 | 381 |
379 if "b" not in mode: | 382 if "b" not in mode: |
380 mode += "b" # for that other OS | 383 mode += "b" # for that other OS |
381 | 384 |