##// END OF EJS Templates
diffs: fixed problem with potential diff display.
milka -
r4592:8ef51af3 stable
parent child Browse files
Show More
@@ -398,7 +398,10 b' class DiffSet(object):'
398 398 ):
399 399
400 400 self.highlight_mode = highlight_mode
401 self.highlighted_filenodes = {}
401 self.highlighted_filenodes = {
402 'before': {},
403 'after': {}
404 }
402 405 self.source_node_getter = source_node_getter
403 406 self.target_node_getter = target_node_getter
404 407 self.source_nodes = source_nodes or {}
@@ -657,7 +660,7 b' class DiffSet(object):'
657 660 else:
658 661 before_tokens = self.get_line_tokens(
659 662 line_text=before['line'], line_number=before['old_lineno'],
660 input_file=source_file, no_hl=no_hl)
663 input_file=source_file, no_hl=no_hl, source='before')
661 664 original.lineno = before['old_lineno']
662 665 original.content = before['line']
663 666 original.action = self.action_to_op(before['action'])
@@ -671,7 +674,7 b' class DiffSet(object):'
671 674 else:
672 675 after_tokens = self.get_line_tokens(
673 676 line_text=after['line'], line_number=after['new_lineno'],
674 input_file=target_file, no_hl=no_hl)
677 input_file=target_file, no_hl=no_hl, source='after')
675 678 modified.lineno = after['new_lineno']
676 679 modified.content = after['line']
677 680 modified.action = self.action_to_op(after['action'])
@@ -705,7 +708,7 b' class DiffSet(object):'
705 708
706 709 return lines
707 710
708 def get_line_tokens(self, line_text, line_number, input_file=None, no_hl=False):
711 def get_line_tokens(self, line_text, line_number, input_file=None, no_hl=False, source=''):
709 712 filenode = None
710 713 filename = None
711 714
@@ -720,8 +723,7 b' class DiffSet(object):'
720 723 lexer = self._get_lexer_for_filename(filename)
721 724 file_size_allowed = input_file.size < self.max_file_size_limit
722 725 if line_number and file_size_allowed:
723 return self.get_tokenized_filenode_line(
724 input_file, line_number, lexer)
726 return self.get_tokenized_filenode_line(input_file, line_number, lexer, source)
725 727
726 728 if hl_mode in (self.HL_REAL, self.HL_FAST) and filename:
727 729 lexer = self._get_lexer_for_filename(filename)
@@ -729,17 +731,19 b' class DiffSet(object):'
729 731
730 732 return list(tokenize_string(line_text, plain_text_lexer))
731 733
732 def get_tokenized_filenode_line(self, filenode, line_number, lexer=None):
734 def get_tokenized_filenode_line(self, filenode, line_number, lexer=None, source=''):
733 735
734 if filenode not in self.highlighted_filenodes:
735 tokenized_lines = filenode_as_lines_tokens(filenode, lexer)
736 self.highlighted_filenodes[filenode] = tokenized_lines
736 def tokenize(_filenode):
737 self.highlighted_filenodes[source][filenode] = filenode_as_lines_tokens(filenode, lexer)
738
739 if filenode not in self.highlighted_filenodes[source]:
740 tokenize(filenode)
737 741
738 742 try:
739 return self.highlighted_filenodes[filenode][line_number - 1]
743 return self.highlighted_filenodes[source][filenode][line_number - 1]
740 744 except Exception:
741 745 log.exception('diff rendering error')
742 return [('', u'rhodecode diff rendering error')]
746 return [('', u'L{}: rhodecode diff rendering error'.format(line_number))]
743 747
744 748 def action_to_op(self, action):
745 749 return {
General Comments 0
You need to be logged in to leave comments. Login now