##// END OF EJS Templates
added support for binary files, and, protection again unicode decode errors that might occure in changesets views
marcink -
r273:cad478ed default
parent child Browse files
Show More
@@ -48,17 +48,39 b' class ChangesetController(BaseController'
48
48
49 for node in c.changeset.added:
49 for node in c.changeset.added:
50 filenode_old = FileNode(node.path, '')
50 filenode_old = FileNode(node.path, '')
51 f_udiff = differ.get_udiff(filenode_old, node)
51 if filenode_old.is_binary or node.is_binary:
52 diff = differ.DiffProcessor(f_udiff).as_html()
52 diff = 'binary file'
53 c.changes.append(('added', node, diff))
53 else:
54 f_udiff = differ.get_udiff(filenode_old, node)
55 diff = differ.DiffProcessor(f_udiff).as_html()
56 try:
57 diff = unicode(diff)
58 except:
59 log.warning('Decoding failed of %s', filenode_old)
60 log.warning('Decoding failed of %s', node)
61 diff = 'unsupported type'
62 cs1 = None
63 cs2 = node.last_changeset.raw_id
64 c.changes.append(('added', node, diff, cs1, cs2))
54
65
55 for node in c.changeset.changed:
66 for node in c.changeset.changed:
56 filenode_old = c.changeset_old.get_node(node.path)
67 filenode_old = c.changeset_old.get_node(node.path)
57 f_udiff = differ.get_udiff(filenode_old, node)
68 if filenode_old.is_binary or node.is_binary:
58 diff = differ.DiffProcessor(f_udiff).as_html()
69 diff = 'binary file'
59 c.changes.append(('changed', node, diff))
70 else:
71 f_udiff = differ.get_udiff(filenode_old, node)
72 diff = differ.DiffProcessor(f_udiff).as_html()
73 try:
74 diff = unicode(diff)
75 except:
76 log.warning('Decoding failed of %s', filenode_old)
77 log.warning('Decoding failed of %s', node)
78 diff = 'unsupported type'
79 cs1 = filenode_old.last_changeset.raw_id
80 cs2 = node.last_changeset.raw_id
81 c.changes.append(('changed', node, diff, cs1, cs2))
60
82
61 for node in c.changeset.removed:
83 for node in c.changeset.removed:
62 c.changes.append(('removed', node, None))
84 c.changes.append(('removed', node, None, None, None))
63
85
64 return render('changeset/changeset.html')
86 return render('changeset/changeset.html')
General Comments 0
You need to be logged in to leave comments. Login now