Changeset - 0c065f793d0e
[Not reviewed]
beta
0 1 0
Marcin Kuzminski - 15 years ago 2010-11-03 16:29:12
marcin@python-works.com
fixed raw diff breakline bug
1 file changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/changeset.py
Show inline comments
 
@@ -130,56 +130,58 @@ class ChangesetController(BaseController
 

	
 
        return render('changeset/changeset.html')
 

	
 
    def raw_changeset(self, revision):
 

	
 
        hg_model = HgModel()
 
        method = request.GET.get('diff', 'show')
 
        try:
 
            r = hg_model.get_repo(c.repo_name)
 
            c.scm_type = r.alias
 
            c.changeset = r.get_changeset(revision)
 
        except RepositoryError:
 
            log.error(traceback.format_exc())
 
            return redirect(url('home'))
 
        else:
 
            try:
 
                c.changeset_old = c.changeset.parents[0]
 
            except IndexError:
 
                c.changeset_old = None
 
            c.changes = []
 

	
 
            for node in c.changeset.added:
 
                filenode_old = FileNode(node.path, '')
 
                if filenode_old.is_binary or node.is_binary:
 
                    diff = _('binary file')
 
                    diff = _('binary file') +'\n'
 
                else:
 
                    f_udiff = differ.get_udiff(filenode_old, node)
 
                    diff = differ.DiffProcessor(f_udiff).raw_diff()
 

	
 
                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)
 
                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).raw_diff()
 

	
 
                cs1 = filenode_old.last_changeset.raw_id
 
                cs2 = node.last_changeset.raw_id
 
                c.changes.append(('changed', node, diff, cs1, cs2))
 

	
 
        response.content_type = 'text/plain'
 
        
 
        if method == 'download':
 
            response.content_disposition = 'attachment; filename=%s.patch' % revision
 
            
 
        parent = True if len(c.changeset.parents) > 0 else False
 
        c.parent_tmpl = 'Parent  %s' % c.changeset.parents[0].raw_id if parent else ''
 

	
 
        c.diffs = ''
 
        for x in c.changes:
 
            c.diffs += x[2]
 
        
 
        return render('changeset/raw_changeset.html')
0 comments (0 inline, 0 general)