Show More
@@ -6,8 +6,7 b' from pylons.controllers.util import abor' | |||
|
6 | 6 | from pylons_app.lib.base import BaseController, render |
|
7 | 7 | from pylons_app.lib.utils import get_repo_slug |
|
8 | 8 | from pylons_app.model.hg_model import HgModel |
|
9 | from difflib import unified_diff | |
|
10 | from pylons_app.lib.differ import render_udiff | |
|
9 | from vcs.utils import diffs as differ | |
|
11 | 10 | from vcs.exceptions import RepositoryError, ChangesetError |
|
12 | 11 | |
|
13 | 12 | log = logging.getLogger(__name__) |
@@ -83,21 +82,14 b' class FilesController(BaseController):' | |||
|
83 | 82 | c.repo = hg_model.get_repo(c.repo_name) |
|
84 | 83 | c.changeset_1 = c.repo.get_changeset(diff1) |
|
85 | 84 | c.changeset_2 = c.repo.get_changeset(diff2) |
|
86 | f1 = c.changeset_1.get_node(f_path) | |
|
87 | f2 = c.changeset_2.get_node(f_path) | |
|
88 | 85 | |
|
89 | 86 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short) |
|
90 | 87 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short) |
|
91 | ||
|
92 | f_udiff = unified_diff(f1.content.splitlines(True), | |
|
93 | f2.content.splitlines(True), | |
|
94 | f1.name, | |
|
95 | f2.name) | |
|
88 | ||
|
96 | 89 | |
|
97 | c.diff_files = render_udiff(udiff=f_udiff, differ='difflib') | |
|
98 | print c.diff_files | |
|
99 | if len(c.diff_files) < 1: | |
|
100 | c.no_changes = True | |
|
90 | f_udiff = differ.get_udiff(c.changeset_1.get_node(f_path), | |
|
91 | c.changeset_2.get_node(f_path)) | |
|
92 | c.differ = differ.DiffProcessor(f_udiff) | |
|
101 | 93 | return render('files/file_diff.html') |
|
102 | 94 | |
|
103 | 95 | def _get_history(self, repo, node, f_path): |
@@ -24,6 +24,14 b' div.diffblock .code-body{' | |||
|
24 | 24 | |
|
25 | 25 | .code-difftable{ |
|
26 | 26 | border-collapse: collapse; |
|
27 | width: 99%; | |
|
28 | } | |
|
29 | .code-difftable td:target *{ | |
|
30 | background: repeat scroll 0 0 #FFFFBE !important; | |
|
31 | text-decoration: underline; | |
|
32 | } | |
|
33 | .code-difftable .context{ | |
|
34 | background:none repeat scroll 0 0 #DDE7EF; | |
|
27 | 35 | } |
|
28 | 36 | .code-difftable .add{ |
|
29 | 37 | background:none repeat scroll 0 0 #DDFFDD; |
@@ -14,10 +14,14 b' div.codeblock .code-header{' | |||
|
14 | 14 | color:blue; |
|
15 | 15 | padding:10px 0 10px 0; |
|
16 | 16 | } |
|
17 |
div.codeblock .code-header |
|
|
17 | div.codeblock .code-header .revision{ | |
|
18 | 18 | margin-left:25px; |
|
19 | 19 | font-weight: bold; |
|
20 | 20 | } |
|
21 | div.codeblock .code-header .commit{ | |
|
22 | margin-left:25px; | |
|
23 | font-weight: normal; | |
|
24 | } | |
|
21 | 25 | |
|
22 | 26 | .code-highlight { |
|
23 | 27 | padding: 0px; |
@@ -34,25 +34,7 b'' | |||
|
34 | 34 | %if c.no_changes: |
|
35 | 35 | ${_('No changes')} |
|
36 | 36 | %else: |
|
37 | <table class='code-difftable'> | |
|
38 | %for diff in c.diff_files: | |
|
39 | %for x in diff['chunks']: | |
|
40 | %for y in x: | |
|
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> | |
|
45 | <td id="#${diff['filename']}_N${y['new_lineno']}"class="lineno new"> | |
|
46 | <pre><a href="#${diff['filename']}_N${y['new_lineno']}">${y['new_lineno']}</a></pre> | |
|
47 | </td> | |
|
48 | <td class="code"> | |
|
49 | <pre>${y['line']|n}</pre> | |
|
50 | </td> | |
|
51 | </tr> | |
|
52 | %endfor$ | |
|
53 | %endfor | |
|
54 | %endfor | |
|
55 | </table> | |
|
37 | ${c.differ.as_HTML()|n} | |
|
56 | 38 | %endif |
|
57 | 39 | </div> |
|
58 | 40 | </div> |
@@ -17,8 +17,8 b'' | |||
|
17 | 17 | </dl> |
|
18 | 18 | <div id="body" class="codeblock"> |
|
19 | 19 | <div class="code-header"> |
|
20 |
< |
|
|
21 |
|
|
|
20 | <div class="revision">${c.files_list.name}@r${c.files_list.last_changeset.revision}:${c.files_list.last_changeset._short}</div> | |
|
21 | <div class="commit" style="font-size:70%">"${c.file_msg}"</div> | |
|
22 | 22 | </div> |
|
23 | 23 | <div class="code-body"> |
|
24 | 24 | ${h.pygmentize(c.files_list.content,linenos=True,anchorlinenos=True,cssclass="code-highlight")} |
|
1 | NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now