##// END OF EJS Templates
blame: use BinaryEnvelope wrapper to handle raw non-ascii content of files
super-admin -
r1139:1b29ba78 default
parent child Browse files
Show More
@@ -187,7 +187,7 b' class BytesEnvelope(bytes):'
187 if isinstance(content, bytes):
187 if isinstance(content, bytes):
188 return super().__new__(cls, content)
188 return super().__new__(cls, content)
189 else:
189 else:
190 raise TypeError('Content must be bytes.')
190 raise TypeError('BytesEnvelope content= param must be bytes. Use BinaryEnvelope to wrap other types')
191
191
192
192
193 class BinaryBytesEnvelope(BytesEnvelope):
193 class BinaryBytesEnvelope(BytesEnvelope):
@@ -1307,7 +1307,7 b' class GitRemote(RemoteBase):'
1307
1307
1308 result_libgit.append((line_no, blame_commit_id, line))
1308 result_libgit.append((line_no, blame_commit_id, line))
1309
1309
1310 return result_libgit
1310 return BinaryEnvelope(result_libgit)
1311
1311
1312 @reraise_safe_exceptions
1312 @reraise_safe_exceptions
1313 def update_server_info(self, wire):
1313 def update_server_info(self, wire):
@@ -598,8 +598,8 b' class HgRemote(RemoteBase):'
598 ln_no = i
598 ln_no = i
599 sha = hex(annotate_obj.fctx.node())
599 sha = hex(annotate_obj.fctx.node())
600 content = annotate_obj.text
600 content = annotate_obj.text
601 result.append((ln_no, sha, content))
601 result.append((ln_no, ascii_str(sha), content))
602 return result
602 return BinaryEnvelope(result)
603
603
604 @reraise_safe_exceptions
604 @reraise_safe_exceptions
605 def fctx_node_data(self, wire, revision, path):
605 def fctx_node_data(self, wire, revision, path):
@@ -344,10 +344,10 b' class SvnRemote(RemoteBase):'
344 except svn.core.SubversionException as exc:
344 except svn.core.SubversionException as exc:
345 log.exception("Error during blame operation.")
345 log.exception("Error during blame operation.")
346 raise Exception(
346 raise Exception(
347 "Blame not supported or file does not exist at path %s. "
347 f"Blame not supported or file does not exist at path {path}. "
348 "Error %s." % (path, exc))
348 f"Error {exc}.")
349
349
350 return annotations
350 return BinaryEnvelope(annotations)
351
351
352 @reraise_safe_exceptions
352 @reraise_safe_exceptions
353 def get_node_type(self, wire, revision=None, path=''):
353 def get_node_type(self, wire, revision=None, path=''):
General Comments 0
You need to be logged in to leave comments. Login now