Show More
@@ -24,14 +24,15 b'' | |||||
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 |
|
25 | |||
26 | import logging |
|
26 | import logging | |
|
27 | import binascii | |||
27 |
|
28 | |||
28 | from pylons import tmpl_context as c |
|
29 | from pylons import tmpl_context as c | |
29 | import binascii |
|
|||
30 |
|
30 | |||
31 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
31 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
32 | from rhodecode.lib.base import BaseRepoController, render |
|
32 | from rhodecode.lib.base import BaseRepoController, render | |
33 | from rhodecode.lib.compat import OrderedDict |
|
33 | from rhodecode.lib.compat import OrderedDict | |
34 | from rhodecode.lib.utils2 import safe_unicode |
|
34 | from rhodecode.lib.utils2 import safe_unicode | |
|
35 | ||||
35 | log = logging.getLogger(__name__) |
|
36 | log = logging.getLogger(__name__) | |
36 |
|
37 | |||
37 |
|
38 |
@@ -25,11 +25,13 b'' | |||||
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
26 | import logging |
|
26 | import logging | |
27 | import traceback |
|
27 | import traceback | |
|
28 | import binascii | |||
28 |
|
29 | |||
29 | from webob.exc import HTTPNotFound |
|
30 | from webob.exc import HTTPNotFound | |
30 | from pylons import request, response, session, tmpl_context as c, url |
|
31 | from pylons import request, response, session, tmpl_context as c, url | |
31 | from pylons.controllers.util import abort, redirect |
|
32 | from pylons.controllers.util import abort, redirect | |
32 |
|
33 | |||
|
34 | from rhodecode.lib import helpers as h | |||
33 | from rhodecode.lib.base import BaseRepoController, render |
|
35 | from rhodecode.lib.base import BaseRepoController, render | |
34 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
36 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
35 | from rhodecode.lib import diffs |
|
37 | from rhodecode.lib import diffs | |
@@ -89,12 +91,15 b' class CompareController(BaseRepoControll' | |||||
89 | #case two independent repos |
|
91 | #case two independent repos | |
90 | if org_repo != other_repo: |
|
92 | if org_repo != other_repo: | |
91 | from mercurial import discovery |
|
93 | from mercurial import discovery | |
92 | import binascii |
|
|||
93 | out = discovery.findcommonoutgoing(org_repo._repo, other_repo._repo) |
|
94 | out = discovery.findcommonoutgoing(org_repo._repo, other_repo._repo) | |
94 | for cs in map(binascii.hexlify, out.missing): |
|
95 | for cs in map(binascii.hexlify, out.missing): | |
95 | changesets.append(org_repo.get_changeset(cs)) |
|
96 | changesets.append(org_repo.get_changeset(cs)) | |
96 | else: |
|
97 | else: | |
97 | for cs in map(binascii.hexlify, out): |
|
98 | revs = ['ancestors(%s) and not ancestors(%s)' % (org_ref[1], | |
|
99 | other_ref[1])] | |||
|
100 | from mercurial import scmutil | |||
|
101 | out = scmutil.revrange(org_repo._repo, revs) | |||
|
102 | for cs in reversed(out): | |||
98 | changesets.append(org_repo.get_changeset(cs)) |
|
103 | changesets.append(org_repo.get_changeset(cs)) | |
99 |
|
104 | |||
100 | return changesets |
|
105 | return changesets | |
@@ -112,19 +117,18 b' class CompareController(BaseRepoControll' | |||||
112 |
|
117 | |||
113 | c.org_ref = org_ref[1] |
|
118 | c.org_ref = org_ref[1] | |
114 | c.other_ref = other_ref[1] |
|
119 | c.other_ref = other_ref[1] | |
115 | cs1 = org_repo.scm_instance.get_changeset(org_ref[1]) |
|
|||
116 | cs2 = other_repo.scm_instance.get_changeset(other_ref[1]) |
|
|||
117 |
|
120 | |||
118 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) |
|
121 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) | |
119 | diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') |
|
122 | diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') | |
|
123 | _parsed = diff_processor.prepare() | |||
120 |
|
124 | |||
121 | diff = diff_processor.as_html(enable_comments=False) |
|
125 | c.files = [] | |
122 | stats = diff_processor.stat() |
|
126 | c.changes = {} | |
123 |
|
127 | |||
124 | c.changes = [('change?', None, diff, cs1, cs2, stats,)] |
|
128 | for f in _parsed: | |
|
129 | fid = h.FID('', f['filename']) | |||
|
130 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) | |||
|
131 | diff = diff_processor.as_html(enable_comments=False, diff_lines=[f]) | |||
|
132 | c.changes[fid] = [f['operation'], f['filename'], diff] | |||
125 |
|
133 | |||
126 | return render('compare/compare_diff.html') |
|
134 | return render('compare/compare_diff.html') | |
127 |
|
||||
128 |
|
||||
129 |
|
||||
130 |
|
@@ -431,8 +431,10 b' class RemovedFileNode(FileNode):' | |||||
431 | name, kind or state (or methods/attributes checking those two) would raise |
|
431 | name, kind or state (or methods/attributes checking those two) would raise | |
432 | RemovedFileNodeError. |
|
432 | RemovedFileNodeError. | |
433 | """ |
|
433 | """ | |
434 | ALLOWED_ATTRIBUTES = ['name', 'path', 'state', 'is_root', 'is_file', |
|
434 | ALLOWED_ATTRIBUTES = [ | |
435 | 'is_dir', 'kind', 'added', 'changed', 'not_changed', 'removed'] |
|
435 | 'name', 'path', 'state', 'is_root', 'is_file', 'is_dir', 'kind', | |
|
436 | 'added', 'changed', 'not_changed', 'removed' | |||
|
437 | ] | |||
436 |
|
438 | |||
437 | def __init__(self, path): |
|
439 | def __init__(self, path): | |
438 | """ |
|
440 | """ |
@@ -2333,7 +2333,7 b' h3.files_location {' | |||||
2333 | padding: 2px 0px 2px 0px; |
|
2333 | padding: 2px 0px 2px 0px; | |
2334 | } |
|
2334 | } | |
2335 |
|
2335 | |||
2336 | .cs_files .cs_added { |
|
2336 | .cs_files .cs_added,.cs_files .cs_A { | |
2337 | background: url("../images/icons/page_white_add.png") no-repeat scroll |
|
2337 | background: url("../images/icons/page_white_add.png") no-repeat scroll | |
2338 | 3px; |
|
2338 | 3px; | |
2339 | height: 16px; |
|
2339 | height: 16px; | |
@@ -2342,7 +2342,7 b' h3.files_location {' | |||||
2342 | text-align: left; |
|
2342 | text-align: left; | |
2343 | } |
|
2343 | } | |
2344 |
|
2344 | |||
2345 | .cs_files .cs_changed { |
|
2345 | .cs_files .cs_changed,.cs_files .cs_M { | |
2346 | background: url("../images/icons/page_white_edit.png") no-repeat scroll |
|
2346 | background: url("../images/icons/page_white_edit.png") no-repeat scroll | |
2347 | 3px; |
|
2347 | 3px; | |
2348 | height: 16px; |
|
2348 | height: 16px; | |
@@ -2351,7 +2351,7 b' h3.files_location {' | |||||
2351 | text-align: left; |
|
2351 | text-align: left; | |
2352 | } |
|
2352 | } | |
2353 |
|
2353 | |||
2354 | .cs_files .cs_removed { |
|
2354 | .cs_files .cs_removed,.cs_files .cs_D { | |
2355 | background: url("../images/icons/page_white_delete.png") no-repeat |
|
2355 | background: url("../images/icons/page_white_delete.png") no-repeat | |
2356 | scroll 3px; |
|
2356 | scroll 3px; | |
2357 | height: 16px; |
|
2357 | height: 16px; |
@@ -1,12 +1,12 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | ##usage: |
|
2 | ##usage: | |
3 | ## <%namespace name="diff_block" file="/changeset/diff_block.html"/> |
|
3 | ## <%namespace name="diff_block" file="/changeset/diff_block.html"/> | |
4 |
## ${diff_block.diff_block(change |
|
4 | ## ${diff_block.diff_block(change)} | |
5 | ## |
|
5 | ## | |
6 |
<%def name="diff_block(change |
|
6 | <%def name="diff_block(change)"> | |
7 |
|
7 | |||
8 |
%for |
|
8 | %for op,filenode,diff,cs1,cs2,stat in change: | |
9 |
%if |
|
9 | %if op !='removed': | |
10 | <div id="${h.FID(filenode.changeset.raw_id,filenode.path)}_target" style="clear:both;margin-top:25px"></div> |
|
10 | <div id="${h.FID(filenode.changeset.raw_id,filenode.path)}_target" style="clear:both;margin-top:25px"></div> | |
11 | <div id="${h.FID(filenode.changeset.raw_id,filenode.path)}" class="diffblock margined comm"> |
|
11 | <div id="${h.FID(filenode.changeset.raw_id,filenode.path)}" class="diffblock margined comm"> | |
12 | <div class="code-header"> |
|
12 | <div class="code-header"> | |
@@ -39,3 +39,23 b'' | |||||
39 | %endfor |
|
39 | %endfor | |
40 |
|
40 | |||
41 | </%def> |
|
41 | </%def> | |
|
42 | ||||
|
43 | <%def name="diff_block_simple(change)"> | |||
|
44 | ||||
|
45 | %for op,filenode_path,diff in change: | |||
|
46 | <div id="${h.FID('',filenode_path)}_target" style="clear:both;margin-top:25px"></div> | |||
|
47 | <div id="${h.FID('',filenode_path)}" class="diffblock margined comm"> | |||
|
48 | <div class="code-header"> | |||
|
49 | <div class="changeset_header"> | |||
|
50 | <div class="changeset_file"> | |||
|
51 | <a href="#">${h.safe_unicode(filenode_path)}</a> | |||
|
52 | </div> | |||
|
53 | </div> | |||
|
54 | </div> | |||
|
55 | <div class="code-body"> | |||
|
56 | <div class="full_f_path" path="${h.safe_unicode(filenode_path)}"></div> | |||
|
57 | ${diff|n} | |||
|
58 | </div> | |||
|
59 | </div> | |||
|
60 | %endfor | |||
|
61 | </%def> No newline at end of file |
@@ -2,7 +2,7 b'' | |||||
2 | <%inherit file="/base/base.html"/> |
|
2 | <%inherit file="/base/base.html"/> | |
3 |
|
3 | |||
4 | <%def name="title()"> |
|
4 | <%def name="title()"> | |
5 | TODO FIll this in |
|
5 | ${c.repo_name} ${_('Compare')} ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} -> ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} | |
6 | </%def> |
|
6 | </%def> | |
7 |
|
7 | |||
8 | <%def name="breadcrumbs_links()"> |
|
8 | <%def name="breadcrumbs_links()"> | |
@@ -10,7 +10,7 b'' | |||||
10 | » |
|
10 | » | |
11 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} |
|
11 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} | |
12 | » |
|
12 | » | |
13 | TODO! |
|
13 | ${_('Compare')} | |
14 | </%def> |
|
14 | </%def> | |
15 |
|
15 | |||
16 | <%def name="page_nav()"> |
|
16 | <%def name="page_nav()"> | |
@@ -53,13 +53,21 b'' | |||||
53 | </div> |
|
53 | </div> | |
54 | <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Files affected')}</div> |
|
54 | <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Files affected')}</div> | |
55 | <div class="cs_files"> |
|
55 | <div class="cs_files"> | |
56 | %for change,filenode,diff,cs1,cs2,st in c.changes[cs.raw_id]: |
|
56 | %for fid, change, f, stat in c.files: | |
57 | <div class="cs_${change}">${h.link_to(h.safe_unicode(filenode.path),h.url.current(anchor=h.FID(cs.raw_id,filenode.path)))}</div> |
|
57 | <div class="cs_${change}"> | |
|
58 | <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div> | |||
|
59 | <div class="changes">${h.fancy_file_stats(stat)}</div> | |||
|
60 | </div> | |||
58 | %endfor |
|
61 | %endfor | |
59 | </div> |
|
62 | </div> | |
60 | </div> |
|
63 | </div> | |
|
64 | </div> | |||
61 |
|
65 | |||
62 | </div> |
|
66 | ## diff block | |
|
67 | <%namespace name="diff_block" file="/changeset/diff_block.html"/> | |||
|
68 | %for fid, change, f, stat in c.files: | |||
|
69 | ${diff_block.diff_block_simple([c.changes[fid]])} | |||
|
70 | %endfor | |||
63 |
|
71 | |||
64 | <script type="text/javascript"> |
|
72 | <script type="text/javascript"> | |
65 |
|
73 |
General Comments 0
You need to be logged in to leave comments.
Login now