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