Show More
@@ -1,180 +1,181 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | rhodecode.controllers.compare |
|
4 | 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 | 5 | |
|
6 | 6 | compare controller for pylons showing differences between two |
|
7 | 7 | repos, branches, bookmarks or tips |
|
8 | 8 | |
|
9 | 9 | :created_on: May 6, 2012 |
|
10 | 10 | :author: marcink |
|
11 | 11 | :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
|
12 | 12 | :license: GPLv3, see COPYING for more details. |
|
13 | 13 | """ |
|
14 | 14 | # This program is free software: you can redistribute it and/or modify |
|
15 | 15 | # it under the terms of the GNU General Public License as published by |
|
16 | 16 | # the Free Software Foundation, either version 3 of the License, or |
|
17 | 17 | # (at your option) any later version. |
|
18 | 18 | # |
|
19 | 19 | # This program is distributed in the hope that it will be useful, |
|
20 | 20 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 | 21 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 | 22 | # GNU General Public License for more details. |
|
23 | 23 | # |
|
24 | 24 | # You should have received a copy of the GNU General Public License |
|
25 | 25 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
26 | 26 | import logging |
|
27 | 27 | import traceback |
|
28 | 28 | |
|
29 | 29 | from webob.exc import HTTPNotFound |
|
30 | 30 | from pylons import request, response, session, tmpl_context as c, url |
|
31 | 31 | from pylons.controllers.util import abort, redirect |
|
32 | 32 | from pylons.i18n.translation import _ |
|
33 | 33 | |
|
34 | 34 | from rhodecode.lib.vcs.exceptions import EmptyRepositoryError, RepositoryError |
|
35 | 35 | from rhodecode.lib import helpers as h |
|
36 | 36 | from rhodecode.lib.base import BaseRepoController, render |
|
37 | 37 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
38 | 38 | from rhodecode.lib import diffs |
|
39 | 39 | |
|
40 | 40 | from rhodecode.model.db import Repository |
|
41 | 41 | from rhodecode.model.pull_request import PullRequestModel |
|
42 | 42 | from webob.exc import HTTPBadRequest |
|
43 | 43 | from rhodecode.lib.utils2 import str2bool |
|
44 | 44 | from rhodecode.lib.diffs import LimitedDiffContainer |
|
45 | 45 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
46 | 46 | |
|
47 | 47 | log = logging.getLogger(__name__) |
|
48 | 48 | |
|
49 | 49 | |
|
50 | 50 | class CompareController(BaseRepoController): |
|
51 | 51 | |
|
52 | 52 | @LoginRequired() |
|
53 | 53 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
54 | 54 | 'repository.admin') |
|
55 | 55 | def __before__(self): |
|
56 | 56 | super(CompareController, self).__before__() |
|
57 | 57 | |
|
58 | 58 | def __get_cs_or_redirect(self, rev, repo, redirect_after=True, |
|
59 | 59 | partial=False): |
|
60 | 60 | """ |
|
61 | 61 | Safe way to get changeset if error occur it redirects to changeset with |
|
62 | 62 | proper message. If partial is set then don't do redirect raise Exception |
|
63 | 63 | instead |
|
64 | 64 | |
|
65 | 65 | :param rev: revision to fetch |
|
66 | 66 | :param repo: repo instance |
|
67 | 67 | """ |
|
68 | 68 | |
|
69 | 69 | try: |
|
70 | 70 | type_, rev = rev |
|
71 | 71 | return repo.scm_instance.get_changeset(rev) |
|
72 | 72 | except EmptyRepositoryError, e: |
|
73 | 73 | if not redirect_after: |
|
74 | 74 | return None |
|
75 | 75 | h.flash(h.literal(_('There are no changesets yet')), |
|
76 | 76 | category='warning') |
|
77 | 77 | redirect(url('summary_home', repo_name=repo.repo_name)) |
|
78 | 78 | |
|
79 | 79 | except RepositoryError, e: |
|
80 | 80 | log.error(traceback.format_exc()) |
|
81 | 81 | h.flash(str(e), category='warning') |
|
82 | 82 | if not partial: |
|
83 | 83 | redirect(h.url('summary_home', repo_name=repo.repo_name)) |
|
84 | 84 | raise HTTPBadRequest() |
|
85 | 85 | |
|
86 | 86 | def index(self, org_ref_type, org_ref, other_ref_type, other_ref): |
|
87 | 87 | |
|
88 | 88 | org_repo = c.rhodecode_db_repo.repo_name |
|
89 | 89 | org_ref = (org_ref_type, org_ref) |
|
90 | 90 | other_ref = (other_ref_type, other_ref) |
|
91 | other_repo = request.GET.get('repo', org_repo) | |
|
91 | other_repo = request.GET.get('other_repo', org_repo) | |
|
92 | 92 | c.fulldiff = fulldiff = request.GET.get('fulldiff') |
|
93 | 93 | rev_start = request.GET.get('rev_start') |
|
94 | 94 | rev_end = request.GET.get('rev_end') |
|
95 | 95 | |
|
96 |
c.swap_url = h.url('compare_url', |
|
|
96 | c.swap_url = h.url('compare_url', as_form=request.GET.get('as_form'), | |
|
97 | repo_name=other_repo, | |
|
97 | 98 |
|
|
98 | other_ref_type=org_ref[0], other_ref=org_ref[1], | |
|
99 | repo=org_repo, as_form=request.GET.get('as_form')) | |
|
99 | repo=org_repo, | |
|
100 | other_ref_type=org_ref[0], other_ref=org_ref[1]) | |
|
100 | 101 | |
|
101 | 102 | c.org_repo = org_repo = Repository.get_by_repo_name(org_repo) |
|
102 | 103 | c.other_repo = other_repo = Repository.get_by_repo_name(other_repo) |
|
103 | 104 | |
|
104 | 105 | if c.org_repo is None: |
|
105 | 106 | log.error('Could not find org repo %s' % org_repo) |
|
106 | 107 | raise HTTPNotFound |
|
107 | 108 | if c.other_repo is None: |
|
108 | 109 | log.error('Could not find other repo %s' % other_repo) |
|
109 | 110 | raise HTTPNotFound |
|
110 | 111 | |
|
111 | 112 | if c.org_repo != c.other_repo and h.is_git(c.rhodecode_repo): |
|
112 | 113 | log.error('compare of two remote repos not available for GIT REPOS') |
|
113 | 114 | raise HTTPNotFound |
|
114 | 115 | |
|
115 | 116 | if c.org_repo.scm_instance.alias != c.other_repo.scm_instance.alias: |
|
116 | 117 | log.error('compare of two different kind of remote repos not available') |
|
117 | 118 | raise HTTPNotFound |
|
118 | 119 | |
|
119 | 120 | partial = request.environ.get('HTTP_X_PARTIAL_XHR') |
|
120 | 121 | self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial) |
|
121 | 122 | self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial) |
|
122 | 123 | |
|
123 | 124 | if rev_start and rev_end: |
|
124 | 125 | #replace our org_ref with given CS |
|
125 | 126 | org_ref = ('rev', rev_start) |
|
126 | 127 | other_ref = ('rev', rev_end) |
|
127 | 128 | |
|
128 | 129 | c.cs_ranges = PullRequestModel().get_compare_data( |
|
129 | 130 | org_repo, org_ref, other_repo, other_ref, |
|
130 | 131 | ) |
|
131 | 132 | |
|
132 | 133 | c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in |
|
133 | 134 | c.cs_ranges]) |
|
134 | 135 | c.target_repo = c.repo_name |
|
135 | 136 | # defines that we need hidden inputs with changesets |
|
136 | 137 | c.as_form = request.GET.get('as_form', False) |
|
137 | 138 | if partial: |
|
138 | 139 | return render('compare/compare_cs.html') |
|
139 | 140 | |
|
140 | 141 | c.org_ref = org_ref[1] |
|
141 | 142 | c.other_ref = other_ref[1] |
|
142 | 143 | |
|
143 | 144 | if c.cs_ranges and c.org_repo != c.other_repo: |
|
144 | 145 | # case we want a simple diff without incoming changesets, just |
|
145 | 146 | # for review purposes. Make the diff on the forked repo, with |
|
146 | 147 | # revision that is common ancestor |
|
147 | 148 | _org_ref = org_ref |
|
148 | 149 | org_ref = ('rev', getattr(c.cs_ranges[0].parents[0] |
|
149 | 150 | if c.cs_ranges[0].parents |
|
150 | 151 | else EmptyChangeset(), 'raw_id')) |
|
151 | 152 | log.debug('Changed org_ref from %s to %s' % (_org_ref, org_ref)) |
|
152 | 153 | other_repo = org_repo |
|
153 | 154 | |
|
154 | 155 | diff_limit = self.cut_off_limit if not fulldiff else None |
|
155 | 156 | |
|
156 | 157 | _diff = diffs.differ(org_repo, org_ref, other_repo, other_ref) |
|
157 | 158 | |
|
158 | 159 | diff_processor = diffs.DiffProcessor(_diff or '', format='gitdiff', |
|
159 | 160 | diff_limit=diff_limit) |
|
160 | 161 | _parsed = diff_processor.prepare() |
|
161 | 162 | |
|
162 | 163 | c.limited_diff = False |
|
163 | 164 | if isinstance(_parsed, LimitedDiffContainer): |
|
164 | 165 | c.limited_diff = True |
|
165 | 166 | |
|
166 | 167 | c.files = [] |
|
167 | 168 | c.changes = {} |
|
168 | 169 | c.lines_added = 0 |
|
169 | 170 | c.lines_deleted = 0 |
|
170 | 171 | for f in _parsed: |
|
171 | 172 | st = f['stats'] |
|
172 | 173 | if st[0] != 'b': |
|
173 | 174 | c.lines_added += st[0] |
|
174 | 175 | c.lines_deleted += st[1] |
|
175 | 176 | fid = h.FID('', f['filename']) |
|
176 | 177 | c.files.append([fid, f['operation'], f['filename'], f['stats']]) |
|
177 | 178 | diff = diff_processor.as_html(enable_comments=False, parsed_lines=[f]) |
|
178 | 179 | c.changes[fid] = [f['operation'], f['filename'], diff] |
|
179 | 180 | |
|
180 | 181 | return render('compare/compare_diff.html') |
@@ -1,367 +1,367 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <%inherit file="root.html"/> |
|
3 | 3 | |
|
4 | 4 | <!-- HEADER --> |
|
5 | 5 | <div id="header-dd"></div> |
|
6 | 6 | <div id="header"> |
|
7 | 7 | <div id="header-inner" class="title"> |
|
8 | 8 | <div id="logo"> |
|
9 | 9 | <h1><a href="${h.url('home')}">${c.rhodecode_name}</a></h1> |
|
10 | 10 | </div> |
|
11 | 11 | <!-- MENU --> |
|
12 | 12 | ${self.page_nav()} |
|
13 | 13 | <!-- END MENU --> |
|
14 | 14 | ${self.body()} |
|
15 | 15 | </div> |
|
16 | 16 | </div> |
|
17 | 17 | <!-- END HEADER --> |
|
18 | 18 | |
|
19 | 19 | <!-- CONTENT --> |
|
20 | 20 | <div id="content"> |
|
21 | 21 | <div class="flash_msg"> |
|
22 | 22 | <% messages = h.flash.pop_messages() %> |
|
23 | 23 | % if messages: |
|
24 | 24 | <ul id="flash-messages"> |
|
25 | 25 | % for message in messages: |
|
26 | 26 | <li class="${message.category}_msg">${message}</li> |
|
27 | 27 | % endfor |
|
28 | 28 | </ul> |
|
29 | 29 | % endif |
|
30 | 30 | </div> |
|
31 | 31 | <div id="main"> |
|
32 | 32 | ${next.main()} |
|
33 | 33 | </div> |
|
34 | 34 | </div> |
|
35 | 35 | <!-- END CONTENT --> |
|
36 | 36 | |
|
37 | 37 | <!-- FOOTER --> |
|
38 | 38 | <div id="footer"> |
|
39 | 39 | <div id="footer-inner" class="title"> |
|
40 | 40 | <div> |
|
41 | 41 | <p class="footer-link"> |
|
42 | 42 | <a href="${h.url('bugtracker')}">${_('Submit a bug')}</a> |
|
43 | 43 | </p> |
|
44 | 44 | <p class="footer-link-right"> |
|
45 | 45 | <a href="${h.url('rhodecode_official')}">RhodeCode${'-%s' % c.rhodecode_instanceid if c.rhodecode_instanceid else ''}</a> |
|
46 | 46 | ${c.rhodecode_version} © 2010-${h.datetime.today().year} by Marcin Kuzminski |
|
47 | 47 | </p> |
|
48 | 48 | </div> |
|
49 | 49 | </div> |
|
50 | 50 | </div> |
|
51 | 51 | <!-- END FOOTER --> |
|
52 | 52 | |
|
53 | 53 | ### MAKO DEFS ### |
|
54 | 54 | <%def name="page_nav()"> |
|
55 | 55 | ${self.menu()} |
|
56 | 56 | </%def> |
|
57 | 57 | |
|
58 | 58 | <%def name="breadcrumbs()"> |
|
59 | 59 | <div class="breadcrumbs"> |
|
60 | 60 | ${self.breadcrumbs_links()} |
|
61 | 61 | </div> |
|
62 | 62 | </%def> |
|
63 | 63 | |
|
64 | 64 | <%def name="usermenu()"> |
|
65 | 65 | ## USER MENU |
|
66 | 66 | <li> |
|
67 | 67 | <a class="menu_link" id="quick_login_link"> |
|
68 | 68 | <span class="icon" style="padding:5px 5px 0px 5px"> |
|
69 | 69 | <img src="${h.gravatar_url(c.rhodecode_user.email,20)}" alt="avatar"> |
|
70 | 70 | </span> |
|
71 | 71 | %if c.rhodecode_user.username != 'default': |
|
72 | 72 | <span class="menu_link_user">${c.rhodecode_user.username}</span> |
|
73 | 73 | %if c.unread_notifications != 0: |
|
74 | 74 | <span class="menu_link_notifications">${c.unread_notifications}</span> |
|
75 | 75 | %endif |
|
76 | 76 | %else: |
|
77 | 77 | <span>${_('Not logged in')}</span> |
|
78 | 78 | %endif |
|
79 | 79 | </a> |
|
80 | 80 | |
|
81 | 81 | <div class="user-menu"> |
|
82 | 82 | <div id="quick_login"> |
|
83 | 83 | %if c.rhodecode_user.username == 'default': |
|
84 | 84 | <h4>${_('Login to your account')}</h4> |
|
85 | 85 | ${h.form(h.url('login_home',came_from=h.url.current()))} |
|
86 | 86 | <div class="form"> |
|
87 | 87 | <div class="fields"> |
|
88 | 88 | <div class="field"> |
|
89 | 89 | <div class="label"> |
|
90 | 90 | <label for="username">${_('Username')}:</label> |
|
91 | 91 | </div> |
|
92 | 92 | <div class="input"> |
|
93 | 93 | ${h.text('username',class_='focus',size=40)} |
|
94 | 94 | </div> |
|
95 | 95 | |
|
96 | 96 | </div> |
|
97 | 97 | <div class="field"> |
|
98 | 98 | <div class="label"> |
|
99 | 99 | <label for="password">${_('Password')}:</label> |
|
100 | 100 | </div> |
|
101 | 101 | <div class="input"> |
|
102 | 102 | ${h.password('password',class_='focus',size=40)} |
|
103 | 103 | </div> |
|
104 | 104 | |
|
105 | 105 | </div> |
|
106 | 106 | <div class="buttons"> |
|
107 | 107 | <div class="password_forgoten">${h.link_to(_('Forgot password ?'),h.url('reset_password'))}</div> |
|
108 | 108 | <div class="register"> |
|
109 | 109 | %if h.HasPermissionAny('hg.admin', 'hg.register.auto_activate', 'hg.register.manual_activate')(): |
|
110 | 110 | ${h.link_to(_("Don't have an account ?"),h.url('register'))} |
|
111 | 111 | %endif |
|
112 | 112 | </div> |
|
113 | 113 | <div class="submit"> |
|
114 | 114 | ${h.submit('sign_in',_('Log In'),class_="ui-btn xsmall")} |
|
115 | 115 | </div> |
|
116 | 116 | </div> |
|
117 | 117 | </div> |
|
118 | 118 | </div> |
|
119 | 119 | ${h.end_form()} |
|
120 | 120 | %else: |
|
121 | 121 | <div class="links_left"> |
|
122 | 122 | <div class="full_name">${c.rhodecode_user.full_name_or_username}</div> |
|
123 | 123 | <div class="email">${c.rhodecode_user.email}</div> |
|
124 | 124 | <div class="big_gravatar"><img alt="gravatar" src="${h.gravatar_url(c.rhodecode_user.email,48)}" /></div> |
|
125 | 125 | <div class="notifications"><a href="${h.url('notifications')}">${_('Notifications')}</a></div> |
|
126 | 126 | <div class="unread"><a href="${h.url('notifications')}">${_('Unread')}: ${c.unread_notifications}</a></div> |
|
127 | 127 | </div> |
|
128 | 128 | <div class="links_right"> |
|
129 | 129 | <ol class="links"> |
|
130 | 130 | <li>${h.link_to(_(u'Home'),h.url('home'))}</li> |
|
131 | 131 | <li>${h.link_to(_(u'Journal'),h.url('journal'))}</li> |
|
132 | 132 | <li>${h.link_to(_(u'My account'),h.url('admin_settings_my_account'))}</li> |
|
133 | 133 | <li class="logout">${h.link_to(_(u'Log Out'),h.url('logout_home'))}</li> |
|
134 | 134 | </ol> |
|
135 | 135 | </div> |
|
136 | 136 | %endif |
|
137 | 137 | </div> |
|
138 | 138 | </div> |
|
139 | 139 | |
|
140 | 140 | </li> |
|
141 | 141 | </%def> |
|
142 | 142 | |
|
143 | 143 | <%def name="menu(current=None)"> |
|
144 | 144 | <% |
|
145 | 145 | def is_current(selected): |
|
146 | 146 | if selected == current: |
|
147 | 147 | return h.literal('class="current"') |
|
148 | 148 | %> |
|
149 | 149 | <ul id="quick"> |
|
150 | 150 | <!-- repo switcher --> |
|
151 | 151 | <li ${is_current('home')}> |
|
152 | 152 | <a class="menu_link" id="repo_switcher" title="${_('Switch repository')}" href="${h.url('home')}"> |
|
153 | 153 | <span class="icon"> |
|
154 | 154 | <img src="${h.url('/images/icons/database.png')}" alt="${_('Products')}" /> |
|
155 | 155 | </span> |
|
156 | 156 | <span>${_('Repositories')}</span> |
|
157 | 157 | </a> |
|
158 | 158 | <ul id="repo_switcher_list" class="repo_switcher"> |
|
159 | 159 | <li> |
|
160 | 160 | <a href="#">${_('loading...')}</a> |
|
161 | 161 | </li> |
|
162 | 162 | </ul> |
|
163 | 163 | </li> |
|
164 | 164 | ## we render this menu only not for those pages |
|
165 | 165 | %if current not in ['home','admin', 'search', 'journal']: |
|
166 | 166 | ##REGULAR MENU |
|
167 | 167 | <li ${is_current('summary')}> |
|
168 | 168 | <a class="menu_link" title="${_('Summary page')}" href="${h.url('summary_home',repo_name=c.repo_name)}"> |
|
169 | 169 | <span class="icon"> |
|
170 | 170 | <img src="${h.url('/images/icons/clipboard_16.png')}" alt="${_('Summary')}" /> |
|
171 | 171 | </span> |
|
172 | 172 | <span>${_('Summary')}</span> |
|
173 | 173 | </a> |
|
174 | 174 | </li> |
|
175 | 175 | <li ${is_current('changelog')}> |
|
176 | 176 | <a class="menu_link" title="${_('Changeset list')}" href="${h.url('changelog_home',repo_name=c.repo_name)}"> |
|
177 | 177 | <span class="icon"> |
|
178 | 178 | <img src="${h.url('/images/icons/time.png')}" alt="${_('Changelog')}" /> |
|
179 | 179 | </span> |
|
180 | 180 | <span>${_('Changelog')}</span> |
|
181 | 181 | </a> |
|
182 | 182 | </li> |
|
183 | 183 | <li ${is_current('switch_to')}> |
|
184 | 184 | <a class="menu_link" id="branch_tag_switcher" title="${_('Switch to')}" href="#"> |
|
185 | 185 | <span class="icon"> |
|
186 | 186 | <img src="${h.url('/images/icons/arrow_switch.png')}" alt="${_('Switch to')}" /> |
|
187 | 187 | </span> |
|
188 | 188 | <span>${_('Switch to')}</span> |
|
189 | 189 | </a> |
|
190 | 190 | <ul id="switch_to_list" class="switch_to"> |
|
191 | 191 | <li><a href="#">${_('loading...')}</a></li> |
|
192 | 192 | </ul> |
|
193 | 193 | </li> |
|
194 | 194 | <li ${is_current('files')}> |
|
195 | 195 | <a class="menu_link" title="${_('Show repository content')}" href="${h.url('files_home',repo_name=c.repo_name)}"> |
|
196 | 196 | <span class="icon"> |
|
197 | 197 | <img src="${h.url('/images/icons/file.png')}" alt="${_('Files')}" /> |
|
198 | 198 | </span> |
|
199 | 199 | <span>${_('Files')}</span> |
|
200 | 200 | </a> |
|
201 | 201 | </li> |
|
202 | 202 | <li ${is_current('options')}> |
|
203 | 203 | <a class="menu_link" title="${_('Options')}" href="#"> |
|
204 | 204 | <span class="icon"> |
|
205 | 205 | <img src="${h.url('/images/icons/table_gear.png')}" alt="${_('Admin')}" /> |
|
206 | 206 | </span> |
|
207 | 207 | <span>${_('Options')}</span> |
|
208 | 208 | </a> |
|
209 | 209 | <ul> |
|
210 | 210 | %if h.HasRepoPermissionAll('repository.admin')(c.repo_name): |
|
211 | 211 | %if h.HasPermissionAll('hg.admin')('access settings on repository'): |
|
212 | 212 | <li>${h.link_to(_('repository settings'),h.url('edit_repo',repo_name=c.repo_name),class_='settings')}</li> |
|
213 | 213 | %else: |
|
214 | 214 | <li>${h.link_to(_('repository settings'),h.url('repo_settings_home',repo_name=c.repo_name),class_='settings')}</li> |
|
215 | 215 | %endif |
|
216 | 216 | %endif |
|
217 | 217 | |
|
218 | 218 | <li>${h.link_to(_('fork'),h.url('repo_fork_home',repo_name=c.repo_name),class_='fork')}</li> |
|
219 | 219 | %if h.is_hg(c.rhodecode_repo): |
|
220 | 220 | <li>${h.link_to(_('open new pull request'),h.url('pullrequest_home',repo_name=c.repo_name),class_='pull_request')}</li> |
|
221 | 221 | %endif |
|
222 | 222 | %if c.rhodecode_db_repo.fork: |
|
223 |
<li>${h.link_to(_('compare fork'),h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_re |
|
|
223 | <li>${h.link_to(_('compare fork'),h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_repo=c.rhodecode_db_repo.fork.repo_name,other_ref_type='branch',other_ref='default'),class_='compare_request')}</li> | |
|
224 | 224 | %endif |
|
225 | 225 | <li>${h.link_to(_('lightweight changelog'),h.url('shortlog_home',repo_name=c.repo_name),class_='shortlog')}</li> |
|
226 | 226 | <li>${h.link_to(_('search'),h.url('search_repo',repo_name=c.repo_name),class_='search')}</li> |
|
227 | 227 | |
|
228 | 228 | %if h.HasRepoPermissionAny('repository.write','repository.admin')(c.repo_name) and c.rhodecode_db_repo.enable_locking: |
|
229 | 229 | %if c.rhodecode_db_repo.locked[0]: |
|
230 | 230 | <li>${h.link_to(_('unlock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_del')}</li> |
|
231 | 231 | %else: |
|
232 | 232 | <li>${h.link_to(_('lock'), h.url('toggle_locking',repo_name=c.repo_name),class_='locking_add')}</li> |
|
233 | 233 | %endif |
|
234 | 234 | %endif |
|
235 | 235 | |
|
236 | 236 | % if h.HasPermissionAll('hg.admin')('access admin main page'): |
|
237 | 237 | <li> |
|
238 | 238 | ${h.link_to(_('admin'),h.url('admin_home'),class_='admin')} |
|
239 | 239 | <%def name="admin_menu()"> |
|
240 | 240 | <ul> |
|
241 | 241 | <li>${h.link_to(_('admin journal'),h.url('admin_home'),class_='journal')}</li> |
|
242 | 242 | <li>${h.link_to(_('repositories'),h.url('repos'),class_='repos')}</li> |
|
243 | 243 | <li>${h.link_to(_('repositories groups'),h.url('repos_groups'),class_='repos_groups')}</li> |
|
244 | 244 | <li>${h.link_to(_('users'),h.url('users'),class_='users')}</li> |
|
245 | 245 | <li>${h.link_to(_('users groups'),h.url('users_groups'),class_='groups')}</li> |
|
246 | 246 | <li>${h.link_to(_('permissions'),h.url('edit_permission',id='default'),class_='permissions')}</li> |
|
247 | 247 | <li>${h.link_to(_('ldap'),h.url('ldap_home'),class_='ldap')}</li> |
|
248 | 248 | <li>${h.link_to(_('defaults'),h.url('defaults'),class_='defaults')}</li> |
|
249 | 249 | <li class="last">${h.link_to(_('settings'),h.url('admin_settings'),class_='settings')}</li> |
|
250 | 250 | </ul> |
|
251 | 251 | </%def> |
|
252 | 252 | ## ADMIN MENU |
|
253 | 253 | ${admin_menu()} |
|
254 | 254 | </li> |
|
255 | 255 | % endif |
|
256 | 256 | </ul> |
|
257 | 257 | </li> |
|
258 | 258 | <li> |
|
259 | 259 | <a class="menu_link" title="${_('Followers')}" href="${h.url('repo_followers_home',repo_name=c.repo_name)}"> |
|
260 | 260 | <span class="icon_short"> |
|
261 | 261 | <img src="${h.url('/images/icons/heart.png')}" alt="${_('Followers')}" /> |
|
262 | 262 | </span> |
|
263 | 263 | <span id="current_followers_count" class="short">${c.repository_followers}</span> |
|
264 | 264 | </a> |
|
265 | 265 | </li> |
|
266 | 266 | <li> |
|
267 | 267 | <a class="menu_link" title="${_('Forks')}" href="${h.url('repo_forks_home',repo_name=c.repo_name)}"> |
|
268 | 268 | <span class="icon_short"> |
|
269 | 269 | <img src="${h.url('/images/icons/arrow_divide.png')}" alt="${_('Forks')}" /> |
|
270 | 270 | </span> |
|
271 | 271 | <span class="short">${c.repository_forks}</span> |
|
272 | 272 | </a> |
|
273 | 273 | </li> |
|
274 | 274 | <li> |
|
275 | 275 | <a class="menu_link" title="${_('Pull requests')}" href="${h.url('pullrequest_show_all',repo_name=c.repo_name)}"> |
|
276 | 276 | <span class="icon_short"> |
|
277 | 277 | <img src="${h.url('/images/icons/arrow_join.png')}" alt="${_('Pull requests')}" /> |
|
278 | 278 | </span> |
|
279 | 279 | <span class="short">${c.repository_pull_requests}</span> |
|
280 | 280 | </a> |
|
281 | 281 | </li> |
|
282 | 282 | ${usermenu()} |
|
283 | 283 | <script type="text/javascript"> |
|
284 | 284 | YUE.on('branch_tag_switcher','mouseover',function(){ |
|
285 | 285 | var loaded = YUD.hasClass('branch_tag_switcher','loaded'); |
|
286 | 286 | if(!loaded){ |
|
287 | 287 | YUD.addClass('branch_tag_switcher','loaded'); |
|
288 | 288 | ypjax("${h.url('branch_tag_switcher',repo_name=c.repo_name)}",'switch_to_list', |
|
289 | 289 | function(o){}, |
|
290 | 290 | function(o){YUD.removeClass('branch_tag_switcher','loaded');} |
|
291 | 291 | ,null); |
|
292 | 292 | } |
|
293 | 293 | return false; |
|
294 | 294 | }); |
|
295 | 295 | </script> |
|
296 | 296 | %else: |
|
297 | 297 | ##ROOT MENU |
|
298 | 298 | %if c.rhodecode_user.username != 'default': |
|
299 | 299 | <li ${is_current('journal')}> |
|
300 | 300 | <a class="menu_link" title="${_('Show recent activity')}" href="${h.url('journal')}"> |
|
301 | 301 | <span class="icon"> |
|
302 | 302 | <img src="${h.url('/images/icons/book.png')}" alt="${_('Journal')}" /> |
|
303 | 303 | </span> |
|
304 | 304 | <span>${_('Journal')}</span> |
|
305 | 305 | </a> |
|
306 | 306 | </li> |
|
307 | 307 | %else: |
|
308 | 308 | <li ${is_current('journal')}> |
|
309 | 309 | <a class="menu_link" title="${_('Public journal')}" href="${h.url('public_journal')}"> |
|
310 | 310 | <span class="icon"> |
|
311 | 311 | <img src="${h.url('/images/icons/book.png')}" alt="${_('Public journal')}" /> |
|
312 | 312 | </span> |
|
313 | 313 | <span>${_('Public journal')}</span> |
|
314 | 314 | </a> |
|
315 | 315 | </li> |
|
316 | 316 | %endif |
|
317 | 317 | <li ${is_current('search')}> |
|
318 | 318 | <a class="menu_link" title="${_('Search in repositories')}" href="${h.url('search')}"> |
|
319 | 319 | <span class="icon"> |
|
320 | 320 | <img src="${h.url('/images/icons/search_16.png')}" alt="${_('Search')}" /> |
|
321 | 321 | </span> |
|
322 | 322 | <span>${_('Search')}</span> |
|
323 | 323 | </a> |
|
324 | 324 | </li> |
|
325 | 325 | %if h.HasPermissionAll('hg.admin')('access admin main page'): |
|
326 | 326 | <li ${is_current('admin')}> |
|
327 | 327 | <a class="menu_link" title="${_('Admin')}" href="${h.url('admin_home')}"> |
|
328 | 328 | <span class="icon"> |
|
329 | 329 | <img src="${h.url('/images/icons/cog_edit.png')}" alt="${_('Admin')}" /> |
|
330 | 330 | </span> |
|
331 | 331 | <span>${_('Admin')}</span> |
|
332 | 332 | </a> |
|
333 | 333 | ${admin_menu()} |
|
334 | 334 | </li> |
|
335 | 335 | %endif |
|
336 | 336 | ${usermenu()} |
|
337 | 337 | %endif |
|
338 | 338 | <script type="text/javascript"> |
|
339 | 339 | YUE.on('repo_switcher','mouseover',function(){ |
|
340 | 340 | var target = 'q_filter_rs'; |
|
341 | 341 | var qfilter_activate = function(){ |
|
342 | 342 | var nodes = YUQ('ul#repo_switcher_list li a.repo_name'); |
|
343 | 343 | var func = function(node){ |
|
344 | 344 | return node.parentNode; |
|
345 | 345 | } |
|
346 | 346 | q_filter(target,nodes,func); |
|
347 | 347 | } |
|
348 | 348 | |
|
349 | 349 | var loaded = YUD.hasClass('repo_switcher','loaded'); |
|
350 | 350 | if(!loaded){ |
|
351 | 351 | YUD.addClass('repo_switcher','loaded'); |
|
352 | 352 | ypjax("${h.url('repo_switcher')}",'repo_switcher_list', |
|
353 | 353 | function(o){qfilter_activate();YUD.get(target).focus()}, |
|
354 | 354 | function(o){YUD.removeClass('repo_switcher','loaded');} |
|
355 | 355 | ,null); |
|
356 | 356 | }else{ |
|
357 | 357 | YUD.get(target).focus(); |
|
358 | 358 | } |
|
359 | 359 | return false; |
|
360 | 360 | }); |
|
361 | 361 | |
|
362 | 362 | YUE.on('header-dd', 'click',function(e){ |
|
363 | 363 | YUD.addClass('header-inner', 'hover'); |
|
364 | 364 | }); |
|
365 | 365 | |
|
366 | 366 | </script> |
|
367 | 367 | </%def> |
@@ -1,306 +1,306 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | <%inherit file="/base/base.html"/> |
|
4 | 4 | |
|
5 | 5 | <%def name="title()"> |
|
6 | 6 | ${_('%s Changelog') % c.repo_name} - ${c.rhodecode_name} |
|
7 | 7 | </%def> |
|
8 | 8 | |
|
9 | 9 | <%def name="breadcrumbs_links()"> |
|
10 | 10 | ${h.link_to(_(u'Home'),h.url('/'))} |
|
11 | 11 | » |
|
12 | 12 | ${h.link_to(c.repo_name,h.url('summary_home',repo_name=c.repo_name))} |
|
13 | 13 | » |
|
14 | 14 | <% size = c.size if c.size <= c.total_cs else c.total_cs %> |
|
15 | 15 | ${_('Changelog')} - ${ungettext('showing %d out of %d revision', 'showing %d out of %d revisions', size) % (size, c.total_cs)} |
|
16 | 16 | </%def> |
|
17 | 17 | |
|
18 | 18 | <%def name="page_nav()"> |
|
19 | 19 | ${self.menu('changelog')} |
|
20 | 20 | </%def> |
|
21 | 21 | |
|
22 | 22 | <%def name="main()"> |
|
23 | 23 | <div class="box"> |
|
24 | 24 | <!-- box / title --> |
|
25 | 25 | <div class="title"> |
|
26 | 26 | ${self.breadcrumbs()} |
|
27 | 27 | </div> |
|
28 | 28 | <div class="table"> |
|
29 | 29 | % if c.pagination: |
|
30 | 30 | <div id="graph"> |
|
31 | 31 | <div id="graph_nodes"> |
|
32 | 32 | <canvas id="graph_canvas"></canvas> |
|
33 | 33 | </div> |
|
34 | 34 | <div id="graph_content"> |
|
35 | 35 | <div class="info_box" style="clear: both;padding: 10px 6px;vertical-align: right;text-align: right;"> |
|
36 | 36 | <a href="#" class="ui-btn small" id="rev_range_container" style="display:none"></a> |
|
37 | 37 | <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a> |
|
38 | 38 | |
|
39 | 39 | %if c.rhodecode_db_repo.fork: |
|
40 |
<a title="${_('compare fork with %s' % c.rhodecode_db_repo.fork.repo_name)}" href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_re |
|
|
40 | <a title="${_('compare fork with %s' % c.rhodecode_db_repo.fork.repo_name)}" href="${h.url('compare_url',repo_name=c.repo_name,org_ref_type='branch',org_ref=request.GET.get('branch') or 'default',other_repo=c.rhodecode_db_repo.fork.repo_name,other_ref_type='branch',other_ref='default')}" class="ui-btn small">${_('Compare fork with parent')}</a> | |
|
41 | 41 | %endif |
|
42 | 42 | %if h.is_hg(c.rhodecode_repo): |
|
43 | 43 | <a id="open_new_pr" href="${h.url('pullrequest_home',repo_name=c.repo_name)}" class="ui-btn small">${_('open new pull request')}</a> |
|
44 | 44 | %endif |
|
45 | 45 | </div> |
|
46 | 46 | <div class="container_header"> |
|
47 | 47 | ${h.form(h.url.current(),method='get')} |
|
48 | 48 | <div class="info_box" style="float:left"> |
|
49 | 49 | ${h.submit('set',_('Show'),class_="ui-btn")} |
|
50 | 50 | ${h.text('size',size=1,value=c.size)} |
|
51 | 51 | ${_('revisions')} |
|
52 | 52 | </div> |
|
53 | 53 | ${h.end_form()} |
|
54 | 54 | <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div> |
|
55 | 55 | </div> |
|
56 | 56 | |
|
57 | 57 | %for cnt,cs in enumerate(c.pagination): |
|
58 | 58 | <div id="chg_${cnt+1}" class="container ${'tablerow%s' % (cnt%2)}"> |
|
59 | 59 | <div class="left"> |
|
60 | 60 | <div> |
|
61 | 61 | ${h.checkbox(cs.raw_id,class_="changeset_range")} |
|
62 | 62 | <span class="tooltip" title="${h.tooltip(h.age(cs.date))}"><a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id)}"><span class="changeset_id">${cs.revision}:<span class="changeset_hash">${h.short_id(cs.raw_id)}</span></span></a></span> |
|
63 | 63 | </div> |
|
64 | 64 | <div class="author"> |
|
65 | 65 | <div class="gravatar"> |
|
66 | 66 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(cs.author),16)}"/> |
|
67 | 67 | </div> |
|
68 | 68 | <div title="${cs.author}" class="user">${h.shorter(h.person(cs.author),22)}</div> |
|
69 | 69 | </div> |
|
70 | 70 | <div class="date">${h.fmt_date(cs.date)}</div> |
|
71 | 71 | </div> |
|
72 | 72 | <div class="mid"> |
|
73 | 73 | <div class="message">${h.urlify_commit(cs.message, c.repo_name,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}</div> |
|
74 | 74 | <div class="expand"><span class="expandtext">↓ ${_('show more')} ↓</span></div> |
|
75 | 75 | </div> |
|
76 | 76 | <div class="right"> |
|
77 | 77 | <div class="changes"> |
|
78 | 78 | <div id="changed_total_${cs.raw_id}" style="float:right;" class="changed_total tooltip" title="${h.tooltip(_('Affected number of files, click to show more details'))}">${len(cs.affected_files)}</div> |
|
79 | 79 | <div class="comments-container"> |
|
80 | 80 | %if len(c.comments.get(cs.raw_id,[])) > 0: |
|
81 | 81 | <div class="comments-cnt" title="${('comments')}"> |
|
82 | 82 | <a href="${h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id,anchor='comment-%s' % c.comments[cs.raw_id][0].comment_id)}"> |
|
83 | 83 | <div class="comments-cnt">${len(c.comments[cs.raw_id])}</div> |
|
84 | 84 | <img src="${h.url('/images/icons/comments.png')}"> |
|
85 | 85 | </a> |
|
86 | 86 | </div> |
|
87 | 87 | %endif |
|
88 | 88 | </div> |
|
89 | 89 | <div class="changeset-status-container"> |
|
90 | 90 | %if c.statuses.get(cs.raw_id): |
|
91 | 91 | <div title="${_('Changeset status')}" class="changeset-status-lbl">${c.statuses.get(cs.raw_id)[1]}</div> |
|
92 | 92 | <div class="changeset-status-ico"> |
|
93 | 93 | %if c.statuses.get(cs.raw_id)[2]: |
|
94 | 94 | <a class="tooltip" title="${_('Click to open associated pull request #%s' % c.statuses.get(cs.raw_id)[2])}" href="${h.url('pullrequest_show',repo_name=c.statuses.get(cs.raw_id)[3],pull_request_id=c.statuses.get(cs.raw_id)[2])}"><img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" /></a> |
|
95 | 95 | %else: |
|
96 | 96 | <img src="${h.url('/images/icons/flag_status_%s.png' % c.statuses.get(cs.raw_id)[0])}" /> |
|
97 | 97 | %endif |
|
98 | 98 | </div> |
|
99 | 99 | %endif |
|
100 | 100 | </div> |
|
101 | 101 | </div> |
|
102 | 102 | %if cs.parents: |
|
103 | 103 | %for p_cs in reversed(cs.parents): |
|
104 | 104 | <div class="parent">${_('Parent')} |
|
105 | 105 | <span class="changeset_id">${p_cs.revision}:<span class="changeset_hash">${h.link_to(h.short_id(p_cs.raw_id), |
|
106 | 106 | h.url('changeset_home',repo_name=c.repo_name,revision=p_cs.raw_id),title=p_cs.message)}</span></span> |
|
107 | 107 | </div> |
|
108 | 108 | %endfor |
|
109 | 109 | %else: |
|
110 | 110 | <div class="parent">${_('No parents')}</div> |
|
111 | 111 | %endif |
|
112 | 112 | |
|
113 | 113 | <span class="logtags"> |
|
114 | 114 | %if len(cs.parents)>1: |
|
115 | 115 | <span class="merge">${_('merge')}</span> |
|
116 | 116 | %endif |
|
117 | 117 | %if cs.branch: |
|
118 | 118 | <span class="branchtag" title="${'%s %s' % (_('branch'),cs.branch)}"> |
|
119 | 119 | ${h.link_to(h.shorter(cs.branch),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))} |
|
120 | 120 | </span> |
|
121 | 121 | %endif |
|
122 | 122 | %if h.is_hg(c.rhodecode_repo): |
|
123 | 123 | %for book in cs.bookmarks: |
|
124 | 124 | <span class="bookbook" title="${'%s %s' % (_('bookmark'),book)}"> |
|
125 | 125 | ${h.link_to(h.shorter(book),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))} |
|
126 | 126 | </span> |
|
127 | 127 | %endfor |
|
128 | 128 | %endif |
|
129 | 129 | %for tag in cs.tags: |
|
130 | 130 | <span class="tagtag" title="${'%s %s' % (_('tag'),tag)}"> |
|
131 | 131 | ${h.link_to(h.shorter(tag),h.url('files_home',repo_name=c.repo_name,revision=cs.raw_id))}</span> |
|
132 | 132 | %endfor |
|
133 | 133 | </span> |
|
134 | 134 | </div> |
|
135 | 135 | </div> |
|
136 | 136 | |
|
137 | 137 | %endfor |
|
138 | 138 | <div class="pagination-wh pagination-left"> |
|
139 | 139 | ${c.pagination.pager('$link_previous ~2~ $link_next')} |
|
140 | 140 | </div> |
|
141 | 141 | </div> |
|
142 | 142 | </div> |
|
143 | 143 | |
|
144 | 144 | <script type="text/javascript" src="${h.url('/js/graph.js')}"></script> |
|
145 | 145 | <script type="text/javascript"> |
|
146 | 146 | YAHOO.util.Event.onDOMReady(function(){ |
|
147 | 147 | |
|
148 | 148 | //Monitor range checkboxes and build a link to changesets |
|
149 | 149 | //ranges |
|
150 | 150 | var checkboxes = YUD.getElementsByClassName('changeset_range'); |
|
151 | 151 | var url_tmpl = "${h.url('changeset_home',repo_name=c.repo_name,revision='__REVRANGE__')}"; |
|
152 | 152 | var pr_tmpl = "${h.url('pullrequest_home',repo_name=c.repo_name)}"; |
|
153 | 153 | YUE.on(checkboxes,'click',function(e){ |
|
154 | 154 | var clicked_cb = e.currentTarget; |
|
155 | 155 | var checked_checkboxes = []; |
|
156 | 156 | for (pos in checkboxes){ |
|
157 | 157 | if(checkboxes[pos].checked){ |
|
158 | 158 | checked_checkboxes.push(checkboxes[pos]); |
|
159 | 159 | } |
|
160 | 160 | } |
|
161 | 161 | if(YUD.get('open_new_pr')){ |
|
162 | 162 | if(checked_checkboxes.length>0){ |
|
163 | 163 | // modify open pull request to show we have selected cs |
|
164 | 164 | YUD.get('open_new_pr').innerHTML = _TM['Open new pull request for selected changesets']; |
|
165 | 165 | |
|
166 | 166 | }else{ |
|
167 | 167 | YUD.get('open_new_pr').innerHTML = _TM['Open new pull request']; |
|
168 | 168 | } |
|
169 | 169 | } |
|
170 | 170 | |
|
171 | 171 | if(checked_checkboxes.length>0){ |
|
172 | 172 | var rev_end = checked_checkboxes[0].name; |
|
173 | 173 | var rev_start = checked_checkboxes[checked_checkboxes.length-1].name; |
|
174 | 174 | |
|
175 | 175 | // now select all checkboxes in the middle. |
|
176 | 176 | var checked = false; |
|
177 | 177 | for (var i=0; i<checkboxes.length; i++){ |
|
178 | 178 | var cb = checkboxes[i]; |
|
179 | 179 | var rev = cb.name; |
|
180 | 180 | |
|
181 | 181 | if (rev == rev_end){ |
|
182 | 182 | checked = true; |
|
183 | 183 | } |
|
184 | 184 | if (checked){ |
|
185 | 185 | cb.checked = true; |
|
186 | 186 | } |
|
187 | 187 | else{ |
|
188 | 188 | cb.checked = false; |
|
189 | 189 | } |
|
190 | 190 | if (rev == rev_start){ |
|
191 | 191 | checked = false; |
|
192 | 192 | } |
|
193 | 193 | |
|
194 | 194 | } |
|
195 | 195 | |
|
196 | 196 | var url = url_tmpl.replace('__REVRANGE__', |
|
197 | 197 | rev_start+'...'+rev_end); |
|
198 | 198 | |
|
199 | 199 | var link = _TM['Show selected changes __S -> __E']; |
|
200 | 200 | link = link.replace('__S',rev_start.substr(0,6)); |
|
201 | 201 | link = link.replace('__E',rev_end.substr(0,6)); |
|
202 | 202 | YUD.get('rev_range_container').href = url; |
|
203 | 203 | YUD.get('rev_range_container').innerHTML = link; |
|
204 | 204 | YUD.setStyle('rev_range_container','display',''); |
|
205 | 205 | YUD.setStyle('rev_range_clear','display',''); |
|
206 | 206 | |
|
207 | 207 | YUD.get('open_new_pr').href = pr_tmpl + '?rev_start={0}&rev_end={1}'.format(rev_start,rev_end); |
|
208 | 208 | |
|
209 | 209 | } |
|
210 | 210 | else{ |
|
211 | 211 | YUD.setStyle('rev_range_container','display','none'); |
|
212 | 212 | YUD.setStyle('rev_range_clear','display','none'); |
|
213 | 213 | } |
|
214 | 214 | }); |
|
215 | 215 | YUE.on('rev_range_clear','click',function(e){ |
|
216 | 216 | for (var i=0; i<checkboxes.length; i++){ |
|
217 | 217 | var cb = checkboxes[i]; |
|
218 | 218 | cb.checked = false; |
|
219 | 219 | } |
|
220 | 220 | YUE.preventDefault(e); |
|
221 | 221 | }) |
|
222 | 222 | var msgs = YUQ('.message'); |
|
223 | 223 | // get first element height |
|
224 | 224 | var el = YUQ('#graph_content .container')[0]; |
|
225 | 225 | var row_h = el.clientHeight; |
|
226 | 226 | for(var i=0;i<msgs.length;i++){ |
|
227 | 227 | var m = msgs[i]; |
|
228 | 228 | |
|
229 | 229 | var h = m.clientHeight; |
|
230 | 230 | var pad = YUD.getStyle(m,'padding'); |
|
231 | 231 | if(h > row_h){ |
|
232 | 232 | var offset = row_h - (h+12); |
|
233 | 233 | YUD.setStyle(m.nextElementSibling,'display','block'); |
|
234 | 234 | YUD.setStyle(m.nextElementSibling,'margin-top',offset+'px'); |
|
235 | 235 | }; |
|
236 | 236 | } |
|
237 | 237 | YUE.on(YUQ('.expand'),'click',function(e){ |
|
238 | 238 | var elem = e.currentTarget.parentNode.parentNode; |
|
239 | 239 | YUD.setStyle(e.currentTarget,'display','none'); |
|
240 | 240 | YUD.setStyle(elem,'height','auto'); |
|
241 | 241 | |
|
242 | 242 | //redraw the graph, line_count and jsdata are global vars |
|
243 | 243 | set_canvas(100); |
|
244 | 244 | |
|
245 | 245 | var r = new BranchRenderer(); |
|
246 | 246 | r.render(jsdata,100,line_count); |
|
247 | 247 | |
|
248 | 248 | }) |
|
249 | 249 | |
|
250 | 250 | // Fetch changeset details |
|
251 | 251 | YUE.on(YUD.getElementsByClassName('changed_total'),'click',function(e){ |
|
252 | 252 | var id = e.currentTarget.id; |
|
253 | 253 | var url = "${h.url('changelog_details',repo_name=c.repo_name,cs='__CS__')}"; |
|
254 | 254 | var url = url.replace('__CS__',id.replace('changed_total_','')); |
|
255 | 255 | ypjax(url,id,function(){tooltip_activate()}); |
|
256 | 256 | }); |
|
257 | 257 | |
|
258 | 258 | // change branch filter |
|
259 | 259 | YUE.on(YUD.get('branch_filter'),'change',function(e){ |
|
260 | 260 | var selected_branch = e.currentTarget.options[e.currentTarget.selectedIndex].value; |
|
261 | 261 | var url_main = "${h.url('changelog_home',repo_name=c.repo_name)}"; |
|
262 | 262 | var url = "${h.url('changelog_home',repo_name=c.repo_name,branch='__BRANCH__')}"; |
|
263 | 263 | var url = url.replace('__BRANCH__',selected_branch); |
|
264 | 264 | if(selected_branch != ''){ |
|
265 | 265 | window.location = url; |
|
266 | 266 | }else{ |
|
267 | 267 | window.location = url_main; |
|
268 | 268 | } |
|
269 | 269 | |
|
270 | 270 | }); |
|
271 | 271 | |
|
272 | 272 | function set_canvas(width) { |
|
273 | 273 | var c = document.getElementById('graph_nodes'); |
|
274 | 274 | var t = document.getElementById('graph_content'); |
|
275 | 275 | canvas = document.getElementById('graph_canvas'); |
|
276 | 276 | var div_h = t.clientHeight; |
|
277 | 277 | c.style.height=div_h+'px'; |
|
278 | 278 | canvas.setAttribute('height',div_h); |
|
279 | 279 | c.style.height=width+'px'; |
|
280 | 280 | canvas.setAttribute('width',width); |
|
281 | 281 | }; |
|
282 | 282 | var heads = 1; |
|
283 | 283 | var line_count = 0; |
|
284 | 284 | var jsdata = ${c.jsdata|n}; |
|
285 | 285 | |
|
286 | 286 | for (var i=0;i<jsdata.length;i++) { |
|
287 | 287 | var in_l = jsdata[i][2]; |
|
288 | 288 | for (var j in in_l) { |
|
289 | 289 | var m = in_l[j][1]; |
|
290 | 290 | if (m > line_count) |
|
291 | 291 | line_count = m; |
|
292 | 292 | } |
|
293 | 293 | } |
|
294 | 294 | set_canvas(100); |
|
295 | 295 | |
|
296 | 296 | var r = new BranchRenderer(); |
|
297 | 297 | r.render(jsdata,100,line_count); |
|
298 | 298 | |
|
299 | 299 | }); |
|
300 | 300 | </script> |
|
301 | 301 | %else: |
|
302 | 302 | ${_('There are no changes yet')} |
|
303 | 303 | %endif |
|
304 | 304 | </div> |
|
305 | 305 | </div> |
|
306 | 306 | </%def> |
@@ -1,43 +1,43 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | % if c.forks_pager: |
|
4 | 4 | % for f in c.forks_pager: |
|
5 | 5 | <div> |
|
6 | 6 | <div class="fork_user"> |
|
7 | 7 | <div class="gravatar"> |
|
8 | 8 | <img alt="gravatar" src="${h.gravatar_url(f.user.email,24)}"/> |
|
9 | 9 | </div> |
|
10 | 10 | <span style="font-size: 20px"> |
|
11 | 11 | <b>${f.user.username}</b> (${f.user.name} ${f.user.lastname}) / |
|
12 | 12 | ${h.link_to(f.repo_name,h.url('summary_home',repo_name=f.repo_name))} |
|
13 | 13 | </span> |
|
14 | 14 | <div style="padding:5px 3px 3px 42px;">${f.description}</div> |
|
15 | 15 | </div> |
|
16 | 16 | <div style="clear:both;padding-top: 10px"></div> |
|
17 | 17 | <div class="follower_date">${_('forked')} - |
|
18 | 18 | <span class="tooltip" title="${h.tooltip(h.fmt_date(f.created_on))}"> ${h.age(f.created_on)}</span> |
|
19 | 19 | <a title="${_('compare fork with %s' % c.repo_name)}" |
|
20 |
href="${h.url('compare_url',repo_name=f.repo_name,org_ref_type='branch',org_ref='default',other_ref_type='branch',other_ref='default' |
|
|
20 | href="${h.url('compare_url',repo_name=f.repo_name,org_ref_type='branch',org_ref='default',other_repo=c.repo_name,other_ref_type='branch',other_ref='default')}" | |
|
21 | 21 | class="ui-btn small">${_('Compare fork')}</a> |
|
22 | 22 | </div> |
|
23 | 23 | <div style="border-bottom: 1px solid #DDD;margin:10px 0px 10px 0px"></div> |
|
24 | 24 | </div> |
|
25 | 25 | % endfor |
|
26 | 26 | <div class="pagination-wh pagination-left"> |
|
27 | 27 | <script type="text/javascript"> |
|
28 | 28 | YUE.onDOMReady(function(){ |
|
29 | 29 | YUE.delegate("forks","click",function(e, matchedEl, container){ |
|
30 | 30 | ypjax(e.target.href,"forks",function(){ |
|
31 | 31 | show_more_event(); |
|
32 | 32 | tooltip_activate(); |
|
33 | 33 | show_changeset_tooltip(); |
|
34 | 34 | }); |
|
35 | 35 | YUE.preventDefault(e); |
|
36 | 36 | },'.pager_link'); |
|
37 | 37 | }); |
|
38 | 38 | </script> |
|
39 | 39 | ${c.forks_pager.pager('$link_previous ~2~ $link_next')} |
|
40 | 40 | </div> |
|
41 | 41 | % else: |
|
42 | 42 | ${_('There are no forks yet')} |
|
43 | 43 | % endif |
@@ -1,204 +1,204 b'' | |||
|
1 | 1 | <%inherit file="/base/base.html"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${c.repo_name} ${_('New pull request')} |
|
5 | 5 | </%def> |
|
6 | 6 | |
|
7 | 7 | <%def name="breadcrumbs_links()"> |
|
8 | 8 | ${h.link_to(_(u'Home'),h.url('/'))} |
|
9 | 9 | » |
|
10 | 10 | ${h.link_to(c.repo_name,h.url('changelog_home',repo_name=c.repo_name))} |
|
11 | 11 | » |
|
12 | 12 | ${_('New pull request')} |
|
13 | 13 | </%def> |
|
14 | 14 | |
|
15 | 15 | <%def name="main()"> |
|
16 | 16 | |
|
17 | 17 | <div class="box"> |
|
18 | 18 | <!-- box / title --> |
|
19 | 19 | <div class="title"> |
|
20 | 20 | ${self.breadcrumbs()} |
|
21 | 21 | </div> |
|
22 | 22 | ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')} |
|
23 | 23 | <div style="float:left;padding:0px 30px 30px 30px"> |
|
24 | 24 | <input type="hidden" name="rev_start" value="${request.GET.get('rev_start')}" /> |
|
25 | 25 | <input type="hidden" name="rev_end" value="${request.GET.get('rev_end')}" /> |
|
26 | 26 | |
|
27 | 27 | ##ORG |
|
28 | 28 | <div style="float:left"> |
|
29 | 29 | <div class="fork_user"> |
|
30 | 30 | <div class="gravatar"> |
|
31 | 31 | <img alt="gravatar" src="${h.gravatar_url(c.rhodecode_db_repo.user.email,24)}"/> |
|
32 | 32 | </div> |
|
33 | 33 | <span style="font-size: 20px"> |
|
34 | 34 | ${h.select('org_repo','',c.org_repos,class_='refs')}:${h.select('org_ref','',c.org_refs,class_='refs')} |
|
35 | 35 | </span> |
|
36 | 36 | <div style="padding:5px 3px 3px 42px;">${c.rhodecode_db_repo.description}</div> |
|
37 | 37 | </div> |
|
38 | 38 | <div style="clear:both;padding-top: 10px"></div> |
|
39 | 39 | </div> |
|
40 | 40 | <div style="float:left;font-size:24px;padding:0px 20px"> |
|
41 | 41 | <img height=32 width=32 src="${h.url('/images/arrow_right_64.png')}"/> |
|
42 | 42 | </div> |
|
43 | 43 | |
|
44 | 44 | ##OTHER, most Probably the PARENT OF THIS FORK |
|
45 | 45 | <div style="float:left"> |
|
46 | 46 | <div class="fork_user"> |
|
47 | 47 | <div class="gravatar"> |
|
48 | 48 | <img id="other_repo_gravatar" alt="gravatar" src=""/> |
|
49 | 49 | </div> |
|
50 | 50 | <span style="font-size: 20px"> |
|
51 | 51 | ${h.select('other_repo',c.default_pull_request ,c.other_repos,class_='refs')}:${h.select('other_ref',c.default_pull_request_rev,c.default_revs,class_='refs')} |
|
52 | 52 | </span> |
|
53 | 53 | <span style="padding:3px"> |
|
54 | 54 | <a id="refresh" href="#" class="tooltip" title="${h.tooltip(_('refresh overview'))}"> |
|
55 | 55 | <img style="margin:3px" class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/> |
|
56 | 56 | </a> |
|
57 | 57 | </span> |
|
58 | 58 | <div id="other_repo_desc" style="padding:5px 3px 3px 42px;"></div> |
|
59 | 59 | </div> |
|
60 | 60 | <div style="clear:both;padding-top: 10px"></div> |
|
61 | 61 | </div> |
|
62 | 62 | <div style="clear:both;padding-top: 10px"></div> |
|
63 | 63 | ## overview pulled by ajax |
|
64 | 64 | <div style="float:left" id="pull_request_overview"></div> |
|
65 | 65 | <div style="float:left;clear:both;padding:10px 10px 10px 0px;display:none"> |
|
66 | 66 | <a id="pull_request_overview_url" href="#">${_('Detailed compare view')}</a> |
|
67 | 67 | </div> |
|
68 | 68 | </div> |
|
69 | 69 | <div style="float:left; border-left:1px dashed #eee"> |
|
70 | 70 | <h4>${_('Pull request reviewers')}</h4> |
|
71 | 71 | <div id="reviewers" style="padding:0px 0px 0px 15px"> |
|
72 | 72 | ## members goes here ! |
|
73 | 73 | <div class="group_members_wrap"> |
|
74 | 74 | <ul id="review_members" class="group_members"> |
|
75 | 75 | %for member in c.review_members: |
|
76 | 76 | <li id="reviewer_${member.user_id}"> |
|
77 | 77 | <div class="reviewers_member"> |
|
78 | 78 | <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div> |
|
79 | 79 | <div style="float:left">${member.full_name} (${_('owner')})</div> |
|
80 | 80 | <input type="hidden" value="${member.user_id}" name="review_members" /> |
|
81 | 81 | <span class="delete_icon action_button" onclick="removeReviewer(${member.user_id})"></span> |
|
82 | 82 | </div> |
|
83 | 83 | </li> |
|
84 | 84 | %endfor |
|
85 | 85 | </ul> |
|
86 | 86 | </div> |
|
87 | 87 | |
|
88 | 88 | <div class='ac'> |
|
89 | 89 | <div class="reviewer_ac"> |
|
90 | 90 | ${h.text('user', class_='yui-ac-input')} |
|
91 | 91 | <span class="help-block">${_('Add reviewer to this pull request.')}</span> |
|
92 | 92 | <div id="reviewers_container"></div> |
|
93 | 93 | </div> |
|
94 | 94 | </div> |
|
95 | 95 | </div> |
|
96 | 96 | </div> |
|
97 | 97 | <h3>${_('Create new pull request')}</h3> |
|
98 | 98 | |
|
99 | 99 | <div class="form"> |
|
100 | 100 | <!-- fields --> |
|
101 | 101 | |
|
102 | 102 | <div class="fields"> |
|
103 | 103 | |
|
104 | 104 | <div class="field"> |
|
105 | 105 | <div class="label"> |
|
106 | 106 | <label for="pullrequest_title">${_('Title')}:</label> |
|
107 | 107 | </div> |
|
108 | 108 | <div class="input"> |
|
109 | 109 | ${h.text('pullrequest_title',size=30)} |
|
110 | 110 | </div> |
|
111 | 111 | </div> |
|
112 | 112 | |
|
113 | 113 | <div class="field"> |
|
114 | 114 | <div class="label label-textarea"> |
|
115 | 115 | <label for="pullrequest_desc">${_('description')}:</label> |
|
116 | 116 | </div> |
|
117 | 117 | <div class="textarea text-area editor"> |
|
118 | 118 | ${h.textarea('pullrequest_desc',size=30)} |
|
119 | 119 | </div> |
|
120 | 120 | </div> |
|
121 | 121 | |
|
122 | 122 | <div class="buttons"> |
|
123 | 123 | ${h.submit('save',_('Send pull request'),class_="ui-btn large")} |
|
124 | 124 | ${h.reset('reset',_('Reset'),class_="ui-btn large")} |
|
125 | 125 | </div> |
|
126 | 126 | </div> |
|
127 | 127 | </div> |
|
128 | 128 | ${h.end_form()} |
|
129 | 129 | |
|
130 | 130 | </div> |
|
131 | 131 | |
|
132 | 132 | <script type="text/javascript"> |
|
133 | 133 | var _USERS_AC_DATA = ${c.users_array|n}; |
|
134 | 134 | var _GROUPS_AC_DATA = ${c.users_groups_array|n}; |
|
135 | 135 | PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA); |
|
136 | 136 | |
|
137 | 137 | var other_repos_info = ${c.other_repos_info|n}; |
|
138 | 138 | |
|
139 | 139 | var loadPreview = function(){ |
|
140 | 140 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none'); |
|
141 | 141 | var url = "${h.url('compare_url', |
|
142 | 142 | repo_name='org_repo', |
|
143 | 143 | org_ref_type='org_ref_type', org_ref='org_ref', |
|
144 | other_repo='other_repo', | |
|
144 | 145 | other_ref_type='other_ref_type', other_ref='other_ref', |
|
145 | repo='other_repo', | |
|
146 | 146 | as_form=True, |
|
147 | 147 | rev_start=request.GET.get('rev_start',''), |
|
148 | 148 | rev_end=request.GET.get('rev_end',''))}"; |
|
149 | 149 | |
|
150 | 150 | var select_refs = YUQ('#pull_request_form select.refs') |
|
151 | 151 | var rev_data = {}; // gather the org/other ref and repo here |
|
152 | 152 | for(var i=0;i<select_refs.length;i++){ |
|
153 | 153 | var select_ref = select_refs[i]; |
|
154 | 154 | var select_ref_data = select_ref.value.split(':'); |
|
155 | 155 | var key = null; |
|
156 | 156 | var val = null; |
|
157 | 157 | |
|
158 | 158 | if(select_ref_data.length>1){ |
|
159 | 159 | key = select_ref.name+"_type"; |
|
160 | 160 | val = select_ref_data[0]; |
|
161 | 161 | url = url.replace(key,val); |
|
162 | 162 | rev_data[key] = val; |
|
163 | 163 | |
|
164 | 164 | key = select_ref.name; |
|
165 | 165 | val = select_ref_data[1]; |
|
166 | 166 | url = url.replace(key,val); |
|
167 | 167 | rev_data[key] = val; |
|
168 | 168 | |
|
169 | 169 | }else{ |
|
170 | 170 | key = select_ref.name; |
|
171 | 171 | val = select_ref.value; |
|
172 | 172 | url = url.replace(key,val); |
|
173 | 173 | rev_data[key] = val; |
|
174 | 174 | } |
|
175 | 175 | } |
|
176 | 176 | |
|
177 | 177 | YUE.on('other_repo', 'change', function(e){ |
|
178 | 178 | var repo_name = e.currentTarget.value; |
|
179 | 179 | // replace the <select> of changed repo |
|
180 | 180 | YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; |
|
181 | 181 | }); |
|
182 | 182 | |
|
183 | 183 | ypjax(url,'pull_request_overview', function(data){ |
|
184 | 184 | var sel_box = YUQ('#pull_request_form #other_repo')[0]; |
|
185 | 185 | var repo_name = sel_box.options[sel_box.selectedIndex].value; |
|
186 | 186 | YUD.get('pull_request_overview_url').href = url; |
|
187 | 187 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display',''); |
|
188 | 188 | YUD.get('other_repo_gravatar').src = other_repos_info[repo_name]['gravatar']; |
|
189 | 189 | YUD.get('other_repo_desc').innerHTML = other_repos_info[repo_name]['description']; |
|
190 | 190 | YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; |
|
191 | 191 | // select back the revision that was just compared |
|
192 | 192 | setSelectValue(YUD.get('other_ref'), rev_data['other_ref']); |
|
193 | 193 | }) |
|
194 | 194 | } |
|
195 | 195 | YUE.on('refresh','click',function(e){ |
|
196 | 196 | loadPreview() |
|
197 | 197 | }) |
|
198 | 198 | |
|
199 | 199 | //lazy load overview after 0.5s |
|
200 | 200 | setTimeout(loadPreview, 500) |
|
201 | 201 | |
|
202 | 202 | </script> |
|
203 | 203 | |
|
204 | 204 | </%def> |
@@ -1,347 +1,347 b'' | |||
|
1 | 1 | from rhodecode.tests import * |
|
2 | 2 | from rhodecode.model.repo import RepoModel |
|
3 | 3 | from rhodecode.model.meta import Session |
|
4 | 4 | from rhodecode.model.db import Repository |
|
5 | 5 | from rhodecode.model.scm import ScmModel |
|
6 | 6 | from rhodecode.lib.vcs.backends.base import EmptyChangeset |
|
7 | 7 | |
|
8 | 8 | |
|
9 | 9 | def _fork_repo(fork_name, vcs_type, parent=None): |
|
10 | 10 | if vcs_type =='hg': |
|
11 | 11 | _REPO = HG_REPO |
|
12 | 12 | elif vcs_type == 'git': |
|
13 | 13 | _REPO = GIT_REPO |
|
14 | 14 | |
|
15 | 15 | if parent: |
|
16 | 16 | _REPO = parent |
|
17 | 17 | |
|
18 | 18 | form_data = dict( |
|
19 | 19 | repo_name=fork_name, |
|
20 | 20 | repo_name_full=fork_name, |
|
21 | 21 | repo_group=None, |
|
22 | 22 | repo_type=vcs_type, |
|
23 | 23 | description='', |
|
24 | 24 | private=False, |
|
25 | 25 | copy_permissions=False, |
|
26 | 26 | landing_rev='tip', |
|
27 | 27 | update_after_clone=False, |
|
28 | 28 | fork_parent_id=Repository.get_by_repo_name(_REPO), |
|
29 | 29 | ) |
|
30 | 30 | repo = RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) |
|
31 | 31 | |
|
32 | 32 | Session().commit() |
|
33 | 33 | return Repository.get_by_repo_name(fork_name) |
|
34 | 34 | |
|
35 | 35 | |
|
36 | 36 | def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False): |
|
37 | 37 | repo = Repository.get_by_repo_name(repo) |
|
38 | 38 | _cs = parent |
|
39 | 39 | if not parent: |
|
40 | 40 | _cs = EmptyChangeset(alias=vcs_type) |
|
41 | 41 | |
|
42 | 42 | if newfile: |
|
43 | 43 | cs = ScmModel().create_node( |
|
44 | 44 | repo=repo.scm_instance, repo_name=repo.repo_name, |
|
45 | 45 | cs=_cs, user=TEST_USER_ADMIN_LOGIN, |
|
46 | 46 | author=TEST_USER_ADMIN_LOGIN, |
|
47 | 47 | message=message, |
|
48 | 48 | content=content, |
|
49 | 49 | f_path=filename |
|
50 | 50 | ) |
|
51 | 51 | else: |
|
52 | 52 | cs = ScmModel().commit_change( |
|
53 | 53 | repo=repo.scm_instance, repo_name=repo.repo_name, |
|
54 | 54 | cs=parent, user=TEST_USER_ADMIN_LOGIN, |
|
55 | 55 | author=TEST_USER_ADMIN_LOGIN, |
|
56 | 56 | message=message, |
|
57 | 57 | content=content, |
|
58 | 58 | f_path=filename |
|
59 | 59 | ) |
|
60 | 60 | return cs |
|
61 | 61 | |
|
62 | 62 | |
|
63 | 63 | class TestCompareController(TestController): |
|
64 | 64 | |
|
65 | 65 | def test_compare_forks_on_branch_extra_commits_hg(self): |
|
66 | 66 | self.log_user() |
|
67 | 67 | |
|
68 | 68 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', |
|
69 | 69 | description='diff-test', |
|
70 | 70 | owner=TEST_USER_ADMIN_LOGIN) |
|
71 | 71 | r1_id = repo1.repo_id |
|
72 | 72 | Session().commit() |
|
73 | 73 | #commit something ! |
|
74 | 74 | cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
|
75 | 75 | message='commit1', vcs_type='hg', parent=None, newfile=True) |
|
76 | 76 | |
|
77 | 77 | #fork this repo |
|
78 | 78 | repo2 = _fork_repo('one-fork', 'hg', parent='one') |
|
79 | 79 | Session().commit() |
|
80 | 80 | r2_id = repo2.repo_id |
|
81 | 81 | |
|
82 | 82 | #add two extra commit into fork |
|
83 | 83 | cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', |
|
84 | 84 | message='commit2', vcs_type='hg', parent=cs0) |
|
85 | 85 | |
|
86 | 86 | cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n', |
|
87 | 87 | message='commit3', vcs_type='hg', parent=cs1) |
|
88 | 88 | |
|
89 | 89 | rev1 = 'default' |
|
90 | 90 | rev2 = 'default' |
|
91 | 91 | response = self.app.get(url(controller='compare', action='index', |
|
92 | 92 | repo_name=repo2.repo_name, |
|
93 | 93 | org_ref_type="branch", |
|
94 | 94 | org_ref=rev1, |
|
95 | other_repo=repo1.repo_name, | |
|
95 | 96 | other_ref_type="branch", |
|
96 | 97 | other_ref=rev2, |
|
97 | repo=repo1.repo_name | |
|
98 | 98 | )) |
|
99 | 99 | |
|
100 | 100 | try: |
|
101 | 101 | response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2)) |
|
102 | 102 | response.mustcontain("""Showing 2 commits""") |
|
103 | 103 | response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") |
|
104 | 104 | |
|
105 | 105 | response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""") |
|
106 | 106 | response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""") |
|
107 | 107 | |
|
108 | 108 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) |
|
109 | 109 | response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) |
|
110 | 110 | ## files |
|
111 | 111 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2)) |
|
112 | 112 | |
|
113 | 113 | finally: |
|
114 | 114 | RepoModel().delete(r2_id) |
|
115 | 115 | RepoModel().delete(r1_id) |
|
116 | 116 | |
|
117 | 117 | |
|
118 | 118 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self): |
|
119 | 119 | self.log_user() |
|
120 | 120 | |
|
121 | 121 | repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', |
|
122 | 122 | description='diff-test', |
|
123 | 123 | owner=TEST_USER_ADMIN_LOGIN) |
|
124 | 124 | r1_id = repo1.repo_id |
|
125 | 125 | Session().commit() |
|
126 | 126 | #commit something ! |
|
127 | 127 | cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
|
128 | 128 | message='commit1', vcs_type='hg', parent=None, newfile=True) |
|
129 | 129 | |
|
130 | 130 | #fork this repo |
|
131 | 131 | repo2 = _fork_repo('one-fork', 'hg', parent='one') |
|
132 | 132 | Session().commit() |
|
133 | 133 | |
|
134 | 134 | #now commit something to origin repo |
|
135 | 135 | cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n', |
|
136 | 136 | message='commit2', vcs_type='hg', parent=cs0, newfile=True) |
|
137 | 137 | |
|
138 | 138 | r2_id = repo2.repo_id |
|
139 | 139 | |
|
140 | 140 | #add two extra commit into fork |
|
141 | 141 | cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', |
|
142 | 142 | message='commit2', vcs_type='hg', parent=cs0) |
|
143 | 143 | |
|
144 | 144 | cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n', |
|
145 | 145 | message='commit3', vcs_type='hg', parent=cs1) |
|
146 | 146 | |
|
147 | 147 | rev1 = 'default' |
|
148 | 148 | rev2 = 'default' |
|
149 | 149 | response = self.app.get(url(controller='compare', action='index', |
|
150 | 150 | repo_name=repo2.repo_name, |
|
151 | 151 | org_ref_type="branch", |
|
152 | 152 | org_ref=rev1, |
|
153 | other_repo=repo1.repo_name, | |
|
153 | 154 | other_ref_type="branch", |
|
154 | 155 | other_ref=rev2, |
|
155 | repo=repo1.repo_name | |
|
156 | 156 | )) |
|
157 | 157 | |
|
158 | 158 | try: |
|
159 | 159 | response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2)) |
|
160 | 160 | response.mustcontain("""Showing 2 commits""") |
|
161 | 161 | response.mustcontain("""1 file changed with 2 insertions and 0 deletions""") |
|
162 | 162 | |
|
163 | 163 | response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""") |
|
164 | 164 | response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""") |
|
165 | 165 | |
|
166 | 166 | response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id)) |
|
167 | 167 | response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id)) |
|
168 | 168 | ## files |
|
169 | 169 | response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2)) |
|
170 | 170 | |
|
171 | 171 | finally: |
|
172 | 172 | RepoModel().delete(r2_id) |
|
173 | 173 | RepoModel().delete(r1_id) |
|
174 | 174 | |
|
175 | 175 | |
|
176 | 176 | # def test_compare_remote_repos_remote_flag_off(self): |
|
177 | 177 | # self.log_user() |
|
178 | 178 | # _fork_repo(HG_FORK, 'hg') |
|
179 | 179 | # |
|
180 | 180 | # rev1 = '56349e29c2af' |
|
181 | 181 | # rev2 = '7d4bc8ec6be5' |
|
182 | 182 | # |
|
183 | 183 | # response = self.app.get(url(controller='compare', action='index', |
|
184 | 184 | # repo_name=HG_REPO, |
|
185 | 185 | # org_ref_type="rev", |
|
186 | 186 | # org_ref=rev1, |
|
187 | 187 | # other_ref_type="rev", |
|
188 | 188 | # other_ref=rev2, |
|
189 | 189 | # repo=HG_FORK, |
|
190 | 190 | # bundle=False, |
|
191 | 191 | # )) |
|
192 | 192 | # |
|
193 | 193 | # try: |
|
194 | 194 | # response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) |
|
195 | 195 | # ## outgoing changesets between those revisions |
|
196 | 196 | # |
|
197 | 197 | # response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) |
|
198 | 198 | # response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO)) |
|
199 | 199 | # response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2)) |
|
200 | 200 | # |
|
201 | 201 | # ## files |
|
202 | 202 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2)) |
|
203 | 203 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2)) |
|
204 | 204 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2)) |
|
205 | 205 | # finally: |
|
206 | 206 | # RepoModel().delete(HG_FORK) |
|
207 | 207 | |
|
208 | 208 | |
|
209 | 209 | |
|
210 | 210 | # |
|
211 | 211 | # def test_compare_remote_branches_hg(self): |
|
212 | 212 | # self.log_user() |
|
213 | 213 | # |
|
214 | 214 | # _fork_repo(HG_FORK, 'hg') |
|
215 | 215 | # |
|
216 | 216 | # rev1 = '56349e29c2af' |
|
217 | 217 | # rev2 = '7d4bc8ec6be5' |
|
218 | 218 | # |
|
219 | 219 | # response = self.app.get(url(controller='compare', action='index', |
|
220 | 220 | # repo_name=HG_REPO, |
|
221 | 221 | # org_ref_type="rev", |
|
222 | 222 | # org_ref=rev1, |
|
223 | 223 | # other_ref_type="rev", |
|
224 | 224 | # other_ref=rev2, |
|
225 | 225 | # repo=HG_FORK, |
|
226 | 226 | # )) |
|
227 | 227 | # |
|
228 | 228 | # try: |
|
229 | 229 | # response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) |
|
230 | 230 | # ## outgoing changesets between those revisions |
|
231 | 231 | # |
|
232 | 232 | # response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO)) |
|
233 | 233 | # response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO)) |
|
234 | 234 | # response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2)) |
|
235 | 235 | # |
|
236 | 236 | # ## files |
|
237 | 237 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2)) |
|
238 | 238 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2)) |
|
239 | 239 | # response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2)) |
|
240 | 240 | # finally: |
|
241 | 241 | # RepoModel().delete(HG_FORK) |
|
242 | 242 | # |
|
243 | 243 | # def test_org_repo_new_commits_after_forking_simple_diff(self): |
|
244 | 244 | # self.log_user() |
|
245 | 245 | # |
|
246 | 246 | # repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg', |
|
247 | 247 | # description='diff-test', |
|
248 | 248 | # owner=TEST_USER_ADMIN_LOGIN) |
|
249 | 249 | # |
|
250 | 250 | # Session().commit() |
|
251 | 251 | # r1_id = repo1.repo_id |
|
252 | 252 | # r1_name = repo1.repo_name |
|
253 | 253 | # |
|
254 | 254 | # #commit something initially ! |
|
255 | 255 | # cs0 = ScmModel().create_node( |
|
256 | 256 | # repo=repo1.scm_instance, repo_name=r1_name, |
|
257 | 257 | # cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
258 | 258 | # author=TEST_USER_ADMIN_LOGIN, |
|
259 | 259 | # message='commit1', |
|
260 | 260 | # content='line1', |
|
261 | 261 | # f_path='file1' |
|
262 | 262 | # ) |
|
263 | 263 | # Session().commit() |
|
264 | 264 | # self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id]) |
|
265 | 265 | # #fork the repo1 |
|
266 | 266 | # repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg', |
|
267 | 267 | # description='compare-test', |
|
268 | 268 | # clone_uri=repo1.repo_full_path, |
|
269 | 269 | # owner=TEST_USER_ADMIN_LOGIN, fork_of='one') |
|
270 | 270 | # Session().commit() |
|
271 | 271 | # self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id]) |
|
272 | 272 | # r2_id = repo2.repo_id |
|
273 | 273 | # r2_name = repo2.repo_name |
|
274 | 274 | # |
|
275 | 275 | # #make 3 new commits in fork |
|
276 | 276 | # cs1 = ScmModel().create_node( |
|
277 | 277 | # repo=repo2.scm_instance, repo_name=r2_name, |
|
278 | 278 | # cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN, |
|
279 | 279 | # author=TEST_USER_ADMIN_LOGIN, |
|
280 | 280 | # message='commit1-fork', |
|
281 | 281 | # content='file1-line1-from-fork', |
|
282 | 282 | # f_path='file1-fork' |
|
283 | 283 | # ) |
|
284 | 284 | # cs2 = ScmModel().create_node( |
|
285 | 285 | # repo=repo2.scm_instance, repo_name=r2_name, |
|
286 | 286 | # cs=cs1, user=TEST_USER_ADMIN_LOGIN, |
|
287 | 287 | # author=TEST_USER_ADMIN_LOGIN, |
|
288 | 288 | # message='commit2-fork', |
|
289 | 289 | # content='file2-line1-from-fork', |
|
290 | 290 | # f_path='file2-fork' |
|
291 | 291 | # ) |
|
292 | 292 | # cs3 = ScmModel().create_node( |
|
293 | 293 | # repo=repo2.scm_instance, repo_name=r2_name, |
|
294 | 294 | # cs=cs2, user=TEST_USER_ADMIN_LOGIN, |
|
295 | 295 | # author=TEST_USER_ADMIN_LOGIN, |
|
296 | 296 | # message='commit3-fork', |
|
297 | 297 | # content='file3-line1-from-fork', |
|
298 | 298 | # f_path='file3-fork' |
|
299 | 299 | # ) |
|
300 | 300 | # |
|
301 | 301 | # #compare ! |
|
302 | 302 | # rev1 = 'default' |
|
303 | 303 | # rev2 = 'default' |
|
304 | 304 | # response = self.app.get(url(controller='compare', action='index', |
|
305 | 305 | # repo_name=r2_name, |
|
306 | 306 | # org_ref_type="branch", |
|
307 | 307 | # org_ref=rev1, |
|
308 | 308 | # other_ref_type="branch", |
|
309 | 309 | # other_ref=rev2, |
|
310 | 310 | # repo=r1_name, |
|
311 | 311 | # bundle=False, |
|
312 | 312 | # )) |
|
313 | 313 | # |
|
314 | 314 | # try: |
|
315 | 315 | # #response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
316 | 316 | # |
|
317 | 317 | # #add new commit into parent ! |
|
318 | 318 | # cs0 = ScmModel().create_node( |
|
319 | 319 | # repo=repo1.scm_instance, repo_name=r1_name, |
|
320 | 320 | # cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, |
|
321 | 321 | # author=TEST_USER_ADMIN_LOGIN, |
|
322 | 322 | # message='commit2', |
|
323 | 323 | # content='line1', |
|
324 | 324 | # f_path='file2' |
|
325 | 325 | # ) |
|
326 | 326 | # #compare ! |
|
327 | 327 | # rev1 = 'default' |
|
328 | 328 | # rev2 = 'default' |
|
329 | 329 | # response = self.app.get(url(controller='compare', action='index', |
|
330 | 330 | # repo_name=r2_name, |
|
331 | 331 | # org_ref_type="branch", |
|
332 | 332 | # org_ref=rev1, |
|
333 | 333 | # other_ref_type="branch", |
|
334 | 334 | # other_ref=rev2, |
|
335 | 335 | # repo=r1_name, |
|
336 | 336 | # bundle=False |
|
337 | 337 | # )) |
|
338 | 338 | # |
|
339 | 339 | # response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) |
|
340 | 340 | # response.mustcontain("""file1-line1-from-fork""") |
|
341 | 341 | # response.mustcontain("""file2-line1-from-fork""") |
|
342 | 342 | # response.mustcontain("""file3-line1-from-fork""") |
|
343 | 343 | # self.assertFalse("""<a href="#">file2</a>""" in response.body) # new commit from parent |
|
344 | 344 | # self.assertFalse("""line1-from-new-parent""" in response.body) |
|
345 | 345 | # finally: |
|
346 | 346 | # RepoModel().delete(r2_id) |
|
347 | 347 | # RepoModel().delete(r1_id) |
General Comments 0
You need to be logged in to leave comments.
Login now