##// END OF EJS Templates
pullrequests: use shared changelog_table implementation...
Mads Kiilerich -
r6775:00905ed0 default
parent child Browse files
Show More
@@ -1,120 +1,137 b''
1 1 ## Render changelog table with id 'changesets' with the range of changesets,
2 2 ## statuses, and comments.
3 3 ## Optionally, pass a js snippet to run whenever a table resize is triggered.
4 <%def name="changelog(repo_name, cs_range, cs_statuses, cs_comments, show_checkbox=False, show_branch=True, resize_js='')">
4 <%def name="changelog(repo_name, cs_range, cs_statuses, cs_comments, show_checkbox=False, show_branch=True, show_index=False, resize_js='')">
5 <% num_cs = len(cs_range) %>
5 6 <table class="table" id="changesets">
6 7 <tbody>
7 8 %for cnt,cs in enumerate(cs_range):
8 9 <tr id="chg_${cnt+1}" class="${'mergerow' if len(cs.parents) > 1 else ''}">
9 10 %if show_checkbox:
10 11 <td class="checkbox-column">
11 12 ${h.checkbox(cs.raw_id,class_="changeset_range")}
12 13 </td>
13 14 %endif
15 %if show_index:
16 <td class="changeset-logical-index">
17 <%
18 index = num_cs - cnt
19 if index == 1:
20 title = _('First (oldest) changeset in this list')
21 elif index == num_cs:
22 title = _('Last (most recent) changeset in this list')
23 else:
24 title = _('Position in this list of changesets')
25 %>
26 <span data-toggle="tooltip" title="${title}">
27 ${index}
28 </span>
29 </td>
30 %endif
14 31 <td class="status">
15 32 %if cs_statuses.get(cs.raw_id):
16 33 %if cs_statuses.get(cs.raw_id)[2]:
17 34 <a data-toggle="tooltip"
18 35 title="${_('Changeset status: %s by %s\nClick to open associated pull request %s') % (cs_statuses.get(cs.raw_id)[1], cs_statuses.get(cs.raw_id)[5].username, cs_statuses.get(cs.raw_id)[4])}"
19 36 href="${h.url('pullrequest_show',repo_name=cs_statuses.get(cs.raw_id)[3],pull_request_id=cs_statuses.get(cs.raw_id)[2])}">
20 37 <i class="icon-circle changeset-status-${cs_statuses.get(cs.raw_id)[0]}"></i>
21 38 </a>
22 39 %else:
23 40 <a data-toggle="tooltip"
24 41 title="${_('Changeset status: %s by %s') % (cs_statuses.get(cs.raw_id)[1], cs_statuses.get(cs.raw_id)[5].username)}"
25 42 href="${cs_comments[cs.raw_id][0].url()}">
26 43 <i class="icon-circle changeset-status-${cs_statuses.get(cs.raw_id)[0]}"></i>
27 44 </a>
28 45 %endif
29 46 %endif
30 47 </td>
31 48 <td class="author" data-toggle="tooltip" title="${cs.author}">
32 49 ${h.gravatar(h.email_or_none(cs.author), size=16)}
33 50 <span class="user">${h.person(cs.author)}</span>
34 51 </td>
35 52 <td class="hash">
36 53 ${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id), class_='changeset_hash')}
37 54 </td>
38 55 <td class="date">
39 56 <div data-toggle="tooltip" title="${h.fmt_date(cs.date)}">${h.age(cs.date,True)}</div>
40 57 </td>
41 58 <% message_lines = cs.message.splitlines() %>
42 59 %if len(message_lines) > 1:
43 60 <td class="expand_commit" title="${_('Expand commit message')}">
44 61 <i class="icon-align-left"></i>
45 62 </td>
46 63 %else:
47 64 <td></td>
48 65 %endif
49 66 <td class="mid">
50 67 <div class="log-container">
51 68 <div class="message">
52 69 <div class="message-firstline">${h.urlify_text(message_lines[0], c.repo_name,h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id))}</div>
53 70 %if len(message_lines) > 1:
54 71 <div class="message-full hidden">${h.urlify_text(cs.message, repo_name)}</div>
55 72 %endif
56 73 </div>
57 74 <div class="extra-container">
58 75 %if cs_comments.get(cs.raw_id):
59 76 <a class="comments-container comments-cnt" href="${cs_comments[cs.raw_id][0].url()}" data-toggle="tooltip" title="${_('%s comments') % len(cs_comments[cs.raw_id])}">
60 77 ${len(cs_comments[cs.raw_id])}
61 78 <i class="icon-comment-discussion"></i>
62 79 </a>
63 80 %endif
64 81 %if cs.bumped:
65 82 <span class="bumpedtag" title="Bumped">
66 83 Bumped
67 84 </span>
68 85 %endif
69 86 %if cs.divergent:
70 87 <span class="divergenttag" title="Divergent">
71 88 Divergent
72 89 </span>
73 90 %endif
74 91 %if cs.extinct:
75 92 <span class="extincttag" title="Extinct">
76 93 Extinct
77 94 </span>
78 95 %endif
79 96 %if cs.unstable:
80 97 <span class="unstabletag" title="Unstable">
81 98 Unstable
82 99 </span>
83 100 %endif
84 101 %if cs.phase:
85 102 <span class="phasetag" title="Phase">
86 103 ${cs.phase}
87 104 </span>
88 105 %endif
89 106 %for book in cs.bookmarks:
90 107 <span class="booktag" title="${_('Bookmark %s') % book}">
91 108 ${h.link_to(book,h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id))}
92 109 </span>
93 110 %endfor
94 111 %for tag in cs.tags:
95 112 <span class="tagtag" title="${_('Tag %s') % tag}">
96 113 ${h.link_to(tag,h.url('changeset_home',repo_name=repo_name,revision=cs.raw_id))}
97 114 </span>
98 115 %endfor
99 116 %if show_branch and cs.branch:
100 117 <span class="branchtag" title="${_('Branch %s' % cs.branch)}">
101 118 ${h.link_to(cs.branch,h.url('changelog_home',repo_name=repo_name,branch=cs.branch))}
102 119 </span>
103 120 %endif
104 121 </div>
105 122 </div>
106 123 </td>
107 124 </tr>
108 125 %endfor
109 126 </tbody>
110 127 </table>
111 128
112 129 <script type="text/javascript">
113 130 $(document).ready(function() {
114 131 $('#changesets .expand_commit').on('click',function(e){
115 132 $(this).next('.mid').find('.message > div').toggleClass('hidden');
116 133 ${resize_js};
117 134 });
118 135 });
119 136 </script>
120 137 </%def>
@@ -1,143 +1,85 b''
1 ## Changesets table !
1 ## Changesets table with graph
2 <%namespace name="changelog_table" file="/changelog/changelog_table.html"/>
2 3 <div>
3 4 %if not c.cs_ranges:
4 5 <span class="empty_data">${_('No changesets')}</span>
5 6 %else:
6 7
7 8 %if c.ancestors:
8 9 <div class="ancestor">
9 10 %if len(c.ancestors) > 1:
10 11 <div class="text-danger">
11 12 ${_('Criss cross merge situation with multiple merge ancestors detected!')}
12 13 </div>
13 14 <div>
14 15 ${_('Please merge the target branch to your branch before creating a pull request.')}
15 16 </div>
16 17 %endif
17 18 <div>
18 19 ${_('Merge Ancestor')}:
19 20 %for ancestor in c.ancestors:
20 21 ${h.link_to(h.short_id(ancestor),h.url('changeset_home',repo_name=c.repo_name,revision=ancestor), class_="changeset_hash")}
21 22 %endfor
22 23 </div>
23 24 </div>
24 25 %endif
25 26
26 27 <div id="graph_nodes">
27 28 <canvas id="graph_canvas"></canvas>
28 29 </div>
29 30
30 31 <div id="graph_content_pr">
31
32 <table class="table compare_view_commits">
33 %for cnt, cs in enumerate(reversed(c.cs_ranges)):
34 <tr id="chg_${cnt+1}" class="${'mergerow' if len(cs.parents) > 1 else ''}">
35 <td>
36 %if cs.raw_id in c.cs_statuses:
37 <i class="icon-circle changeset-status-${c.cs_statuses[cs.raw_id][0]}" title="${_('Changeset status: %s') % c.cs_statuses[cs.raw_id][1]}"></i>
38 %endif
39 %if c.cs_comments.get(cs.raw_id):
40 <div class="comments-container">
41 <div class="comments-cnt" title="${_('Changeset has comments')}">
42 <a href="${c.cs_comments[cs.raw_id][0].url()}">
43 ${len(c.cs_comments[cs.raw_id])}
44 <i class="icon-comment"></i>
45 </a>
46 </div>
47 </div>
48 %endif
49 </td>
50 <td class="changeset-logical-index">
51 <%
52 num_cs = len(c.cs_ranges)
53 index = num_cs - cnt
54 if index == 1:
55 title = _('First (oldest) changeset in this list')
56 elif index == num_cs:
57 title = _('Last (most recent) changeset in this list')
58 else:
59 title = _('Position in this list of changesets')
60 %>
61 <span data-toggle="tooltip" title="${title}">
62 ${index}
63 </span>
64 </td>
65 <td><span data-toggle="tooltip" title="${h.age(cs.date)}">${cs.date}</span></td>
66 <td class="author">
67 ${h.gravatar(h.email_or_none(cs.author), size=16)}
68 <span data-toggle="tooltip" title="${cs.author}" class="user">${h.person(cs.author)}</span>
69 </td>
70 <td>${h.link_to(h.show_id(cs),h.url('changeset_home',repo_name=c.cs_repo.repo_name,revision=cs.raw_id), class_='changeset_hash')}</td>
71 <td>
72 %if cs.branch:
73 <span class="branchtag">${h.link_to(cs.branch,h.url('changelog_home',repo_name=c.cs_repo.repo_name,branch=cs.branch))}</span>
74 %endif
75 </td>
76 <td class="expand_commit" title="${_('Expand commit message')}">
77 <i class="icon-align-left"></i>
78 </td>
79 <td class="mid">
80 <div class="pull-right">
81 %for tag in cs.tags:
82 <span class="tagtag" title="${_('Tag %s') % tag}">
83 ${h.link_to(tag,h.url('changeset_home',repo_name=c.repo_name,revision=cs.raw_id))}
84 </span>
85 %endfor
86 </div>
87 <div class="message">${h.urlify_text(cs.message, c.repo_name)}</div>
88 </td>
89 </tr>
90 %endfor
91 </table>
92
32 ${changelog_table.changelog(c.cs_repo.repo_name, list(reversed(c.cs_ranges)), c.cs_statuses, c.cs_comments,
33 show_index=True,
34 resize_js='graph.render(jsdata)')}
93 35 </div>
94 36
95 37 %if c.is_ajax_preview:
96 38 <h5>
97 39 ## links should perhaps use ('rev', c.a_rev) instead ...
98 40 ${h.link_to(_('Show merge diff'),
99 41 h.url('compare_url',
100 42 repo_name=c.a_repo.repo_name,
101 43 org_ref_type=c.a_ref_type, org_ref_name=c.a_ref_name,
102 44 other_repo=c.cs_repo.repo_name,
103 45 other_ref_type=c.cs_ref_type, other_ref_name=c.cs_ref_name,
104 46 merge='1')
105 47 )}
106 48 </h5>
107 49 %endif
108 50 %if c.cs_ranges_org is not None:
109 51 ## TODO: list actual changesets?
110 52 <div>
111 53 ${h.link_to_ref(c.cs_repo.repo_name, c.cs_ref_type, c.cs_ref_name, c.cs_rev)}
112 54 ${_('is')}
113 55 <a href="${c.swap_url}">${_('%s changesets') % (len(c.cs_ranges_org))}</a>
114 56 ${_('behind')}
115 57 ${h.link_to_ref(c.a_repo.repo_name, c.a_ref_type, c.a_ref_name)}
116 58 </div>
117 59 %endif
118 60 %endif
119 61 </div>
120 62
121 63 %if c.is_ajax_preview:
122 64 <div id="jsdata" style="display:none">${h.js(c.jsdata)}</div>
123 65 %else:
124 66 <script type="text/javascript" src="${h.url('/js/graph.js', ver=c.kallithea_version)}"></script>
125 67 %endif
126 68
127 69 <script type="text/javascript">
128 70 var jsdata = ${h.js(c.jsdata)};
129 71 var graph = new BranchRenderer('graph_canvas', 'graph_content_pr', 'chg_');
130 72
131 73 $(document).ready(function(){
132 74 graph.render(jsdata);
133 75
134 76 $('.expand_commit').click(function(e){
135 77 $(this).next('.mid').find('.message').toggleClass('expanded');
136 78 graph.render(jsdata);
137 79 });
138 80 });
139 81 $(window).resize(function(){
140 82 graph.render(jsdata);
141 83 });
142 84
143 85 </script>
@@ -1,595 +1,595 b''
1 1 # -*- coding: utf-8 -*-
2 2 from kallithea.tests.base import *
3 3 from kallithea.model.repo import RepoModel
4 4 from kallithea.model.meta import Session
5 5 from kallithea.tests.fixture import Fixture
6 6
7 7 fixture = Fixture()
8 8
9 def _commit_ref(sha, msg):
10 return '''<div class="message">%s</div>''' % msg
9 def _commit_ref(repo_name, sha, msg):
10 return '''<div class="message-firstline"><a class="message-link" href="/%s/changeset/%s">%s</a></div>''' % (repo_name, sha, msg)
11 11
12 12
13 13 class TestCompareController(TestController):
14 14
15 15 def setup_method(self, method):
16 16 self.r1_id = None
17 17 self.r2_id = None
18 18
19 19 def teardown_method(self, method):
20 20 if self.r2_id:
21 21 RepoModel().delete(self.r2_id)
22 22 if self.r1_id:
23 23 RepoModel().delete(self.r1_id)
24 24 Session().commit()
25 25 Session.remove()
26 26
27 27 def test_compare_forks_on_branch_extra_commits_hg(self):
28 28 self.log_user()
29 29 repo1 = fixture.create_repo(u'one', repo_type='hg',
30 30 repo_description='diff-test',
31 31 cur_user=TEST_USER_ADMIN_LOGIN)
32 32 self.r1_id = repo1.repo_id
33 33 #commit something !
34 34 cs0 = fixture.commit_change(repo1.repo_name, filename='file1',
35 35 content='line1\n', message='commit1', vcs_type='hg',
36 36 parent=None, newfile=True)
37 37
38 38 #fork this repo
39 39 repo2 = fixture.create_fork(u'one', u'one-fork')
40 40 self.r2_id = repo2.repo_id
41 41
42 42 #add two extra commit into fork
43 43 cs1 = fixture.commit_change(repo2.repo_name, filename='file1',
44 44 content='line1\nline2\n', message='commit2', vcs_type='hg',
45 45 parent=cs0)
46 46
47 47 cs2 = fixture.commit_change(repo2.repo_name, filename='file1',
48 48 content='line1\nline2\nline3\n', message='commit3',
49 49 vcs_type='hg', parent=cs1)
50 50
51 51 rev1 = 'default'
52 52 rev2 = 'default'
53 53
54 54 response = self.app.get(url('compare_url',
55 55 repo_name=repo1.repo_name,
56 56 org_ref_type="branch",
57 57 org_ref_name=rev2,
58 58 other_repo=repo2.repo_name,
59 59 other_ref_type="branch",
60 60 other_ref_name=rev1,
61 61 merge='1',))
62 62
63 63 response.mustcontain('%s@%s' % (repo1.repo_name, rev2))
64 64 response.mustcontain('%s@%s' % (repo2.repo_name, rev1))
65 65 response.mustcontain("""Showing 2 commits""")
66 66 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
67 67
68 response.mustcontain(_commit_ref(cs1.raw_id, 'commit2'))
69 response.mustcontain(_commit_ref(cs2.raw_id, 'commit3'))
68 response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2'))
69 response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3'))
70 70
71 71 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
72 72 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
73 73 ## files
74 74 response.mustcontain("""<a href="#C--826e8142e6ba">file1</a>""")
75 75 #swap
76 76 response.mustcontain("""<a class="btn btn-default btn-sm" href="/%s/compare/branch@%s...branch@%s?other_repo=%s&amp;merge=True"><i class="icon-arrows-cw"></i> Swap</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
77 77
78 78 def test_compare_forks_on_branch_extra_commits_git(self):
79 79 self.log_user()
80 80 repo1 = fixture.create_repo(u'one-git', repo_type='git',
81 81 repo_description='diff-test',
82 82 cur_user=TEST_USER_ADMIN_LOGIN)
83 83 self.r1_id = repo1.repo_id
84 84 #commit something !
85 85 cs0 = fixture.commit_change(repo1.repo_name, filename='file1',
86 86 content='line1\n', message='commit1', vcs_type='git',
87 87 parent=None, newfile=True)
88 88
89 89 #fork this repo
90 90 repo2 = fixture.create_fork(u'one-git', u'one-git-fork')
91 91 self.r2_id = repo2.repo_id
92 92
93 93 #add two extra commit into fork
94 94 cs1 = fixture.commit_change(repo2.repo_name, filename='file1',
95 95 content='line1\nline2\n', message='commit2', vcs_type='git',
96 96 parent=cs0)
97 97
98 98 cs2 = fixture.commit_change(repo2.repo_name, filename='file1',
99 99 content='line1\nline2\nline3\n', message='commit3',
100 100 vcs_type='git', parent=cs1)
101 101
102 102 rev1 = 'master'
103 103 rev2 = 'master'
104 104
105 105 response = self.app.get(url('compare_url',
106 106 repo_name=repo1.repo_name,
107 107 org_ref_type="branch",
108 108 org_ref_name=rev2,
109 109 other_repo=repo2.repo_name,
110 110 other_ref_type="branch",
111 111 other_ref_name=rev1,
112 112 merge='1',))
113 113
114 114 response.mustcontain('%s@%s' % (repo1.repo_name, rev2))
115 115 response.mustcontain('%s@%s' % (repo2.repo_name, rev1))
116 116 response.mustcontain("""Showing 2 commits""")
117 117 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
118 118
119 response.mustcontain(_commit_ref(cs1.raw_id, 'commit2'))
120 response.mustcontain(_commit_ref(cs2.raw_id, 'commit3'))
119 response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2'))
120 response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3'))
121 121
122 122 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
123 123 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
124 124 ## files
125 125 response.mustcontain("""<a href="#C--826e8142e6ba">file1</a>""")
126 126 #swap
127 127 response.mustcontain("""<a class="btn btn-default btn-sm" href="/%s/compare/branch@%s...branch@%s?other_repo=%s&amp;merge=True"><i class="icon-arrows-cw"></i> Swap</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
128 128
129 129 def test_compare_forks_on_branch_extra_commits_origin_has_incoming_hg(self):
130 130 self.log_user()
131 131
132 132 repo1 = fixture.create_repo(u'one', repo_type='hg',
133 133 repo_description='diff-test',
134 134 cur_user=TEST_USER_ADMIN_LOGIN)
135 135
136 136 self.r1_id = repo1.repo_id
137 137
138 138 #commit something !
139 139 cs0 = fixture.commit_change(repo1.repo_name, filename='file1',
140 140 content='line1\n', message='commit1', vcs_type='hg',
141 141 parent=None, newfile=True)
142 142
143 143 #fork this repo
144 144 repo2 = fixture.create_fork(u'one', u'one-fork')
145 145 self.r2_id = repo2.repo_id
146 146
147 147 #now commit something to origin repo
148 148 cs1_prim = fixture.commit_change(repo1.repo_name, filename='file2',
149 149 content='line1file2\n', message='commit2', vcs_type='hg',
150 150 parent=cs0, newfile=True)
151 151
152 152 #add two extra commit into fork
153 153 cs1 = fixture.commit_change(repo2.repo_name, filename='file1',
154 154 content='line1\nline2\n', message='commit2', vcs_type='hg',
155 155 parent=cs0)
156 156
157 157 cs2 = fixture.commit_change(repo2.repo_name, filename='file1',
158 158 content='line1\nline2\nline3\n', message='commit3',
159 159 vcs_type='hg', parent=cs1)
160 160
161 161 rev1 = 'default'
162 162 rev2 = 'default'
163 163
164 164 response = self.app.get(url('compare_url',
165 165 repo_name=repo1.repo_name,
166 166 org_ref_type="branch",
167 167 org_ref_name=rev2,
168 168 other_repo=repo2.repo_name,
169 169 other_ref_type="branch",
170 170 other_ref_name=rev1,
171 171 merge='1',))
172 172
173 173 response.mustcontain('%s@%s' % (repo1.repo_name, rev2))
174 174 response.mustcontain('%s@%s' % (repo2.repo_name, rev1))
175 175 response.mustcontain("""Showing 2 commits""")
176 176 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
177 177
178 response.mustcontain(_commit_ref(cs1.raw_id, 'commit2'))
179 response.mustcontain(_commit_ref(cs2.raw_id, 'commit3'))
178 response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2'))
179 response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3'))
180 180
181 181 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
182 182 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
183 183 ## files
184 184 response.mustcontain("""<a href="#C--826e8142e6ba">file1</a>""")
185 185 #swap
186 186 response.mustcontain("""<a class="btn btn-default btn-sm" href="/%s/compare/branch@%s...branch@%s?other_repo=%s&amp;merge=True"><i class="icon-arrows-cw"></i> Swap</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
187 187
188 188 def test_compare_forks_on_branch_extra_commits_origin_has_incoming_git(self):
189 189 self.log_user()
190 190
191 191 repo1 = fixture.create_repo(u'one-git', repo_type='git',
192 192 repo_description='diff-test',
193 193 cur_user=TEST_USER_ADMIN_LOGIN)
194 194
195 195 self.r1_id = repo1.repo_id
196 196
197 197 #commit something !
198 198 cs0 = fixture.commit_change(repo1.repo_name, filename='file1',
199 199 content='line1\n', message='commit1', vcs_type='git',
200 200 parent=None, newfile=True)
201 201
202 202 #fork this repo
203 203 repo2 = fixture.create_fork(u'one-git', u'one-git-fork')
204 204 self.r2_id = repo2.repo_id
205 205
206 206 #now commit something to origin repo
207 207 cs1_prim = fixture.commit_change(repo1.repo_name, filename='file2',
208 208 content='line1file2\n', message='commit2', vcs_type='git',
209 209 parent=cs0, newfile=True)
210 210
211 211 #add two extra commit into fork
212 212 cs1 = fixture.commit_change(repo2.repo_name, filename='file1',
213 213 content='line1\nline2\n', message='commit2', vcs_type='git',
214 214 parent=cs0)
215 215
216 216 cs2 = fixture.commit_change(repo2.repo_name, filename='file1',
217 217 content='line1\nline2\nline3\n', message='commit3',
218 218 vcs_type='git', parent=cs1)
219 219
220 220 rev1 = 'master'
221 221 rev2 = 'master'
222 222
223 223 response = self.app.get(url('compare_url',
224 224 repo_name=repo1.repo_name,
225 225 org_ref_type="branch",
226 226 org_ref_name=rev2,
227 227 other_repo=repo2.repo_name,
228 228 other_ref_type="branch",
229 229 other_ref_name=rev1,
230 230 merge='1',))
231 231
232 232 response.mustcontain('%s@%s' % (repo1.repo_name, rev2))
233 233 response.mustcontain('%s@%s' % (repo2.repo_name, rev1))
234 234 response.mustcontain("""Showing 2 commits""")
235 235 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
236 236
237 response.mustcontain(_commit_ref(cs1.raw_id, 'commit2'))
238 response.mustcontain(_commit_ref(cs2.raw_id, 'commit3'))
237 response.mustcontain(_commit_ref(repo2.repo_name, cs1.raw_id, 'commit2'))
238 response.mustcontain(_commit_ref(repo2.repo_name, cs2.raw_id, 'commit3'))
239 239
240 240 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
241 241 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
242 242 ## files
243 243 response.mustcontain("""<a href="#C--826e8142e6ba">file1</a>""")
244 244 #swap
245 245 response.mustcontain("""<a class="btn btn-default btn-sm" href="/%s/compare/branch@%s...branch@%s?other_repo=%s&amp;merge=True"><i class="icon-arrows-cw"></i> Swap</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
246 246
247 247 def test_compare_cherry_pick_changesets_from_bottom(self):
248 248
249 249 # repo1:
250 250 # cs0:
251 251 # cs1:
252 252 # repo1-fork- in which we will cherry pick bottom changesets
253 253 # cs0:
254 254 # cs1:
255 255 # cs2: x
256 256 # cs3: x
257 257 # cs4: x
258 258 # cs5:
259 259 #make repo1, and cs1+cs2
260 260 self.log_user()
261 261
262 262 repo1 = fixture.create_repo(u'repo1', repo_type='hg',
263 263 repo_description='diff-test',
264 264 cur_user=TEST_USER_ADMIN_LOGIN)
265 265 self.r1_id = repo1.repo_id
266 266
267 267 #commit something !
268 268 cs0 = fixture.commit_change(repo1.repo_name, filename='file1',
269 269 content='line1\n', message='commit1', vcs_type='hg',
270 270 parent=None, newfile=True)
271 271 cs1 = fixture.commit_change(repo1.repo_name, filename='file1',
272 272 content='line1\nline2\n', message='commit2', vcs_type='hg',
273 273 parent=cs0)
274 274 #fork this repo
275 275 repo2 = fixture.create_fork(u'repo1', u'repo1-fork')
276 276 self.r2_id = repo2.repo_id
277 277 #now make cs3-6
278 278 cs2 = fixture.commit_change(repo1.repo_name, filename='file1',
279 279 content='line1\nline2\nline3\n', message='commit3',
280 280 vcs_type='hg', parent=cs1)
281 281 cs3 = fixture.commit_change(repo1.repo_name, filename='file1',
282 282 content='line1\nline2\nline3\nline4\n', message='commit4',
283 283 vcs_type='hg', parent=cs2)
284 284 cs4 = fixture.commit_change(repo1.repo_name, filename='file1',
285 285 content='line1\nline2\nline3\nline4\nline5\n',
286 286 message='commit5', vcs_type='hg', parent=cs3)
287 287 cs5 = fixture.commit_change(repo1.repo_name, filename='file1',
288 288 content='line1\nline2\nline3\nline4\nline5\nline6\n',
289 289 message='commit6', vcs_type='hg', parent=cs4)
290 290
291 291 response = self.app.get(url('compare_url',
292 292 repo_name=repo2.repo_name,
293 293 org_ref_type="rev",
294 294 org_ref_name=cs1.short_id, # parent of cs2, in repo2
295 295 other_repo=repo1.repo_name,
296 296 other_ref_type="rev",
297 297 other_ref_name=cs4.short_id,
298 298 merge='True',
299 299 ))
300 300 response.mustcontain('%s@%s' % (repo2.repo_name, cs1.short_id))
301 301 response.mustcontain('%s@%s' % (repo1.repo_name, cs4.short_id))
302 302 response.mustcontain("""Showing 3 commits""")
303 303 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""")
304 304
305 response.mustcontain(_commit_ref(cs2.raw_id, 'commit3'))
306 response.mustcontain(_commit_ref(cs3.raw_id, 'commit4'))
307 response.mustcontain(_commit_ref(cs4.raw_id, 'commit5'))
305 response.mustcontain(_commit_ref(repo1.repo_name, cs2.raw_id, 'commit3'))
306 response.mustcontain(_commit_ref(repo1.repo_name, cs3.raw_id, 'commit4'))
307 response.mustcontain(_commit_ref(repo1.repo_name, cs4.raw_id, 'commit5'))
308 308
309 309 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r2:%s</a>""" % (repo1.repo_name, cs2.raw_id, cs2.short_id))
310 310 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r3:%s</a>""" % (repo1.repo_name, cs3.raw_id, cs3.short_id))
311 311 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r4:%s</a>""" % (repo1.repo_name, cs4.raw_id, cs4.short_id))
312 312 ## files
313 313 response.mustcontain("""#C--826e8142e6ba">file1</a>""")
314 314
315 315 def test_compare_cherry_pick_changesets_from_top(self):
316 316 # repo1:
317 317 # cs0:
318 318 # cs1:
319 319 # repo1-fork- in which we will cherry pick bottom changesets
320 320 # cs0:
321 321 # cs1:
322 322 # cs2:
323 323 # cs3: x
324 324 # cs4: x
325 325 # cs5: x
326 326 #
327 327 #make repo1, and cs1+cs2
328 328 self.log_user()
329 329 repo1 = fixture.create_repo(u'repo1', repo_type='hg',
330 330 repo_description='diff-test',
331 331 cur_user=TEST_USER_ADMIN_LOGIN)
332 332 self.r1_id = repo1.repo_id
333 333
334 334 #commit something !
335 335 cs0 = fixture.commit_change(repo1.repo_name, filename='file1',
336 336 content='line1\n', message='commit1', vcs_type='hg',
337 337 parent=None, newfile=True)
338 338 cs1 = fixture.commit_change(repo1.repo_name, filename='file1',
339 339 content='line1\nline2\n', message='commit2', vcs_type='hg',
340 340 parent=cs0)
341 341 #fork this repo
342 342 repo2 = fixture.create_fork(u'repo1', u'repo1-fork')
343 343 self.r2_id = repo2.repo_id
344 344 #now make cs3-6
345 345 cs2 = fixture.commit_change(repo1.repo_name, filename='file1',
346 346 content='line1\nline2\nline3\n', message='commit3',
347 347 vcs_type='hg', parent=cs1)
348 348 cs3 = fixture.commit_change(repo1.repo_name, filename='file1',
349 349 content='line1\nline2\nline3\nline4\n', message='commit4',
350 350 vcs_type='hg', parent=cs2)
351 351 cs4 = fixture.commit_change(repo1.repo_name, filename='file1',
352 352 content='line1\nline2\nline3\nline4\nline5\n',
353 353 message='commit5', vcs_type='hg', parent=cs3)
354 354 cs5 = fixture.commit_change(repo1.repo_name, filename='file1',
355 355 content='line1\nline2\nline3\nline4\nline5\nline6\n',
356 356 message='commit6', vcs_type='hg', parent=cs4)
357 357
358 358 response = self.app.get(url('compare_url',
359 359 repo_name=repo1.repo_name,
360 360 org_ref_type="rev",
361 361 org_ref_name=cs2.short_id, # parent of cs3, not in repo2
362 362 other_ref_type="rev",
363 363 other_ref_name=cs5.short_id,
364 364 merge='1',))
365 365
366 366 response.mustcontain('%s@%s' % (repo1.repo_name, cs2.short_id))
367 367 response.mustcontain('%s@%s' % (repo1.repo_name, cs5.short_id))
368 368 response.mustcontain("""Showing 3 commits""")
369 369 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""")
370 370
371 response.mustcontain(_commit_ref(cs3.raw_id, 'commit4'))
372 response.mustcontain(_commit_ref(cs4.raw_id, 'commit5'))
373 response.mustcontain(_commit_ref(cs5.raw_id, 'commit6'))
371 response.mustcontain(_commit_ref(repo1.repo_name, cs3.raw_id, 'commit4'))
372 response.mustcontain(_commit_ref(repo1.repo_name, cs4.raw_id, 'commit5'))
373 response.mustcontain(_commit_ref(repo1.repo_name, cs5.raw_id, 'commit6'))
374 374
375 375 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r3:%s</a>""" % (repo1.repo_name, cs3.raw_id, cs3.short_id))
376 376 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r4:%s</a>""" % (repo1.repo_name, cs4.raw_id, cs4.short_id))
377 377 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/%s">r5:%s</a>""" % (repo1.repo_name, cs5.raw_id, cs5.short_id))
378 378 ## files
379 379 response.mustcontain("""#C--826e8142e6ba">file1</a>""")
380 380
381 381 def test_compare_cherry_pick_changeset_mixed_branches(self):
382 382 #TODO: write this
383 383 assert 1
384 384
385 385 def test_compare_remote_branches_hg(self):
386 386 self.log_user()
387 387
388 388 repo2 = fixture.create_fork(HG_REPO, HG_FORK)
389 389 self.r2_id = repo2.repo_id
390 390 rev1 = '56349e29c2af'
391 391 rev2 = '7d4bc8ec6be5'
392 392
393 393 response = self.app.get(url('compare_url',
394 394 repo_name=HG_REPO,
395 395 org_ref_type="rev",
396 396 org_ref_name=rev1,
397 397 other_ref_type="rev",
398 398 other_ref_name=rev2,
399 399 other_repo=HG_FORK,
400 400 merge='1',))
401 401
402 402 response.mustcontain('%s@%s' % (HG_REPO, rev1))
403 403 response.mustcontain('%s@%s' % (HG_FORK, rev2))
404 404 ## outgoing changesets between those revisions
405 405
406 406 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_FORK))
407 407 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_FORK))
408 408 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_FORK, rev2))
409 409
410 410 ## files
411 411 response.mustcontain("""<a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>""")
412 412 response.mustcontain("""<a href="#C--41b41c1f2796">vcs/backends/__init__.py</a>""")
413 413 response.mustcontain("""<a href="#C--2f574d260608">vcs/backends/base.py</a>""")
414 414
415 415 def test_compare_remote_branches_git(self):
416 416 self.log_user()
417 417
418 418 repo2 = fixture.create_fork(GIT_REPO, GIT_FORK)
419 419 self.r2_id = repo2.repo_id
420 420 rev1 = '102607b09cdd60e2793929c4f90478be29f85a17'
421 421 rev2 = 'd7e0d30fbcae12c90680eb095a4f5f02505ce501'
422 422
423 423 response = self.app.get(url('compare_url',
424 424 repo_name=GIT_REPO,
425 425 org_ref_type="rev",
426 426 org_ref_name=rev1,
427 427 other_ref_type="rev",
428 428 other_ref_name=rev2,
429 429 other_repo=GIT_FORK,
430 430 merge='1',))
431 431
432 432 response.mustcontain('%s@%s' % (GIT_REPO, rev1))
433 433 response.mustcontain('%s@%s' % (GIT_FORK, rev2))
434 434 ## outgoing changesets between those revisions
435 435
436 436 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/49d3fd156b6f7db46313fac355dca1a0b94a0017">r4:49d3fd156b6f</a>""" % (GIT_FORK))
437 437 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/2d1028c054665b962fa3d307adfc923ddd528038">r5:2d1028c05466</a>""" % (GIT_FORK))
438 438 response.mustcontain("""<a class="changeset_hash" href="/%s/changeset/d7e0d30fbcae12c90680eb095a4f5f02505ce501">r6:%s</a>""" % (GIT_FORK, rev2[:12]))
439 439
440 440 ## files
441 441 response.mustcontain("""<a href="#C--9c390eb52cd6">vcs/backends/hg.py</a>""")
442 442 response.mustcontain("""<a href="#C--41b41c1f2796">vcs/backends/__init__.py</a>""")
443 443 response.mustcontain("""<a href="#C--2f574d260608">vcs/backends/base.py</a>""")
444 444
445 445 def test_org_repo_new_commits_after_forking_simple_diff_hg(self):
446 446 self.log_user()
447 447
448 448 repo1 = fixture.create_repo(u'one', repo_type='hg',
449 449 repo_description='diff-test',
450 450 cur_user=TEST_USER_ADMIN_LOGIN)
451 451
452 452 self.r1_id = repo1.repo_id
453 453 r1_name = repo1.repo_name
454 454
455 455 cs0 = fixture.commit_change(repo=r1_name, filename='file1',
456 456 content='line1', message='commit1', vcs_type='hg', newfile=True)
457 457 Session().commit()
458 458 assert repo1.scm_instance.revisions == [cs0.raw_id]
459 459 #fork the repo1
460 460 repo2 = fixture.create_repo(u'one-fork', repo_type='hg',
461 461 repo_description='diff-test',
462 462 cur_user=TEST_USER_ADMIN_LOGIN,
463 463 clone_uri=repo1.repo_full_path,
464 464 fork_of='one')
465 465 Session().commit()
466 466 assert repo2.scm_instance.revisions == [cs0.raw_id]
467 467 self.r2_id = repo2.repo_id
468 468 r2_name = repo2.repo_name
469 469
470 470 cs1 = fixture.commit_change(repo=r2_name, filename='file1-fork',
471 471 content='file1-line1-from-fork', message='commit1-fork',
472 472 vcs_type='hg', parent=repo2.scm_instance[-1], newfile=True)
473 473
474 474 cs2 = fixture.commit_change(repo=r2_name, filename='file2-fork',
475 475 content='file2-line1-from-fork', message='commit2-fork',
476 476 vcs_type='hg', parent=cs1, newfile=True)
477 477
478 478 cs3 = fixture.commit_change(repo=r2_name, filename='file3-fork',
479 479 content='file3-line1-from-fork', message='commit3-fork',
480 480 vcs_type='hg', parent=cs2, newfile=True)
481 481 #compare !
482 482 rev1 = 'default'
483 483 rev2 = 'default'
484 484
485 485 response = self.app.get(url('compare_url',
486 486 repo_name=r2_name,
487 487 org_ref_type="branch",
488 488 org_ref_name=rev2,
489 489 other_ref_type="branch",
490 490 other_ref_name=rev1,
491 491 other_repo=r1_name,
492 492 merge='1',), status=404)
493 493
494 494 response.mustcontain('Cannot show empty diff')
495 495
496 496 cs0 = fixture.commit_change(repo=r1_name, filename='file2',
497 497 content='line1-added-after-fork', message='commit2-parent',
498 498 vcs_type='hg', parent=None, newfile=True)
499 499
500 500 #compare !
501 501 rev1 = 'default'
502 502 rev2 = 'default'
503 503 response = self.app.get(url('compare_url',
504 504 repo_name=r2_name,
505 505 org_ref_type="branch",
506 506 org_ref_name=rev2,
507 507 other_ref_type="branch",
508 508 other_ref_name=rev1,
509 509 other_repo=r1_name,
510 510 merge='1',
511 511 ))
512 512
513 513 response.mustcontain('%s@%s' % (r2_name, rev1))
514 514 response.mustcontain('%s@%s' % (r1_name, rev2))
515 515
516 516 response.mustcontain("""commit2-parent""")
517 517 response.mustcontain("""1 file changed with 1 insertions and 0 deletions""")
518 518 response.mustcontain("""line1-added-after-fork""")
519 519
520 520 def test_org_repo_new_commits_after_forking_simple_diff_git(self):
521 521 self.log_user()
522 522
523 523 repo1 = fixture.create_repo(u'one-git', repo_type='git',
524 524 repo_description='diff-test',
525 525 cur_user=TEST_USER_ADMIN_LOGIN)
526 526
527 527 self.r1_id = repo1.repo_id
528 528 r1_name = repo1.repo_name
529 529
530 530 cs0 = fixture.commit_change(repo=r1_name, filename='file1',
531 531 content='line1', message='commit1', vcs_type='git',
532 532 newfile=True)
533 533 Session().commit()
534 534 assert repo1.scm_instance.revisions == [cs0.raw_id]
535 535 #fork the repo1
536 536 repo2 = fixture.create_repo(u'one-git-fork', repo_type='git',
537 537 repo_description='diff-test',
538 538 cur_user=TEST_USER_ADMIN_LOGIN,
539 539 clone_uri=repo1.repo_full_path,
540 540 fork_of='one-git')
541 541 Session().commit()
542 542 assert repo2.scm_instance.revisions == [cs0.raw_id]
543 543 self.r2_id = repo2.repo_id
544 544 r2_name = repo2.repo_name
545 545
546 546
547 547 cs1 = fixture.commit_change(repo=r2_name, filename='file1-fork',
548 548 content='file1-line1-from-fork', message='commit1-fork',
549 549 vcs_type='git', parent=repo2.scm_instance[-1], newfile=True)
550 550
551 551 cs2 = fixture.commit_change(repo=r2_name, filename='file2-fork',
552 552 content='file2-line1-from-fork', message='commit2-fork',
553 553 vcs_type='git', parent=cs1, newfile=True)
554 554
555 555 cs3 = fixture.commit_change(repo=r2_name, filename='file3-fork',
556 556 content='file3-line1-from-fork', message='commit3-fork',
557 557 vcs_type='git', parent=cs2, newfile=True)
558 558 #compare !
559 559 rev1 = 'master'
560 560 rev2 = 'master'
561 561
562 562 response = self.app.get(url('compare_url',
563 563 repo_name=r2_name,
564 564 org_ref_type="branch",
565 565 org_ref_name=rev1,
566 566 other_ref_type="branch",
567 567 other_ref_name=rev2,
568 568 other_repo=r1_name,
569 569 merge='1',), status=404)
570 570
571 571 response.mustcontain('Cannot show empty diff')
572 572
573 573 cs0 = fixture.commit_change(repo=r1_name, filename='file2',
574 574 content='line1-added-after-fork', message='commit2-parent',
575 575 vcs_type='git', parent=None, newfile=True)
576 576
577 577 #compare !
578 578 rev1 = 'master'
579 579 rev2 = 'master'
580 580 response = self.app.get(url('compare_url',
581 581 repo_name=r2_name,
582 582 org_ref_type="branch",
583 583 org_ref_name=rev1,
584 584 other_ref_type="branch",
585 585 other_ref_name=rev2,
586 586 other_repo=r1_name,
587 587 merge='1',
588 588 ))
589 589
590 590 response.mustcontain('%s@%s' % (r2_name, rev1))
591 591 response.mustcontain('%s@%s' % (r1_name, rev2))
592 592
593 593 response.mustcontain("""commit2-parent""")
594 594 response.mustcontain("""1 file changed with 1 insertions and 0 deletions""")
595 595 response.mustcontain("""line1-added-after-fork""")
General Comments 0
You need to be logged in to leave comments. Login now