Show More
@@ -6,6 +6,9 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 | |||
|
10 | from pylons_app.lib.differ import render_udiff | |||
|
11 | ||||
9 | log = logging.getLogger(__name__) |
|
12 | log = logging.getLogger(__name__) | |
10 |
|
13 | |||
11 | class FilesController(BaseController): |
|
14 | class FilesController(BaseController): | |
@@ -29,6 +32,7 b' class FilesController(BaseController):' | |||||
29 | hg_model = HgModel() |
|
32 | hg_model = HgModel() | |
30 | diff1 = request.GET.get('diff1') |
|
33 | diff1 = request.GET.get('diff1') | |
31 | diff2 = request.GET.get('diff2') |
|
34 | diff2 = request.GET.get('diff2') | |
|
35 | c.no_changes = diff1 == diff2 | |||
32 | c.f_path = f_path |
|
36 | c.f_path = f_path | |
33 | c.repo = hg_model.get_repo(c.repo_name) |
|
37 | c.repo = hg_model.get_repo(c.repo_name) | |
34 | c.changeset_1 = c.repo.get_changeset(diff1) |
|
38 | c.changeset_1 = c.repo.get_changeset(diff1) | |
@@ -38,14 +42,12 b' class FilesController(BaseController):' | |||||
38 | c.file_2 = c.changeset_2.get_node(f_path).content |
|
42 | c.file_2 = c.changeset_2.get_node(f_path).content | |
39 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short) |
|
43 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short) | |
40 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short) |
|
44 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short) | |
41 | from difflib import unified_diff |
|
45 | ||
42 | d = unified_diff(c.file_1.splitlines(1), c.file_2.splitlines(1)) |
|
46 | d2 = unified_diff(c.file_1.splitlines(1), c.file_2.splitlines(1)) | |
43 | c.diff = ''.join(d) |
|
47 | c.diff_files = render_udiff(udiff=d2) | |
44 |
|
48 | |||
45 | from pylons_app.lib.differ import render_udiff |
|
49 | if len(c.diff_files) < 1: | |
46 | d2 = unified_diff(c.file_1.splitlines(1), c.file_2.splitlines(1)) |
|
50 | c.no_changes = True | |
47 | c.diff_2 = render_udiff(udiff=d2) |
|
|||
48 |
|
||||
49 | return render('files/file_diff.html') |
|
51 | return render('files/file_diff.html') | |
50 |
|
52 | |||
51 | def _get_history(self, repo, node, f_path): |
|
53 | def _get_history(self, repo, node, f_path): |
General Comments 0
You need to be logged in to leave comments.
Login now