aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcin Kuzminski <marcin@python-works.com>2010-06-08 23:48:41 +0200
committerMarcin Kuzminski <marcin@python-works.com>2010-06-08 23:48:41 +0200
commit4915da7b700097334f212fab33200ed60d8885dc (patch)
treeea9708a08a00ff14adff8bef46ee0583bba6b6da
parentbd6053f794e3e29ca0f6b5c6b9958d24a20b26b5 (diff)
added support for binary files, and, protection again unicode decode errors that might occure in changesets views
-rw-r--r--pylons_app/controllers/changeset.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/pylons_app/controllers/changeset.py b/pylons_app/controllers/changeset.py
index 58fa1a23..8f77da57 100644
--- a/pylons_app/controllers/changeset.py
+++ b/pylons_app/controllers/changeset.py
@@ -48,17 +48,39 @@ class ChangesetController(BaseController):
for node in c.changeset.added:
filenode_old = FileNode(node.path, '')
- f_udiff = differ.get_udiff(filenode_old, node)
- diff = differ.DiffProcessor(f_udiff).as_html()
- c.changes.append(('added', node, diff))
+ if filenode_old.is_binary or node.is_binary:
+ diff = 'binary file'
+ else:
+ f_udiff = differ.get_udiff(filenode_old, node)
+ diff = differ.DiffProcessor(f_udiff).as_html()
+ try:
+ diff = unicode(diff)
+ except:
+ log.warning('Decoding failed of %s', filenode_old)
+ log.warning('Decoding failed of %s', node)
+ diff = 'unsupported type'
+ cs1 = None
+ cs2 = node.last_changeset.raw_id
+ c.changes.append(('added', node, diff, cs1, cs2))
for node in c.changeset.changed:
filenode_old = c.changeset_old.get_node(node.path)
- f_udiff = differ.get_udiff(filenode_old, node)
- diff = differ.DiffProcessor(f_udiff).as_html()
- c.changes.append(('changed', node, diff))
+ if filenode_old.is_binary or node.is_binary:
+ diff = 'binary file'
+ else:
+ f_udiff = differ.get_udiff(filenode_old, node)
+ diff = differ.DiffProcessor(f_udiff).as_html()
+ try:
+ diff = unicode(diff)
+ except:
+ log.warning('Decoding failed of %s', filenode_old)
+ log.warning('Decoding failed of %s', node)
+ diff = 'unsupported type'
+ cs1 = filenode_old.last_changeset.raw_id
+ cs2 = node.last_changeset.raw_id
+ c.changes.append(('changed', node, diff, cs1, cs2))
for node in c.changeset.removed:
- c.changes.append(('removed', node, None))
+ c.changes.append(('removed', node, None, None, None))
return render('changeset/changeset.html')