##// END OF EJS Templates
first implementation of #34 changeset raw diff based on udiff from python
marcink -
r466:183cee11 default
parent child Browse files
Show More
@@ -0,0 +1,8 b''
1 # HG changeset patch
2 # User ${c.changeset.author}
3 # Date ${"%d %d" % c.changeset._ctx.date()}
4 # Node ID ${c.changeset._hex}
5 # ${c.parent_tmpl}
6 ${c.changeset.message}
7
8 ${c.diffs|n} No newline at end of file
@@ -128,6 +128,9 b' def make_map(config):'
128 128 map.connect('changeset_home', '/{repo_name:.*}/changeset/{revision}',
129 129 controller='changeset', revision='tip',
130 130 conditions=dict(function=check_repo))
131 map.connect('raw_changeset_home', '/{repo_name:.*}/raw-changeset/{revision}',
132 controller='changeset',action='raw_changeset', revision='tip',
133 conditions=dict(function=check_repo))
131 134 map.connect('summary_home', '/{repo_name:.*}/summary',
132 135 controller='summary', conditions=dict(function=check_repo))
133 136 map.connect('shortlog_home', '/{repo_name:.*}/shortlog',
@@ -2,7 +2,6 b''
2 2 # encoding: utf-8
3 3 # changeset controller for pylons
4 4 # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com>
5
6 5 # This program is free software; you can redistribute it and/or
7 6 # modify it under the terms of the GNU General Public License
8 7 # as published by the Free Software Foundation; version 2
@@ -22,7 +21,7 b' Created on April 25, 2010'
22 21 changeset controller for pylons
23 22 @author: marcink
24 23 """
25 from pylons import tmpl_context as c, url, request
24 from pylons import tmpl_context as c, url, request, response
26 25 from pylons.controllers.util import redirect
27 26 from pylons_app.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
28 27 from pylons_app.lib.base import BaseController, render
@@ -64,12 +63,7 b' class ChangesetController(BaseController'
64 63 else:
65 64 f_udiff = differ.get_udiff(filenode_old, node)
66 65 diff = differ.DiffProcessor(f_udiff).as_html()
67 try:
68 diff = unicode(diff)
69 except:
70 log.warning('Decoding failed of %s', filenode_old)
71 log.warning('Decoding failed of %s', node)
72 diff = 'unsupported type'
66
73 67 cs1 = None
74 68 cs2 = node.last_changeset.raw_id
75 69 c.changes.append(('added', node, diff, cs1, cs2))
@@ -81,12 +75,7 b' class ChangesetController(BaseController'
81 75 else:
82 76 f_udiff = differ.get_udiff(filenode_old, node)
83 77 diff = differ.DiffProcessor(f_udiff).as_html()
84 try:
85 diff = unicode(diff)
86 except:
87 log.warning('Decoding failed of %s', filenode_old)
88 log.warning('Decoding failed of %s', node)
89 diff = 'unsupported type'
78
90 79 cs1 = filenode_old.last_changeset.raw_id
91 80 cs2 = node.last_changeset.raw_id
92 81 c.changes.append(('changed', node, diff, cs1, cs2))
@@ -95,3 +84,53 b' class ChangesetController(BaseController'
95 84 c.changes.append(('removed', node, None, None, None))
96 85
97 86 return render('changeset/changeset.html')
87
88 def raw_changeset(self,revision):
89
90 hg_model = HgModel()
91 try:
92 c.changeset = hg_model.get_repo(c.repo_name).get_changeset(revision)
93 except RepositoryError:
94 log.error(traceback.format_exc())
95 return redirect(url('hg_home'))
96 else:
97 try:
98 c.changeset_old = c.changeset.parents[0]
99 except IndexError:
100 c.changeset_old = None
101 c.changes = []
102
103 for node in c.changeset.added:
104 filenode_old = FileNode(node.path, '')
105 if filenode_old.is_binary or node.is_binary:
106 diff = 'binary file'
107 else:
108 f_udiff = differ.get_udiff(filenode_old, node)
109 diff = differ.DiffProcessor(f_udiff).raw_diff()
110
111 cs1 = None
112 cs2 = node.last_changeset.raw_id
113 c.changes.append(('added', node, diff, cs1, cs2))
114
115 for node in c.changeset.changed:
116 filenode_old = c.changeset_old.get_node(node.path)
117 if filenode_old.is_binary or node.is_binary:
118 diff = 'binary file'
119 else:
120 f_udiff = differ.get_udiff(filenode_old, node)
121 diff = differ.DiffProcessor(f_udiff).raw_diff()
122
123 cs1 = filenode_old.last_changeset.raw_id
124 cs2 = node.last_changeset.raw_id
125 c.changes.append(('changed', node, diff, cs1, cs2))
126
127 response.content_type = 'text/plain'
128
129 parent = True if len(c.changeset.parents) > 0 else False
130 c.parent_tmpl = 'Parent %s' % c.changeset.parents[0]._hex if parent else ''
131
132 c.diffs = ''
133 for x in c.changes:
134 c.diffs += x[2]
135
136 return render('changeset/raw_changeset.html')
General Comments 0
You need to be logged in to leave comments. Login now