##// END OF EJS Templates
some tests fixes for compare view
marcink -
r3379:8171dfaf beta
parent child Browse files
Show More
@@ -1,469 +1,455 b''
1 from rhodecode.tests import *
1 from rhodecode.tests import *
2 from rhodecode.model.repo import RepoModel
2 from rhodecode.model.repo import RepoModel
3 from rhodecode.model.meta import Session
3 from rhodecode.model.meta import Session
4 from rhodecode.model.db import Repository
4 from rhodecode.model.db import Repository
5 from rhodecode.model.scm import ScmModel
5 from rhodecode.model.scm import ScmModel
6 from rhodecode.lib.vcs.backends.base import EmptyChangeset
6 from rhodecode.lib.vcs.backends.base import EmptyChangeset
7
7
8
8
9 def _fork_repo(fork_name, vcs_type, parent=None):
9 def _fork_repo(fork_name, vcs_type, parent=None):
10 if vcs_type =='hg':
10 if vcs_type =='hg':
11 _REPO = HG_REPO
11 _REPO = HG_REPO
12 elif vcs_type == 'git':
12 elif vcs_type == 'git':
13 _REPO = GIT_REPO
13 _REPO = GIT_REPO
14
14
15 if parent:
15 if parent:
16 _REPO = parent
16 _REPO = parent
17
17
18 form_data = dict(
18 form_data = dict(
19 repo_name=fork_name,
19 repo_name=fork_name,
20 repo_name_full=fork_name,
20 repo_name_full=fork_name,
21 repo_group=None,
21 repo_group=None,
22 repo_type=vcs_type,
22 repo_type=vcs_type,
23 description='',
23 description='',
24 private=False,
24 private=False,
25 copy_permissions=False,
25 copy_permissions=False,
26 landing_rev='tip',
26 landing_rev='tip',
27 update_after_clone=False,
27 update_after_clone=False,
28 fork_parent_id=Repository.get_by_repo_name(_REPO),
28 fork_parent_id=Repository.get_by_repo_name(_REPO),
29 )
29 )
30 repo = RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN)
30 repo = RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN)
31
31
32 Session().commit()
32 Session().commit()
33 return Repository.get_by_repo_name(fork_name)
33 return Repository.get_by_repo_name(fork_name)
34
34
35
35
36 def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False):
36 def _commit_change(repo, filename, content, message, vcs_type, parent=None, newfile=False):
37 repo = Repository.get_by_repo_name(repo)
37 repo = Repository.get_by_repo_name(repo)
38 _cs = parent
38 _cs = parent
39 if not parent:
39 if not parent:
40 _cs = EmptyChangeset(alias=vcs_type)
40 _cs = EmptyChangeset(alias=vcs_type)
41
41
42 if newfile:
42 if newfile:
43 cs = ScmModel().create_node(
43 cs = ScmModel().create_node(
44 repo=repo.scm_instance, repo_name=repo.repo_name,
44 repo=repo.scm_instance, repo_name=repo.repo_name,
45 cs=_cs, user=TEST_USER_ADMIN_LOGIN,
45 cs=_cs, user=TEST_USER_ADMIN_LOGIN,
46 author=TEST_USER_ADMIN_LOGIN,
46 author=TEST_USER_ADMIN_LOGIN,
47 message=message,
47 message=message,
48 content=content,
48 content=content,
49 f_path=filename
49 f_path=filename
50 )
50 )
51 else:
51 else:
52 cs = ScmModel().commit_change(
52 cs = ScmModel().commit_change(
53 repo=repo.scm_instance, repo_name=repo.repo_name,
53 repo=repo.scm_instance, repo_name=repo.repo_name,
54 cs=parent, user=TEST_USER_ADMIN_LOGIN,
54 cs=parent, user=TEST_USER_ADMIN_LOGIN,
55 author=TEST_USER_ADMIN_LOGIN,
55 author=TEST_USER_ADMIN_LOGIN,
56 message=message,
56 message=message,
57 content=content,
57 content=content,
58 f_path=filename
58 f_path=filename
59 )
59 )
60 return cs
60 return cs
61
61
62
62
63 class TestCompareController(TestController):
63 class TestCompareController(TestController):
64
64
65 def setUp(self):
66 self.r1_id = None
67 self.r2_id = None
68
69 def tearDown(self):
70 if self.r2_id:
71 RepoModel().delete(self.r2_id)
72 if self.r1_id:
73 RepoModel().delete(self.r1_id)
74 Session().commit()
75 Session.remove()
76
65 def test_compare_forks_on_branch_extra_commits_hg(self):
77 def test_compare_forks_on_branch_extra_commits_hg(self):
66 self.log_user()
78 self.log_user()
67
68 repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
79 repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
69 description='diff-test',
80 description='diff-test',
70 owner=TEST_USER_ADMIN_LOGIN)
81 owner=TEST_USER_ADMIN_LOGIN)
71 r1_id = repo1.repo_id
72 Session().commit()
82 Session().commit()
83 self.r1_id = repo1.repo_id
73 #commit something !
84 #commit something !
74 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
85 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
75 message='commit1', vcs_type='hg', parent=None, newfile=True)
86 message='commit1', vcs_type='hg', parent=None, newfile=True)
76
87
77 #fork this repo
88 #fork this repo
78 repo2 = _fork_repo('one-fork', 'hg', parent='one')
89 repo2 = _fork_repo('one-fork', 'hg', parent='one')
79 Session().commit()
90 Session().commit()
80 r2_id = repo2.repo_id
91 self.r2_id = repo2.repo_id
81
92
82 #add two extra commit into fork
93 #add two extra commit into fork
83 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
94 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
84 message='commit2', vcs_type='hg', parent=cs0)
95 message='commit2', vcs_type='hg', parent=cs0)
85
96
86 cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n',
97 cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n',
87 message='commit3', vcs_type='hg', parent=cs1)
98 message='commit3', vcs_type='hg', parent=cs1)
88
99
89 rev1 = 'default'
100 rev1 = 'default'
90 rev2 = 'default'
101 rev2 = 'default'
91
102
92
103 response = self.app.get(url(controller='compare', action='index',
93 try:
104 repo_name=repo1.repo_name,
94 response = self.app.get(url(controller='compare', action='index',
105 org_ref_type="branch",
95 repo_name=repo1.repo_name,
106 org_ref=rev2,
96 org_ref_type="branch",
107 other_repo=repo2.repo_name,
97 org_ref=rev2,
108 other_ref_type="branch",
98 other_repo=repo2.repo_name,
109 other_ref=rev1,
99 other_ref_type="branch",
110 ))
100 other_ref=rev1,
101 ))
102
111
103 response.mustcontain('%s@%s -> %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
112 response.mustcontain('%s@%s -> %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
104 response.mustcontain("""Showing 2 commits""")
113 response.mustcontain("""Showing 2 commits""")
105 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
114 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
106
115
107 response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
116 response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
108 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
117 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
109
118
110 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
119 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
111 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
120 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
112 ## files
121 ## files
113 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
122 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
114 #swap
123 #swap
115 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
124 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
116 finally:
117 RepoModel().delete(r2_id)
118 RepoModel().delete(r1_id)
119
125
120 def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self):
126 def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self):
121 self.log_user()
127 self.log_user()
122
128
123 repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
129 repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
124 description='diff-test',
130 description='diff-test',
125 owner=TEST_USER_ADMIN_LOGIN)
131 owner=TEST_USER_ADMIN_LOGIN)
126 r1_id = repo1.repo_id
127 Session().commit()
132 Session().commit()
133 self.r1_id = repo1.repo_id
134
128 #commit something !
135 #commit something !
129 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
136 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
130 message='commit1', vcs_type='hg', parent=None, newfile=True)
137 message='commit1', vcs_type='hg', parent=None, newfile=True)
131
138
132 #fork this repo
139 #fork this repo
133 repo2 = _fork_repo('one-fork', 'hg', parent='one')
140 repo2 = _fork_repo('one-fork', 'hg', parent='one')
134 Session().commit()
141 Session().commit()
142 self.r2_id = repo2.repo_id
135
143
136 #now commit something to origin repo
144 #now commit something to origin repo
137 cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n',
145 cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n',
138 message='commit2', vcs_type='hg', parent=cs0, newfile=True)
146 message='commit2', vcs_type='hg', parent=cs0, newfile=True)
139
147
140 r2_id = repo2.repo_id
141
142 #add two extra commit into fork
148 #add two extra commit into fork
143 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
149 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n',
144 message='commit2', vcs_type='hg', parent=cs0)
150 message='commit2', vcs_type='hg', parent=cs0)
145
151
146 cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n',
152 cs2 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\nline3\n',
147 message='commit3', vcs_type='hg', parent=cs1)
153 message='commit3', vcs_type='hg', parent=cs1)
148
154
149 rev1 = 'default'
155 rev1 = 'default'
150 rev2 = 'default'
156 rev2 = 'default'
151
157
152 try:
158 response = self.app.get(url(controller='compare', action='index',
153 response = self.app.get(url(controller='compare', action='index',
159 repo_name=repo1.repo_name,
154 repo_name=repo1.repo_name,
160 org_ref_type="branch",
155 org_ref_type="branch",
161 org_ref=rev2,
156 org_ref=rev2,
162 other_repo=repo2.repo_name,
157 other_repo=repo2.repo_name,
163 other_ref_type="branch",
158 other_ref_type="branch",
164 other_ref=rev1,
159 other_ref=rev1,
165 ))
160 ))
166 response.mustcontain('%s@%s -&gt; %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
161 response.mustcontain('%s@%s -&gt; %s@%s' % (repo1.repo_name, rev2, repo2.repo_name, rev1))
167 response.mustcontain("""Showing 2 commits""")
162 response.mustcontain("""Showing 2 commits""")
168 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
163 response.mustcontain("""1 file changed with 2 insertions and 0 deletions""")
164
169
165 response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
170 response.mustcontain("""<div class="message tooltip" title="commit2" style="white-space:normal">commit2</div>""")
166 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
171 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
167
172
168 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
173 response.mustcontain("""<a href="/%s/changeset/%s">r1:%s</a>""" % (repo2.repo_name, cs1.raw_id, cs1.short_id))
169 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
174 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo2.repo_name, cs2.raw_id, cs2.short_id))
170 ## files
175 ## files
171 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
176 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo1.repo_name, rev2, rev1, repo2.repo_name))
172 #swap
177 #swap
173 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
178 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
174 finally:
175 RepoModel().delete(r2_id)
176 RepoModel().delete(r1_id)
177
179
178 def test_compare_cherry_pick_changesets_from_bottom(self):
180 def test_compare_cherry_pick_changesets_from_bottom(self):
179 """
181 """
180 repo1:
182 repo1:
181 cs1:
183 cs1:
182 cs2:
184 cs2:
183 repo1-fork- in which we will cherry pick bottom changesets
185 repo1-fork- in which we will cherry pick bottom changesets
184 cs1:
186 cs1:
185 cs2:
187 cs2:
186 cs3: x
188 cs3: x
187 cs4: x
189 cs4: x
188 cs5: x
190 cs5: x
189 cs6:
191 cs6:
190 """
192 """
191 #make repo1, and cs1+cs2
193 #make repo1, and cs1+cs2
192 self.log_user()
194 self.log_user()
193
195
194 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg',
196 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg',
195 description='diff-test',
197 description='diff-test',
196 owner=TEST_USER_ADMIN_LOGIN)
198 owner=TEST_USER_ADMIN_LOGIN)
197 r1_id = repo1.repo_id
198 Session().commit()
199 Session().commit()
200 self.r1_id = repo1.repo_id
201
199 #commit something !
202 #commit something !
200 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
203 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
201 message='commit1', vcs_type='hg', parent=None,
204 message='commit1', vcs_type='hg', parent=None,
202 newfile=True)
205 newfile=True)
203 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n',
206 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n',
204 message='commit2', vcs_type='hg', parent=cs1)
207 message='commit2', vcs_type='hg', parent=cs1)
205 #fork this repo
208 #fork this repo
206 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
209 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
207 Session().commit()
210 Session().commit()
208 r2_id = repo1.repo_id
211 self.r2_id = repo2.repo_id
209 #now make cs3-6
212 #now make cs3-6
210 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
213 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
211 message='commit3', vcs_type='hg', parent=cs2)
214 message='commit3', vcs_type='hg', parent=cs2)
212 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n',
215 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n',
213 message='commit4', vcs_type='hg', parent=cs3)
216 message='commit4', vcs_type='hg', parent=cs3)
214 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n',
217 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n',
215 message='commit5', vcs_type='hg', parent=cs4)
218 message='commit5', vcs_type='hg', parent=cs4)
216 cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n',
219 cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n',
217 message='commit6', vcs_type='hg', parent=cs5)
220 message='commit6', vcs_type='hg', parent=cs5)
218
221
219 rev1 = 'tip'
222 rev1 = 'tip'
220 rev2 = 'tip'
223 rev2 = 'tip'
221
224
222 try:
225 response = self.app.get(url(controller='compare', action='index',
223 response = self.app.get(url(controller='compare', action='index',
226 repo_name=repo2.repo_name,
224 repo_name=repo2.repo_name,
227 org_ref_type="tag",
225 org_ref_type="tag",
228 org_ref=rev1,
226 org_ref=rev1,
229 other_repo=repo1.repo_name,
227 other_repo=repo1.repo_name,
230 other_ref_type="tag",
228 other_ref_type="tag",
231 other_ref=rev2,
229 other_ref=rev2,
232 rev_start=cs3.raw_id,
230 rev_start=cs3.raw_id,
233 rev_end=cs5.raw_id,
231 rev_end=cs5.raw_id,
234 ))
232 ))
235 response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
233 response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
236 response.mustcontain("""Showing 3 commits""")
234 response.mustcontain("""Showing 3 commits""")
237 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""")
235 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""")
236
238
237 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
239 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""")
238 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit4</div>""")
240 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit4</div>""")
239 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit5</div>""")
241 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit5</div>""")
240
242
241 response.mustcontain("""<a href="/%s/changeset/%s">r3:%s</a>""" % (repo2.repo_name, cs3.raw_id, cs3.short_id))
243 response.mustcontain("""<a href="/%s/changeset/%s">r3:%s</a>""" % (repo2.repo_name, cs3.raw_id, cs3.short_id))
242 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo2.repo_name, cs4.raw_id, cs4.short_id))
244 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo2.repo_name, cs4.raw_id, cs4.short_id))
243 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo2.repo_name, cs5.raw_id, cs5.short_id))
245 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo2.repo_name, cs5.raw_id, cs5.short_id))
244 ## files
246 ## files
245 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
247 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
246 #swap
248 #swap
247 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
249 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
248 finally:
249 RepoModel().delete(r2_id)
250 RepoModel().delete(r1_id)
251
250
252 def test_compare_cherry_pick_changesets_from_top(self):
251 def test_compare_cherry_pick_changesets_from_top(self):
253 """
252 """
254 repo1:
253 repo1:
255 cs1:
254 cs1:
256 cs2:
255 cs2:
257 repo1-fork- in which we will cherry pick bottom changesets
256 repo1-fork- in which we will cherry pick bottom changesets
258 cs1:
257 cs1:
259 cs2:
258 cs2:
260 cs3:
259 cs3:
261 cs4: x
260 cs4: x
262 cs5: x
261 cs5: x
263 cs6: x
262 cs6: x
264 """
263 """
265 #make repo1, and cs1+cs2
264 #make repo1, and cs1+cs2
266 self.log_user()
265 self.log_user()
267
268 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg',
266 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg',
269 description='diff-test',
267 description='diff-test',
270 owner=TEST_USER_ADMIN_LOGIN)
268 owner=TEST_USER_ADMIN_LOGIN)
271 r1_id = repo1.repo_id
272 Session().commit()
269 Session().commit()
270 self.r1_id = repo1.repo_id
271
273 #commit something !
272 #commit something !
274 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
273 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n',
275 message='commit1', vcs_type='hg', parent=None,
274 message='commit1', vcs_type='hg', parent=None,
276 newfile=True)
275 newfile=True)
277 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n',
276 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n',
278 message='commit2', vcs_type='hg', parent=cs1)
277 message='commit2', vcs_type='hg', parent=cs1)
279 #fork this repo
278 #fork this repo
280 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
279 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1')
281 Session().commit()
280 Session().commit()
282 r2_id = repo1.repo_id
281 self.r2_id = repo1.repo_id
283 #now make cs3-6
282 #now make cs3-6
284 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
283 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n',
285 message='commit3', vcs_type='hg', parent=cs2)
284 message='commit3', vcs_type='hg', parent=cs2)
286 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n',
285 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n',
287 message='commit4', vcs_type='hg', parent=cs3)
286 message='commit4', vcs_type='hg', parent=cs3)
288 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n',
287 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n',
289 message='commit5', vcs_type='hg', parent=cs4)
288 message='commit5', vcs_type='hg', parent=cs4)
290 cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n',
289 cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n',
291 message='commit6', vcs_type='hg', parent=cs5)
290 message='commit6', vcs_type='hg', parent=cs5)
292
293 rev1 = 'tip'
291 rev1 = 'tip'
294 rev2 = 'tip'
292 rev2 = 'tip'
295
293
296 try:
294 response = self.app.get(url(controller='compare', action='index',
297 response = self.app.get(url(controller='compare', action='index',
295 repo_name=repo2.repo_name,
298 repo_name=repo2.repo_name,
296 org_ref_type="tag",
299 org_ref_type="tag",
297 org_ref=rev1,
300 org_ref=rev1,
298 other_repo=repo1.repo_name,
301 other_repo=repo1.repo_name,
299 other_ref_type="tag",
302 other_ref_type="tag",
300 other_ref=rev2,
303 other_ref=rev2,
301 rev_start=cs4.raw_id,
304 rev_start=cs4.raw_id,
302 rev_end=cs6.raw_id,
305 rev_end=cs6.raw_id,
303 ))
306 ))
307
304
308 response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
305 response.mustcontain('%s@%s -&gt; %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2))
309 response.mustcontain("""Showing 3 commits""")
306 response.mustcontain("""Showing 3 commits""")
310 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""")
307 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""")
311
308
312 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit4</div>""")
309 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit4</div>""")
313 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit5</div>""")
310 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit5</div>""")
314 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit6</div>""")
311 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit6</div>""")
315
312
316 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo2.repo_name, cs4.raw_id, cs4.short_id))
313 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo2.repo_name, cs4.raw_id, cs4.short_id))
317 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo2.repo_name, cs5.raw_id, cs5.short_id))
314 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo2.repo_name, cs5.raw_id, cs5.short_id))
318 response.mustcontain("""<a href="/%s/changeset/%s">r6:%s</a>""" % (repo2.repo_name, cs6.raw_id, cs6.short_id))
315 response.mustcontain("""<a href="/%s/changeset/%s">r6:%s</a>""" % (repo2.repo_name, cs6.raw_id, cs6.short_id))
319 ## files
316 ## files
320 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
317 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?other_repo=%s#C--826e8142e6ba">file1</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
321 #swap
318 #swap
322 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
319 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&amp;other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name))
323 finally:
324 RepoModel().delete(r2_id)
325 RepoModel().delete(r1_id)
326
320
327 def test_compare_cherry_pick_changeset_mixed_branches(self):
321 def test_compare_cherry_pick_changeset_mixed_branches(self):
328 """
322 """
329
323
330 """
324 """
331 pass
325 pass
332 #TODO write this tastecase
326 #TODO write this tastecase
333
327
334 def test_compare_remote_branches_hg(self):
328 def test_compare_remote_branches_hg(self):
335 self.log_user()
329 self.log_user()
336
330
337 _fork_repo(HG_FORK, 'hg')
331 _fork_repo(HG_FORK, 'hg')
338
332
339 rev1 = '56349e29c2af'
333 rev1 = '56349e29c2af'
340 rev2 = '7d4bc8ec6be5'
334 rev2 = '7d4bc8ec6be5'
341
335
342 try:
336 response = self.app.get(url(controller='compare', action='index',
343 response = self.app.get(url(controller='compare', action='index',
337 repo_name=HG_REPO,
344 repo_name=HG_REPO,
338 org_ref_type="rev",
345 org_ref_type="rev",
339 org_ref=rev1,
346 org_ref=rev1,
340 other_ref_type="rev",
347 other_ref_type="rev",
341 other_ref=rev2,
348 other_ref=rev2,
342 other_repo=HG_FORK,
349 other_repo=HG_FORK,
343 ))
350 ))
344 response.mustcontain('%s@%s -&gt; %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
351 response.mustcontain('%s@%s -&gt; %s@%s' % (HG_REPO, rev1, HG_FORK, rev2))
345 ## outgoing changesets between those revisions
352 ## outgoing changesets between those revisions
353
346
354 response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_REPO))
347 response.mustcontain("""<a href="/%s/changeset/2dda4e345facb0ccff1a191052dd1606dba6781d">r4:2dda4e345fac</a>""" % (HG_FORK))
355 response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_REPO))
348 response.mustcontain("""<a href="/%s/changeset/6fff84722075f1607a30f436523403845f84cd9e">r5:6fff84722075</a>""" % (HG_FORK))
356 response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_REPO, rev2))
349 response.mustcontain("""<a href="/%s/changeset/7d4bc8ec6be56c0f10425afb40b6fc315a4c25e7">r6:%s</a>""" % (HG_FORK, rev2))
357
350
358 ## files
351 ## files
359 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2))
352 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--9c390eb52cd6">vcs/backends/hg.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK))
360 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2))
353 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--41b41c1f2796">vcs/backends/__init__.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK))
361 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2))
354 response.mustcontain("""<a href="/%s/compare/rev@%s...rev@%s?other_repo=%s#C--2f574d260608">vcs/backends/base.py</a>""" % (HG_REPO, rev1, rev2, HG_FORK))
362 finally:
363 RepoModel().delete(HG_FORK)
364
355
365 def test_org_repo_new_commits_after_forking_simple_diff(self):
356 def test_org_repo_new_commits_after_forking_simple_diff(self):
366 self.log_user()
357 self.log_user()
367
358
368 repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
359 repo1 = RepoModel().create_repo(repo_name='one', repo_type='hg',
369 description='diff-test',
360 description='diff-test',
370 owner=TEST_USER_ADMIN_LOGIN)
361 owner=TEST_USER_ADMIN_LOGIN)
371
362
372 Session().commit()
363 Session().commit()
373 r1_id = repo1.repo_id
364 self.r1_id = repo1.repo_id
374 r1_name = repo1.repo_name
365 r1_name = repo1.repo_name
375
366
376 #commit something initially !
367 #commit something initially !
377 cs0 = ScmModel().create_node(
368 cs0 = ScmModel().create_node(
378 repo=repo1.scm_instance, repo_name=r1_name,
369 repo=repo1.scm_instance, repo_name=r1_name,
379 cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
370 cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
380 author=TEST_USER_ADMIN_LOGIN,
371 author=TEST_USER_ADMIN_LOGIN,
381 message='commit1',
372 message='commit1',
382 content='line1',
373 content='line1',
383 f_path='file1'
374 f_path='file1'
384 )
375 )
385 Session().commit()
376 Session().commit()
386 self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id])
377 self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id])
387 #fork the repo1
378 #fork the repo1
388 repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg',
379 repo2 = RepoModel().create_repo(repo_name='one-fork', repo_type='hg',
389 description='compare-test',
380 description='compare-test',
390 clone_uri=repo1.repo_full_path,
381 clone_uri=repo1.repo_full_path,
391 owner=TEST_USER_ADMIN_LOGIN, fork_of='one')
382 owner=TEST_USER_ADMIN_LOGIN, fork_of='one')
392 Session().commit()
383 Session().commit()
393 self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id])
384 self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id])
394 r2_id = repo2.repo_id
385 self.r2_id = repo2.repo_id
395 r2_name = repo2.repo_name
386 r2_name = repo2.repo_name
396
387
397 #make 3 new commits in fork
388 #make 3 new commits in fork
398 cs1 = ScmModel().create_node(
389 cs1 = ScmModel().create_node(
399 repo=repo2.scm_instance, repo_name=r2_name,
390 repo=repo2.scm_instance, repo_name=r2_name,
400 cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN,
391 cs=repo2.scm_instance[-1], user=TEST_USER_ADMIN_LOGIN,
401 author=TEST_USER_ADMIN_LOGIN,
392 author=TEST_USER_ADMIN_LOGIN,
402 message='commit1-fork',
393 message='commit1-fork',
403 content='file1-line1-from-fork',
394 content='file1-line1-from-fork',
404 f_path='file1-fork'
395 f_path='file1-fork'
405 )
396 )
406 cs2 = ScmModel().create_node(
397 cs2 = ScmModel().create_node(
407 repo=repo2.scm_instance, repo_name=r2_name,
398 repo=repo2.scm_instance, repo_name=r2_name,
408 cs=cs1, user=TEST_USER_ADMIN_LOGIN,
399 cs=cs1, user=TEST_USER_ADMIN_LOGIN,
409 author=TEST_USER_ADMIN_LOGIN,
400 author=TEST_USER_ADMIN_LOGIN,
410 message='commit2-fork',
401 message='commit2-fork',
411 content='file2-line1-from-fork',
402 content='file2-line1-from-fork',
412 f_path='file2-fork'
403 f_path='file2-fork'
413 )
404 )
414 cs3 = ScmModel().create_node(
405 cs3 = ScmModel().create_node(
415 repo=repo2.scm_instance, repo_name=r2_name,
406 repo=repo2.scm_instance, repo_name=r2_name,
416 cs=cs2, user=TEST_USER_ADMIN_LOGIN,
407 cs=cs2, user=TEST_USER_ADMIN_LOGIN,
417 author=TEST_USER_ADMIN_LOGIN,
408 author=TEST_USER_ADMIN_LOGIN,
418 message='commit3-fork',
409 message='commit3-fork',
419 content='file3-line1-from-fork',
410 content='file3-line1-from-fork',
420 f_path='file3-fork'
411 f_path='file3-fork'
421 )
412 )
422
413
423 #compare !
414 #compare !
424 rev1 = 'default'
415 rev1 = 'default'
425 rev2 = 'default'
416 rev2 = 'default'
426
417
427 try:
418 response = self.app.get(url(controller='compare', action='index',
428 response = self.app.get(url(controller='compare', action='index',
419 repo_name=r2_name,
429 repo_name=r2_name,
420 org_ref_type="branch",
430 org_ref_type="branch",
421 org_ref=rev1,
431 org_ref=rev1,
422 other_ref_type="branch",
432 other_ref_type="branch",
423 other_ref=rev2,
433 other_ref=rev2,
424 other_repo=r1_name,
434 repo=r1_name,
425 ))
435 ))
426 response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
436 #response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
427 response.mustcontain('No files')
428 response.mustcontain('No changesets')
437
429
438 #add new commit into parent !
430 #add new commit into parent !
439 cs0 = ScmModel().create_node(
431 cs0 = ScmModel().create_node(
440 repo=repo1.scm_instance, repo_name=r1_name,
432 repo=repo1.scm_instance, repo_name=r1_name,
441 cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
433 cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN,
442 author=TEST_USER_ADMIN_LOGIN,
434 author=TEST_USER_ADMIN_LOGIN,
443 message='commit2',
435 message='commit2-parent',
444 content='line1',
436 content='line1-added-after-fork',
445 f_path='file2'
437 f_path='file2'
446 )
438 )
447 #compare !
439 #compare !
448 rev1 = 'default'
440 rev1 = 'default'
449 rev2 = 'default'
441 rev2 = 'default'
450 response = self.app.get(url(controller='compare', action='index',
442 response = self.app.get(url(controller='compare', action='index',
451 repo_name=r2_name,
443 repo_name=r2_name,
452 org_ref_type="branch",
444 org_ref_type="branch",
453 org_ref=rev1,
445 org_ref=rev1,
454 other_ref_type="branch",
446 other_ref_type="branch",
455 other_ref=rev2,
447 other_ref=rev2,
456 repo=r1_name,
448 other_repo=r1_name,
457 bundle=False
449 ))
458 ))
459
450
460 response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
451 response.mustcontain('%s@%s -&gt; %s@%s' % (r2_name, rev1, r1_name, rev2))
461 response.mustcontain("""file1-line1-from-fork""")
452
462 response.mustcontain("""file2-line1-from-fork""")
453 response.mustcontain("""commit2-parent""")
463 response.mustcontain("""file3-line1-from-fork""")
454 response.mustcontain("""1 file changed with 1 insertions and 0 deletions""")
464 self.assertFalse("""<a href="#">file2</a>""" in response.body) # new commit from parent
455 response.mustcontain("""line1-added-after-fork""")
465 self.assertFalse("""line1-from-new-parent""" in response.body)
466 finally:
467 RepoModel().delete(r2_id)
468 RepoModel().delete(r1_id)
469 Session()
General Comments 0
You need to be logged in to leave comments. Login now