Mercurial > public > mercurial-scm > hg
comparison mercurial/vfs.py @ 51882:e59e1d8d29d2
vfs: do minor copyediting on comments and doc strings
These were flagged by PyCharm, so clear them from the gutter.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 20 Sep 2024 12:15:08 -0400 |
parents | adbb183c2f27 |
children | 38720073aa34 |
comparison
equal
deleted
inserted
replaced
51881:adbb183c2f27 | 51882:e59e1d8d29d2 |
---|---|
52 | 52 |
53 # default directory separator for vfs | 53 # default directory separator for vfs |
54 # | 54 # |
55 # Other vfs code always use `/` and this works fine because python file API | 55 # Other vfs code always use `/` and this works fine because python file API |
56 # abstract the use of `/` and make it work transparently. For consistency | 56 # abstract the use of `/` and make it work transparently. For consistency |
57 # vfs will always use `/` when joining. This avoid some confusion in | 57 # vfs will always use `/` when joining. This avoids some confusion in |
58 # encoded vfs (see issue6546) | 58 # encoded vfs (see issue6546) |
59 _dir_sep = b'/' | 59 _dir_sep = b'/' |
60 | 60 |
61 # TODO: type return, which is util.posixfile wrapped by a proxy | 61 # TODO: type return, which is util.posixfile wrapped by a proxy |
62 @abc.abstractmethod | 62 @abc.abstractmethod |
203 The initial motivation for this logic is that if mmap is used on NFS | 203 The initial motivation for this logic is that if mmap is used on NFS |
204 and somebody deletes the mapped file (e.g. by renaming on top of it), | 204 and somebody deletes the mapped file (e.g. by renaming on top of it), |
205 then you get SIGBUS, which can be pretty disruptive: we get core dump | 205 then you get SIGBUS, which can be pretty disruptive: we get core dump |
206 reports, and the process terminates without writing to the blackbox. | 206 reports, and the process terminates without writing to the blackbox. |
207 | 207 |
208 Instead in this situation we prefer to read the file normally. | 208 Instead, in this situation we prefer to read the file normally. |
209 The risk of ESTALE in the middle of the read remains, but it's | 209 The risk of ESTALE in the middle of the read remains, but it's |
210 smaller because we read sooner and the error should be reported | 210 smaller because we read sooner and the error should be reported |
211 just as any other error. | 211 just as any other error. |
212 | 212 |
213 Note that python standard library does not offer the necessary function | 213 Note that python standard library does not offer the necessary function |
345 | 345 |
346 def utime(self, path: Optional[bytes] = None, t=None): | 346 def utime(self, path: Optional[bytes] = None, t=None): |
347 return os.utime(self.join(path), t) | 347 return os.utime(self.join(path), t) |
348 | 348 |
349 def walk(self, path: Optional[bytes] = None, onerror=None): | 349 def walk(self, path: Optional[bytes] = None, onerror=None): |
350 """Yield (dirpath, dirs, files) tuple for each directories under path | 350 """Yield (dirpath, dirs, files) tuple for each directory under path |
351 | 351 |
352 ``dirpath`` is relative one from the root of this vfs. This | 352 ``dirpath`` is relative one from the root of this vfs. This |
353 uses ``os.sep`` as path separator, even you specify POSIX | 353 uses ``os.sep`` as path separator, even you specify POSIX |
354 style ``path``. | 354 style ``path``. |
355 | 355 |
685 | 685 |
686 | 686 |
687 class closewrapbase(abc.ABC): | 687 class closewrapbase(abc.ABC): |
688 """Base class of wrapper, which hooks closing | 688 """Base class of wrapper, which hooks closing |
689 | 689 |
690 Do not instantiate outside of the vfs layer. | 690 Do not instantiate outside the vfs layer. |
691 """ | 691 """ |
692 | 692 |
693 def __init__(self, fh): | 693 def __init__(self, fh): |
694 object.__setattr__(self, '_origfh', fh) | 694 object.__setattr__(self, '_origfh', fh) |
695 | 695 |
716 | 716 |
717 | 717 |
718 class delayclosedfile(closewrapbase): | 718 class delayclosedfile(closewrapbase): |
719 """Proxy for a file object whose close is delayed. | 719 """Proxy for a file object whose close is delayed. |
720 | 720 |
721 Do not instantiate outside of the vfs layer. | 721 Do not instantiate outside the vfs layer. |
722 """ | 722 """ |
723 | 723 |
724 def __init__(self, fh, closer): | 724 def __init__(self, fh, closer): |
725 super(delayclosedfile, self).__init__(fh) | 725 super(delayclosedfile, self).__init__(fh) |
726 object.__setattr__(self, '_closer', closer) | 726 object.__setattr__(self, '_closer', closer) |
807 raise error.Abort( | 807 raise error.Abort( |
808 _(b'can only call close() when context manager active') | 808 _(b'can only call close() when context manager active') |
809 ) | 809 ) |
810 | 810 |
811 # If a background thread encountered an exception, raise now so we fail | 811 # If a background thread encountered an exception, raise now so we fail |
812 # fast. Otherwise we may potentially go on for minutes until the error | 812 # fast. Otherwise, we may potentially go on for minutes until the error |
813 # is acted on. | 813 # is acted on. |
814 if self._threadexception: | 814 if self._threadexception: |
815 e = self._threadexception | 815 e = self._threadexception |
816 self._threadexception = None | 816 self._threadexception = None |
817 raise e | 817 raise e |
830 See also util.filestat for detail about "ambiguity of file stat". | 830 See also util.filestat for detail about "ambiguity of file stat". |
831 | 831 |
832 This proxy is useful only if the target file is guarded by any | 832 This proxy is useful only if the target file is guarded by any |
833 lock (e.g. repo.lock or repo.wlock) | 833 lock (e.g. repo.lock or repo.wlock) |
834 | 834 |
835 Do not instantiate outside of the vfs layer. | 835 Do not instantiate outside the vfs layer. |
836 """ | 836 """ |
837 | 837 |
838 def __init__(self, fh): | 838 def __init__(self, fh): |
839 super(checkambigatclosing, self).__init__(fh) | 839 super(checkambigatclosing, self).__init__(fh) |
840 object.__setattr__(self, '_oldstat', util.filestat.frompath(fh.name)) | 840 object.__setattr__(self, '_oldstat', util.filestat.frompath(fh.name)) |