Show More
@@ -0,0 +1,82 b'' | |||||
|
1 | ## -*- coding: utf-8 -*- | |||
|
2 | <%inherit file="/base/base.html"/> | |||
|
3 | ||||
|
4 | <%def name="title()"> | |||
|
5 | TODO FIll this in | |||
|
6 | </%def> | |||
|
7 | ||||
|
8 | <%def name="breadcrumbs_links()"> | |||
|
9 | ${h.link_to(u'Home',h.url('/'))} | |||
|
10 | » | |||
|
11 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} | |||
|
12 | » | |||
|
13 | TODO! | |||
|
14 | </%def> | |||
|
15 | ||||
|
16 | <%def name="page_nav()"> | |||
|
17 | ${self.menu('changelog')} | |||
|
18 | </%def> | |||
|
19 | ||||
|
20 | <%def name="main()"> | |||
|
21 | <div class="box"> | |||
|
22 | <!-- box / title --> | |||
|
23 | <div class="title"> | |||
|
24 | ${self.breadcrumbs()} | |||
|
25 | </div> | |||
|
26 | <div class="table"> | |||
|
27 | <div id="body" class="diffblock"> | |||
|
28 | <div class="code-header cv"> | |||
|
29 | <h3 class="code-header-title">${_('Compare View')}</h3> | |||
|
30 | <div> | |||
|
31 | ${'%s@%s' % (c.org_repo.repo_name, c.org_ref)} -> ${'%s@%s' % (c.other_repo.repo_name, c.other_ref)} | |||
|
32 | </div> | |||
|
33 | </div> | |||
|
34 | </div> | |||
|
35 | <div id="changeset_compare_view_content"> | |||
|
36 | <div class="container"> | |||
|
37 | <table class="compare_view_commits noborder"> | |||
|
38 | %for cnt,cs in enumerate(c.cs_ranges): | |||
|
39 | <tr> | |||
|
40 | <td><div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(h.email(cs.author),14)}"/></div></td> | |||
|
41 | <td>${h.link_to('r%s:%s' % (cs.revision,h.short_id(cs.raw_id)),h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</td> | |||
|
42 | <td><div class="author">${h.person(cs.author)}</div></td> | |||
|
43 | <td><span class="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td> | |||
|
44 | <td> | |||
|
45 | %if hasattr(c,'statuses') and c.statuses: | |||
|
46 | <div title="${_('Changeset status')}" class="changeset-status-ico"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses[cnt])}" /></div> | |||
|
47 | %endif | |||
|
48 | </td> | |||
|
49 | <td><div class="message">${h.urlify_commit(h.wrap_paragraphs(cs.message),c.repo_name)}</div></td> | |||
|
50 | </tr> | |||
|
51 | %endfor | |||
|
52 | </table> | |||
|
53 | </div> | |||
|
54 | <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${_('Files affected')}</div> | |||
|
55 | <div class="cs_files"> | |||
|
56 | %for change,filenode,diff,cs1,cs2,st in c.changes[cs.raw_id]: | |||
|
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> | |||
|
58 | %endfor | |||
|
59 | </div> | |||
|
60 | </div> | |||
|
61 | ||||
|
62 | </div> | |||
|
63 | ||||
|
64 | <script type="text/javascript"> | |||
|
65 | ||||
|
66 | YUE.onDOMReady(function(){ | |||
|
67 | ||||
|
68 | YUE.on(YUQ('.diff-menu-activate'),'click',function(e){ | |||
|
69 | var act = e.currentTarget.nextElementSibling; | |||
|
70 | ||||
|
71 | if(YUD.hasClass(act,'active')){ | |||
|
72 | YUD.removeClass(act,'active'); | |||
|
73 | YUD.setStyle(act,'display','none'); | |||
|
74 | }else{ | |||
|
75 | YUD.addClass(act,'active'); | |||
|
76 | YUD.setStyle(act,'display',''); | |||
|
77 | } | |||
|
78 | }); | |||
|
79 | }) | |||
|
80 | </script> | |||
|
81 | </div> | |||
|
82 | </%def> |
@@ -26,12 +26,15 b'' | |||||
26 | import logging |
|
26 | import logging | |
27 | import traceback |
|
27 | import traceback | |
28 |
|
28 | |||
|
29 | from webob.exc import HTTPNotFound | |||
29 | from pylons import request, response, session, tmpl_context as c, url |
|
30 | from pylons import request, response, session, tmpl_context as c, url | |
30 | from pylons.controllers.util import abort, redirect |
|
31 | from pylons.controllers.util import abort, redirect | |
31 |
|
32 | |||
32 | from rhodecode.lib.base import BaseRepoController, render |
|
33 | from rhodecode.lib.base import BaseRepoController, render | |
33 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
34 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
34 | from webob.exc import HTTPNotFound |
|
35 | from rhodecode.lib import diffs | |
|
36 | ||||
|
37 | from rhodecode.model.db import Repository | |||
35 |
|
38 | |||
36 | log = logging.getLogger(__name__) |
|
39 | log = logging.getLogger(__name__) | |
37 |
|
40 | |||
@@ -47,7 +50,8 b' class CompareController(BaseRepoControll' | |||||
47 | def _handle_ref(self, ref): |
|
50 | def _handle_ref(self, ref): | |
48 | """ |
|
51 | """ | |
49 | Parse the org...other string |
|
52 | Parse the org...other string | |
50 | Possible formats are `(branch|book|tag):<name>...(branch|book|tag):<othername>` |
|
53 | Possible formats are | |
|
54 | `(branch|book|tag):<name>...(branch|book|tag):<othername>` | |||
51 |
|
55 | |||
52 | :param ref: <orginal_reference>...<other_reference> |
|
56 | :param ref: <orginal_reference>...<other_reference> | |
53 | :type ref: str |
|
57 | :type ref: str | |
@@ -64,7 +68,8 b' class CompareController(BaseRepoControll' | |||||
64 | _repo = org_repo |
|
68 | _repo = org_repo | |
65 | name, val = other.split(':') |
|
69 | name, val = other.split(':') | |
66 | if _other_repo: |
|
70 | if _other_repo: | |
67 |
|
|
71 | #TODO: do an actual repo loookup within rhodecode | |
|
72 | _repo = _other_repo | |||
68 |
|
73 | |||
69 | return _repo, (name, val) |
|
74 | return _repo, (name, val) | |
70 |
|
75 | |||
@@ -79,17 +84,47 b' class CompareController(BaseRepoControll' | |||||
79 |
|
84 | |||
80 | raise HTTPNotFound |
|
85 | raise HTTPNotFound | |
81 |
|
86 | |||
|
87 | def _get_changesets(self, org_repo, org_ref, other_repo, other_ref): | |||
|
88 | changesets = [] | |||
|
89 | #case two independent repos | |||
|
90 | if org_repo != other_repo: | |||
|
91 | from mercurial import discovery | |||
|
92 | import binascii | |||
|
93 | out = discovery.findcommonoutgoing(org_repo._repo, other_repo._repo) | |||
|
94 | for cs in map(binascii.hexlify, out.missing): | |||
|
95 | changesets.append(org_repo.get_changeset(cs)) | |||
|
96 | else: | |||
|
97 | for cs in map(binascii.hexlify, out): | |||
|
98 | changesets.append(org_repo.get_changeset(cs)) | |||
|
99 | ||||
|
100 | return changesets | |||
|
101 | ||||
82 | def index(self, ref): |
|
102 | def index(self, ref): | |
83 |
|
||||
84 | org_repo, org_ref, other_repo, other_ref = self._handle_ref(ref) |
|
103 | org_repo, org_ref, other_repo, other_ref = self._handle_ref(ref) | |
85 | return ''' |
|
104 | ||
86 | <pre> |
|
105 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) | |
87 | REPO: %s |
|
106 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) | |
88 | REF: %s |
|
107 | ||
|
108 | c.cs_ranges = self._get_changesets(org_repo.scm_instance, | |||
|
109 | org_ref, | |||
|
110 | other_repo.scm_instance, | |||
|
111 | other_ref) | |||
|
112 | ||||
|
113 | c.org_ref = org_ref[1] | |||
|
114 | 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 | ||||
|
118 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) | |||
|
119 | diff_processor = diffs.DiffProcessor(_diff, format='gitdiff') | |||
|
120 | ||||
|
121 | diff = diff_processor.as_html(enable_comments=False) | |||
|
122 | stats = diff_processor.stat() | |||
|
123 | ||||
|
124 | c.changes = [('change?', None, diff, cs1, cs2, stats,)] | |||
|
125 | ||||
|
126 | return render('compare/compare_diff.html') | |||
|
127 | ||||
|
128 | ||||
|
129 | ||||
89 |
|
130 | |||
90 | vs |
|
|||
91 |
|
||||
92 | REPO: %s |
|
|||
93 | REF: %s |
|
|||
94 | </pre> |
|
|||
95 | ''' % (org_repo, org_ref, other_repo, other_ref) |
|
@@ -522,3 +522,32 b' class DiffProcessor(object):' | |||||
522 | Returns tuple of added, and removed lines for this instance |
|
522 | Returns tuple of added, and removed lines for this instance | |
523 | """ |
|
523 | """ | |
524 | return self.adds, self.removes |
|
524 | return self.adds, self.removes | |
|
525 | ||||
|
526 | ||||
|
527 | def differ(org_repo, org_ref, other_repo, other_ref): | |||
|
528 | """ | |||
|
529 | ||||
|
530 | :param org_repo: | |||
|
531 | :type org_repo: | |||
|
532 | :param org_ref: | |||
|
533 | :type org_ref: | |||
|
534 | :param other_repo: | |||
|
535 | :type other_repo: | |||
|
536 | :param other_ref: | |||
|
537 | :type other_ref: | |||
|
538 | """ | |||
|
539 | ignore_whitespace = False | |||
|
540 | context = 3 | |||
|
541 | from mercurial import patch | |||
|
542 | from mercurial.mdiff import diffopts | |||
|
543 | ||||
|
544 | org_repo = org_repo.scm_instance._repo | |||
|
545 | other_repo = other_repo.scm_instance._repo | |||
|
546 | ||||
|
547 | org_ref = org_ref[1] | |||
|
548 | other_ref = other_ref[1] | |||
|
549 | ||||
|
550 | opts = diffopts(git=True, ignorews=ignore_whitespace, context=context) | |||
|
551 | ||||
|
552 | return ''.join(patch.diff(org_repo, node1=org_ref, node2=other_ref, | |||
|
553 | opts=opts)) |
General Comments 0
You need to be logged in to leave comments.
Login now