Changeset - cad478edb1c7
[Not reviewed]
default
0 1 0
Marcin Kuzminski - 15 years ago 2010-06-08 23:48:41
marcin@python-works.com
added support for binary files, and, protection again unicode decode errors that might occure in changesets views
1 file changed with 29 insertions and 7 deletions:
0 comments (0 inline, 0 general)
pylons_app/controllers/changeset.py
Show inline comments
 
@@ -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')
0 comments (0 inline, 0 general)