Show More
@@ -2,6 +2,19 b'' | |||||
2 | # encoding: utf-8 |
|
2 | # encoding: utf-8 | |
3 | # files controller for pylons |
|
3 | # files controller for pylons | |
4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> |
|
4 | # Copyright (C) 2009-2010 Marcin Kuzminski <marcin@python-works.com> | |
|
5 | from mercurial import archival | |||
|
6 | from pylons import request, response, session, tmpl_context as c, url | |||
|
7 | from pylons.controllers.util import redirect | |||
|
8 | from pylons_app.lib.auth import LoginRequired | |||
|
9 | from pylons_app.lib.base import BaseController, render | |||
|
10 | from pylons_app.lib.utils import EmptyChangeset | |||
|
11 | from pylons_app.model.hg_model import HgModel | |||
|
12 | from vcs.exceptions import RepositoryError, ChangesetError | |||
|
13 | from vcs.nodes import FileNode | |||
|
14 | from vcs.utils import diffs as differ | |||
|
15 | import logging | |||
|
16 | import pylons_app.lib.helpers as h | |||
|
17 | import tempfile | |||
5 |
|
18 | |||
6 | # This program is free software; you can redistribute it and/or |
|
19 | # This program is free software; you can redistribute it and/or | |
7 | # modify it under the terms of the GNU General Public License |
|
20 | # modify it under the terms of the GNU General Public License | |
@@ -22,16 +35,6 b' Created on April 21, 2010' | |||||
22 | files controller for pylons |
|
35 | files controller for pylons | |
23 | @author: marcink |
|
36 | @author: marcink | |
24 | """ |
|
37 | """ | |
25 | from mercurial import archival |
|
|||
26 | from pylons import request, response, session, tmpl_context as c, url |
|
|||
27 | from pylons_app.lib.auth import LoginRequired |
|
|||
28 | from pylons_app.lib.base import BaseController, render |
|
|||
29 | import pylons_app.lib.helpers as h |
|
|||
30 | from pylons_app.model.hg_model import HgModel |
|
|||
31 | from vcs.exceptions import RepositoryError, ChangesetError |
|
|||
32 | from vcs.utils import diffs as differ |
|
|||
33 | import logging |
|
|||
34 | import tempfile |
|
|||
35 |
|
38 | |||
36 |
|
39 | |||
37 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
@@ -140,13 +143,27 b' class FilesController(BaseController):' | |||||
140 | c.no_changes = diff1 == diff2 |
|
143 | c.no_changes = diff1 == diff2 | |
141 | c.f_path = f_path |
|
144 | c.f_path = f_path | |
142 | c.repo = hg_model.get_repo(c.repo_name) |
|
145 | c.repo = hg_model.get_repo(c.repo_name) | |
143 | c.changeset_1 = c.repo.get_changeset(diff1) |
|
|||
144 | c.changeset_2 = c.repo.get_changeset(diff2) |
|
|||
145 |
|
146 | |||
146 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1._short) |
|
147 | try: | |
147 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2._short) |
|
148 | if diff1 not in ['', None, 'None', '0' * 12]: | |
148 | f_udiff = differ.get_udiff(c.changeset_1.get_node(f_path), |
|
149 | c.changeset_1 = c.repo.get_changeset(diff1) | |
149 |
|
|
150 | node1 = c.changeset_1.get_node(f_path) | |
|
151 | else: | |||
|
152 | c.changeset_1 = EmptyChangeset() | |||
|
153 | node1 = FileNode('.', '') | |||
|
154 | if diff2 not in ['', None, 'None', '0' * 12]: | |||
|
155 | c.changeset_2 = c.repo.get_changeset(diff2) | |||
|
156 | node2 = c.changeset_2.get_node(f_path) | |||
|
157 | else: | |||
|
158 | c.changeset_2 = EmptyChangeset() | |||
|
159 | node2 = FileNode('.', '') | |||
|
160 | except RepositoryError: | |||
|
161 | return redirect(url('files_home', | |||
|
162 | repo_name=c.repo_name, f_path=f_path)) | |||
|
163 | ||||
|
164 | c.diff1 = 'r%s:%s' % (c.changeset_1.revision, c.changeset_1.raw_id) | |||
|
165 | c.diff2 = 'r%s:%s' % (c.changeset_2.revision, c.changeset_2.raw_id) | |||
|
166 | f_udiff = differ.get_udiff(node1, node2) | |||
150 |
|
167 | |||
151 | diff = differ.DiffProcessor(f_udiff) |
|
168 | diff = differ.DiffProcessor(f_udiff) | |
152 |
|
169 |
General Comments 0
You need to be logged in to leave comments.
Login now