##// END OF EJS Templates
vcsserver: made binary content check be calculated on vcsserver...
dan -
r3896:4b32a14b default
parent child Browse files
Show More
@@ -1054,6 +1054,12 b' class BaseCommit(object):'
1054 1054 """
1055 1055 raise NotImplementedError
1056 1056
1057 def is_node_binary(self, path):
1058 """
1059 Returns ``True`` is given path is a binary file
1060 """
1061 raise NotImplementedError
1062
1057 1063 def get_file_content(self, path):
1058 1064 """
1059 1065 Returns content of the file at the given `path`.
@@ -245,6 +245,10 b' class GitCommit(base.BaseCommit):'
245 245 def is_link(self, path):
246 246 return stat.S_ISLNK(self.get_file_mode(path))
247 247
248 def is_node_binary(self, path):
249 tree_id, _ = self._get_tree_id_for_path(path)
250 return self._remote.is_binary(tree_id)
251
248 252 def get_file_content(self, path):
249 253 """
250 254 Returns content of the file at given `path`.
@@ -58,10 +58,12 b' class GitInMemoryCommit(base.BaseInMemor'
58 58
59 59 updated = []
60 60 for node in self.added + self.changed:
61 if not node.is_binary:
61
62 if node.is_binary:
63 content = node.content
64 else:
62 65 content = node.content.encode(ENCODING)
63 else:
64 content = node.content
66
65 67 updated.append({
66 68 'path': node.path,
67 69 'node_path': node.name.encode(ENCODING),
@@ -231,6 +231,10 b' class MercurialCommit(base.BaseCommit):'
231 231 path = self._get_filectx(path)
232 232 return 'l' in self._remote.fctx_flags(self.raw_id, path)
233 233
234 def is_node_binary(self, path):
235 path = self._get_filectx(path)
236 return self._remote.is_binary(self.raw_id, path)
237
234 238 def get_file_content(self, path):
235 239 """
236 240 Returns content of the file at given ``path``.
@@ -108,6 +108,10 b' class SubversionCommit(base.BaseCommit):'
108 108 return self.get_file_content(path).startswith('link')
109 109 return False
110 110
111 def is_node_binary(self, path):
112 path = self._fix_path(path)
113 return self._remote.is_binary(self._svn_rev, safe_str(path))
114
111 115 def _get_file_property(self, path, name):
112 116 file_properties = self._remote.node_properties(
113 117 safe_str(path), self._svn_rev)
@@ -377,9 +377,7 b' class FileNode(Node):'
377 377 """
378 378 if self.commit:
379 379 return self.commit.get_file_content_streamed(self.path)
380 raise NodeError(
381 "Cannot retrieve message of the file without related "
382 "commit attribute")
380 raise NodeError("Cannot retrieve stream_bytes without related commit attribute")
383 381
384 382 @LazyProperty
385 383 def md5(self):
@@ -581,8 +579,11 b' class FileNode(Node):'
581 579 """
582 580 Returns True if file has binary content.
583 581 """
584 _bin = self.raw_bytes and '\0' in self.raw_bytes
585 return _bin
582 if self.commit:
583 return self.commit.is_node_binary(self.path)
584 else:
585 raw_bytes = self._content
586 return raw_bytes and '\0' in raw_bytes
586 587
587 588 @LazyProperty
588 589 def extension(self):
@@ -742,8 +743,7 b' class DirNode(Node):'
742 743 return self._nodes_dict[path]
743 744 elif len(paths) > 1:
744 745 if self.commit is None:
745 raise NodeError(
746 "Cannot access deeper nodes without commit")
746 raise NodeError("Cannot access deeper nodes without commit")
747 747 else:
748 748 path1, path2 = paths[0], '/'.join(paths[1:])
749 749 return self.get_node(path1).get_node(path2)
General Comments 0
You need to be logged in to leave comments. Login now