818 return |
818 return |
819 |
819 |
820 # Simple case writes all data on a single line. |
820 # Simple case writes all data on a single line. |
821 if b'\n' not in data: |
821 if b'\n' not in data: |
822 if self.logdataapis: |
822 if self.logdataapis: |
823 self.fh.write(': %s\n' % escapedata(data)) |
823 self.fh.write(': %s\n' % stringutil.escapedata(data)) |
824 else: |
824 else: |
825 self.fh.write('%s> %s\n' % (self.name, escapedata(data))) |
825 self.fh.write('%s> %s\n' |
|
826 % (self.name, stringutil.escapedata(data))) |
826 self.fh.flush() |
827 self.fh.flush() |
827 return |
828 return |
828 |
829 |
829 # Data with newlines is written to multiple lines. |
830 # Data with newlines is written to multiple lines. |
830 if self.logdataapis: |
831 if self.logdataapis: |
831 self.fh.write(':\n') |
832 self.fh.write(':\n') |
832 |
833 |
833 lines = data.splitlines(True) |
834 lines = data.splitlines(True) |
834 for line in lines: |
835 for line in lines: |
835 self.fh.write('%s> %s\n' % (self.name, escapedata(line))) |
836 self.fh.write('%s> %s\n' |
|
837 % (self.name, stringutil.escapedata(line))) |
836 self.fh.flush() |
838 self.fh.flush() |
837 |
839 |
838 class fileobjectobserver(baseproxyobserver): |
840 class fileobjectobserver(baseproxyobserver): |
839 """Logs file object activity.""" |
841 """Logs file object activity.""" |
840 def __init__(self, fh, name, reads=True, writes=True, logdata=False, |
842 def __init__(self, fh, name, reads=True, writes=True, logdata=False, |
1913 if c in _winreservedchars: |
1915 if c in _winreservedchars: |
1914 return _("filename contains '%s', which is reserved " |
1916 return _("filename contains '%s', which is reserved " |
1915 "on Windows") % c |
1917 "on Windows") % c |
1916 if ord(c) <= 31: |
1918 if ord(c) <= 31: |
1917 return _("filename contains '%s', which is invalid " |
1919 return _("filename contains '%s', which is invalid " |
1918 "on Windows") % escapestr(c) |
1920 "on Windows") % stringutil.escapestr(c) |
1919 base = n.split('.')[0] |
1921 base = n.split('.')[0] |
1920 if base and base.lower() in _winreservednames: |
1922 if base and base.lower() in _winreservednames: |
1921 return _("filename contains '%s', which is reserved " |
1923 return _("filename contains '%s', which is reserved " |
1922 "on Windows") % base |
1924 "on Windows") % base |
1923 t = n[-1:] |
1925 t = n[-1:] |
3677 def decompress(self, data): |
3679 def decompress(self, data): |
3678 try: |
3680 try: |
3679 return zlib.decompress(data) |
3681 return zlib.decompress(data) |
3680 except zlib.error as e: |
3682 except zlib.error as e: |
3681 raise error.RevlogError(_('revlog decompress error: %s') % |
3683 raise error.RevlogError(_('revlog decompress error: %s') % |
3682 forcebytestr(e)) |
3684 stringutil.forcebytestr(e)) |
3683 |
3685 |
3684 def revlogcompressor(self, opts=None): |
3686 def revlogcompressor(self, opts=None): |
3685 return self.zlibrevlogcompressor() |
3687 return self.zlibrevlogcompressor() |
3686 |
3688 |
3687 compengines.register(_zlibengine()) |
3689 compengines.register(_zlibengine()) |
3903 # Frame should be exhausted, so no finish() API. |
3905 # Frame should be exhausted, so no finish() API. |
3904 |
3906 |
3905 return ''.join(chunks) |
3907 return ''.join(chunks) |
3906 except Exception as e: |
3908 except Exception as e: |
3907 raise error.RevlogError(_('revlog decompress error: %s') % |
3909 raise error.RevlogError(_('revlog decompress error: %s') % |
3908 forcebytestr(e)) |
3910 stringutil.forcebytestr(e)) |
3909 |
3911 |
3910 def revlogcompressor(self, opts=None): |
3912 def revlogcompressor(self, opts=None): |
3911 opts = opts or {} |
3913 opts = opts or {} |
3912 return self.zstdrevlogcompressor(self._module, |
3914 return self.zstdrevlogcompressor(self._module, |
3913 level=opts.get('level', 3)) |
3915 level=opts.get('level', 3)) |