Show More
@@ -83,15 +83,19 b' class FilesController(BaseController):' | |||||
83 | c.repo = hg_model.get_repo(c.repo_name) |
|
83 | c.repo = hg_model.get_repo(c.repo_name) | |
84 | c.changeset_1 = c.repo.get_changeset(diff1) |
|
84 | c.changeset_1 = c.repo.get_changeset(diff1) | |
85 | c.changeset_2 = c.repo.get_changeset(diff2) |
|
85 | c.changeset_2 = c.repo.get_changeset(diff2) | |
86 |
|
86 | f1 = c.changeset_1.get_node(f_path) | ||
87 |
|
|
87 | f2 = c.changeset_2.get_node(f_path) | |
88 | c.file_2 = c.changeset_2.get_file_content(f_path) |
|
88 | ||
89 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short) |
|
89 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short) | |
90 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short) |
|
90 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short) | |
91 |
|
91 | |||
92 |
|
|
92 | f_udiff = unified_diff(f1.content.splitlines(True), | |
93 | c.diff_files = render_udiff(udiff=d2) |
|
93 | f2.content.splitlines(True), | |
|
94 | f1.name, | |||
|
95 | f2.name) | |||
94 |
|
96 | |||
|
97 | c.diff_files = render_udiff(udiff=f_udiff, differ='difflib') | |||
|
98 | print c.diff_files | |||
95 | if len(c.diff_files) < 1: |
|
99 | if len(c.diff_files) < 1: | |
96 | c.no_changes = True |
|
100 | c.no_changes = True | |
97 | return render('files/file_diff.html') |
|
101 | return render('files/file_diff.html') |
@@ -40,11 +40,18 b' class DiffProcessor(object):' | |||||
40 | """Extract the filename and revision hint from a line.""" |
|
40 | """Extract the filename and revision hint from a line.""" | |
41 | try: |
|
41 | try: | |
42 | if line1.startswith('--- ') and line2.startswith('+++ '): |
|
42 | if line1.startswith('--- ') and line2.startswith('+++ '): | |
43 |
|
|
43 | l1 = line1[4:].split(None, 1) | |
44 | new_rev = line2[4:].split(None, 1)[1] |
|
44 | old_filename = l1[0] if len(l1) >= 1 else None | |
45 | return filename, 'old', 'new' |
|
45 | old_rev = l1[1] if len(l1) == 2 else 'old' | |
|
46 | ||||
|
47 | l2 = line1[4:].split(None, 1) | |||
|
48 | new_filename = l2[0] if len(l2) >= 1 else None | |||
|
49 | new_rev = l2[1] if len(l2) == 2 else 'new' | |||
|
50 | ||||
|
51 | return old_filename, new_rev, old_rev | |||
46 | except (ValueError, IndexError): |
|
52 | except (ValueError, IndexError): | |
47 | pass |
|
53 | pass | |
|
54 | ||||
48 | return None, None, None |
|
55 | return None, None, None | |
49 |
|
56 | |||
50 | def _highlight_line_difflib(self, line, next): |
|
57 | def _highlight_line_difflib(self, line, next): |
@@ -39,11 +39,11 b'' | |||||
39 | %for x in diff['chunks']: |
|
39 | %for x in diff['chunks']: | |
40 | %for y in x: |
|
40 | %for y in x: | |
41 | <tr class="line ${y['action']}"> |
|
41 | <tr class="line ${y['action']}"> | |
|
42 | <td id="#${diff['filename']}_O${y['old_lineno']}" class="lineno old"> | |||
|
43 | <pre><a href="#${diff['filename']}_O${y['old_lineno']}">${y['old_lineno']}</a></pre> | |||
|
44 | </td> | |||
42 | <td id="#${diff['filename']}_N${y['new_lineno']}"class="lineno new"> |
|
45 | <td id="#${diff['filename']}_N${y['new_lineno']}"class="lineno new"> | |
43 | <pre><a href="#${diff['filename']}_N${y['new_lineno']}">${y['new_lineno']}</a></pre> |
|
46 | <pre><a href="#${diff['filename']}_N${y['new_lineno']}">${y['new_lineno']}</a></pre> | |
44 | </td> |
|
|||
45 | <td id="#${diff['filename']}_O${y['old_lineno']}" class="lineno old"> |
|
|||
46 | <pre><a href="#${diff['filename']}_O${y['old_lineno']}">${y['old_lineno']}</a></pre> |
|
|||
47 | </td> |
|
47 | </td> | |
48 | <td class="code"> |
|
48 | <td class="code"> | |
49 | <pre>${y['line']|n}</pre> |
|
49 | <pre>${y['line']|n}</pre> |
General Comments 0
You need to be logged in to leave comments.
Login now