Mercurial > kallithea
comparison rhodecode/tests/functional/test_compare.py @ 3380:01fe360a66c0 beta
fixed pull-requests with cherry picking changesets
- fixed tests for them
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 19 Feb 2013 01:57:59 +0100 |
parents | 8171dfafb5db |
children | b3680a200f75 |
comparison
equal
deleted
inserted
replaced
3379:8171dfafb5db | 3380:01fe360a66c0 |
---|---|
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 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 |
85 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | 85 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
86 message='commit1', vcs_type='hg', parent=None, newfile=True) | 86 message='commit1', vcs_type='hg', parent=None, newfile=True) |
87 | 87 |
88 #fork this repo | 88 #fork this repo |
89 repo2 = _fork_repo('one-fork', 'hg', parent='one') | 89 repo2 = _fork_repo('one-fork', 'hg', parent='one') |
90 Session().commit() | |
91 self.r2_id = repo2.repo_id | 90 self.r2_id = repo2.repo_id |
92 | 91 |
93 #add two extra commit into fork | 92 #add two extra commit into fork |
94 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', | 93 cs1 = _commit_change(repo2.repo_name, filename='file1', content='line1\nline2\n', |
95 message='commit2', vcs_type='hg', parent=cs0) | 94 message='commit2', vcs_type='hg', parent=cs0) |
136 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | 135 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
137 message='commit1', vcs_type='hg', parent=None, newfile=True) | 136 message='commit1', vcs_type='hg', parent=None, newfile=True) |
138 | 137 |
139 #fork this repo | 138 #fork this repo |
140 repo2 = _fork_repo('one-fork', 'hg', parent='one') | 139 repo2 = _fork_repo('one-fork', 'hg', parent='one') |
141 Session().commit() | |
142 self.r2_id = repo2.repo_id | 140 self.r2_id = repo2.repo_id |
143 | 141 |
144 #now commit something to origin repo | 142 #now commit something to origin repo |
145 cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n', | 143 cs1_prim = _commit_change(repo1.repo_name, filename='file2', content='line1file2\n', |
146 message='commit2', vcs_type='hg', parent=cs0, newfile=True) | 144 message='commit2', vcs_type='hg', parent=cs0, newfile=True) |
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)) | 174 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)) |
177 #swap | 175 #swap |
178 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) | 176 response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?as_form=None&other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) |
179 | 177 |
180 def test_compare_cherry_pick_changesets_from_bottom(self): | 178 def test_compare_cherry_pick_changesets_from_bottom(self): |
181 """ | 179 |
182 repo1: | 180 # repo1: |
183 cs1: | 181 # cs0: |
184 cs2: | 182 # cs1: |
185 repo1-fork- in which we will cherry pick bottom changesets | 183 # repo1-fork- in which we will cherry pick bottom changesets |
186 cs1: | 184 # cs0: |
187 cs2: | 185 # cs1: |
188 cs3: x | 186 # cs2: x |
189 cs4: x | 187 # cs3: x |
190 cs5: x | 188 # cs4: x |
191 cs6: | 189 # cs5: |
192 """ | |
193 #make repo1, and cs1+cs2 | 190 #make repo1, and cs1+cs2 |
194 self.log_user() | 191 self.log_user() |
195 | 192 |
196 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg', | 193 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg', |
197 description='diff-test', | 194 description='diff-test', |
198 owner=TEST_USER_ADMIN_LOGIN) | 195 owner=TEST_USER_ADMIN_LOGIN) |
199 Session().commit() | 196 Session().commit() |
200 self.r1_id = repo1.repo_id | 197 self.r1_id = repo1.repo_id |
201 | 198 |
202 #commit something ! | 199 #commit something ! |
203 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | 200 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
204 message='commit1', vcs_type='hg', parent=None, | 201 message='commit1', vcs_type='hg', parent=None, |
205 newfile=True) | 202 newfile=True) |
206 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', | 203 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', |
207 message='commit2', vcs_type='hg', parent=cs1) | 204 message='commit2', vcs_type='hg', parent=cs0) |
208 #fork this repo | 205 #fork this repo |
209 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1') | 206 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1') |
210 Session().commit() | |
211 self.r2_id = repo2.repo_id | 207 self.r2_id = repo2.repo_id |
212 #now make cs3-6 | 208 #now make cs3-6 |
213 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', | 209 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', |
214 message='commit3', vcs_type='hg', parent=cs2) | 210 message='commit3', vcs_type='hg', parent=cs1) |
215 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', | 211 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', |
216 message='commit4', vcs_type='hg', parent=cs3) | 212 message='commit4', vcs_type='hg', parent=cs2) |
217 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n', | 213 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n', |
218 message='commit5', vcs_type='hg', parent=cs4) | 214 message='commit5', vcs_type='hg', parent=cs3) |
219 cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n', | 215 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n', |
220 message='commit6', vcs_type='hg', parent=cs5) | 216 message='commit6', vcs_type='hg', parent=cs4) |
221 | 217 |
218 rev1 = 'tip' | |
219 rev2 = 'tip' | |
220 | |
221 response = self.app.get(url(controller='compare', action='index', | |
222 repo_name=repo2.repo_name, | |
223 org_ref_type="tag", | |
224 org_ref=rev1, | |
225 other_repo=repo1.repo_name, | |
226 other_ref_type="tag", | |
227 other_ref=rev2, | |
228 rev_start=cs2.raw_id, | |
229 rev_end=cs4.raw_id, | |
230 )) | |
231 response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, cs2.short_id, repo1.repo_name, cs4.short_id)) | |
232 response.mustcontain("""Showing 3 commits""") | |
233 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""") | |
234 | |
235 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""") | |
236 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit4</div>""") | |
237 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit5</div>""") | |
238 | |
239 response.mustcontain("""<a href="/%s/changeset/%s">r2:%s</a>""" % (repo1.repo_name, cs2.raw_id, cs2.short_id)) | |
240 response.mustcontain("""<a href="/%s/changeset/%s">r3:%s</a>""" % (repo1.repo_name, cs3.raw_id, cs3.short_id)) | |
241 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo1.repo_name, cs4.raw_id, cs4.short_id)) | |
242 ## files | |
243 response.mustcontain("""#C--826e8142e6ba">file1</a>""") | |
244 | |
245 def test_compare_cherry_pick_changesets_from_top(self): | |
246 # repo1: | |
247 # cs0: | |
248 # cs1: | |
249 # repo1-fork- in which we will cherry pick bottom changesets | |
250 # cs0: | |
251 # cs1: | |
252 # cs2: | |
253 # cs3: x | |
254 # cs4: x | |
255 # cs5: x | |
256 # | |
257 #make repo1, and cs1+cs2 | |
258 self.log_user() | |
259 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg', | |
260 description='diff-test', | |
261 owner=TEST_USER_ADMIN_LOGIN) | |
262 Session().commit() | |
263 self.r1_id = repo1.repo_id | |
264 | |
265 #commit something ! | |
266 cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | |
267 message='commit1', vcs_type='hg', parent=None, | |
268 newfile=True) | |
269 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', | |
270 message='commit2', vcs_type='hg', parent=cs0) | |
271 #fork this repo | |
272 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1') | |
273 self.r2_id = repo2.repo_id | |
274 #now make cs3-6 | |
275 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', | |
276 message='commit3', vcs_type='hg', parent=cs1) | |
277 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', | |
278 message='commit4', vcs_type='hg', parent=cs2) | |
279 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n', | |
280 message='commit5', vcs_type='hg', parent=cs3) | |
281 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n', | |
282 message='commit6', vcs_type='hg', parent=cs4) | |
222 rev1 = 'tip' | 283 rev1 = 'tip' |
223 rev2 = 'tip' | 284 rev2 = 'tip' |
224 | 285 |
225 response = self.app.get(url(controller='compare', action='index', | 286 response = self.app.get(url(controller='compare', action='index', |
226 repo_name=repo2.repo_name, | 287 repo_name=repo2.repo_name, |
230 other_ref_type="tag", | 291 other_ref_type="tag", |
231 other_ref=rev2, | 292 other_ref=rev2, |
232 rev_start=cs3.raw_id, | 293 rev_start=cs3.raw_id, |
233 rev_end=cs5.raw_id, | 294 rev_end=cs5.raw_id, |
234 )) | 295 )) |
235 response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2)) | 296 |
297 response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, cs3.short_id, repo1.repo_name, cs5.short_id)) | |
236 response.mustcontain("""Showing 3 commits""") | 298 response.mustcontain("""Showing 3 commits""") |
237 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""") | 299 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""") |
238 | 300 |
239 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit3</div>""") | |
240 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit4</div>""") | 301 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit4</div>""") |
241 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit5</div>""") | 302 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit5</div>""") |
242 | 303 response.mustcontain("""<div class="message tooltip" title="commit6" style="white-space:normal">commit6</div>""") |
243 response.mustcontain("""<a href="/%s/changeset/%s">r3:%s</a>""" % (repo2.repo_name, cs3.raw_id, cs3.short_id)) | 304 |
244 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo2.repo_name, cs4.raw_id, cs4.short_id)) | 305 response.mustcontain("""<a href="/%s/changeset/%s">r3:%s</a>""" % (repo1.repo_name, cs3.raw_id, cs3.short_id)) |
245 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo2.repo_name, cs5.raw_id, cs5.short_id)) | 306 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo1.repo_name, cs4.raw_id, cs4.short_id)) |
307 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo1.repo_name, cs5.raw_id, cs5.short_id)) | |
246 ## files | 308 ## files |
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)) | 309 response.mustcontain("""#C--826e8142e6ba">file1</a>""") |
248 #swap | |
249 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name)) | |
250 | |
251 def test_compare_cherry_pick_changesets_from_top(self): | |
252 """ | |
253 repo1: | |
254 cs1: | |
255 cs2: | |
256 repo1-fork- in which we will cherry pick bottom changesets | |
257 cs1: | |
258 cs2: | |
259 cs3: | |
260 cs4: x | |
261 cs5: x | |
262 cs6: x | |
263 """ | |
264 #make repo1, and cs1+cs2 | |
265 self.log_user() | |
266 repo1 = RepoModel().create_repo(repo_name='repo1', repo_type='hg', | |
267 description='diff-test', | |
268 owner=TEST_USER_ADMIN_LOGIN) | |
269 Session().commit() | |
270 self.r1_id = repo1.repo_id | |
271 | |
272 #commit something ! | |
273 cs1 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | |
274 message='commit1', vcs_type='hg', parent=None, | |
275 newfile=True) | |
276 cs2 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\n', | |
277 message='commit2', vcs_type='hg', parent=cs1) | |
278 #fork this repo | |
279 repo2 = _fork_repo('repo1-fork', 'hg', parent='repo1') | |
280 Session().commit() | |
281 self.r2_id = repo1.repo_id | |
282 #now make cs3-6 | |
283 cs3 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\n', | |
284 message='commit3', vcs_type='hg', parent=cs2) | |
285 cs4 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\n', | |
286 message='commit4', vcs_type='hg', parent=cs3) | |
287 cs5 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\n', | |
288 message='commit5', vcs_type='hg', parent=cs4) | |
289 cs6 = _commit_change(repo1.repo_name, filename='file1', content='line1\nline2\nline3\nline4\nline5\nline6\n', | |
290 message='commit6', vcs_type='hg', parent=cs5) | |
291 rev1 = 'tip' | |
292 rev2 = 'tip' | |
293 | |
294 response = self.app.get(url(controller='compare', action='index', | |
295 repo_name=repo2.repo_name, | |
296 org_ref_type="tag", | |
297 org_ref=rev1, | |
298 other_repo=repo1.repo_name, | |
299 other_ref_type="tag", | |
300 other_ref=rev2, | |
301 rev_start=cs4.raw_id, | |
302 rev_end=cs6.raw_id, | |
303 )) | |
304 | |
305 response.mustcontain('%s@%s -> %s@%s' % (repo2.repo_name, rev1, repo1.repo_name, rev2)) | |
306 response.mustcontain("""Showing 3 commits""") | |
307 response.mustcontain("""1 file changed with 3 insertions and 0 deletions""") | |
308 | |
309 response.mustcontain("""<div class="message tooltip" title="commit3" style="white-space:normal">commit4</div>""") | |
310 response.mustcontain("""<div class="message tooltip" title="commit4" style="white-space:normal">commit5</div>""") | |
311 response.mustcontain("""<div class="message tooltip" title="commit5" style="white-space:normal">commit6</div>""") | |
312 | |
313 response.mustcontain("""<a href="/%s/changeset/%s">r4:%s</a>""" % (repo2.repo_name, cs4.raw_id, cs4.short_id)) | |
314 response.mustcontain("""<a href="/%s/changeset/%s">r5:%s</a>""" % (repo2.repo_name, cs5.raw_id, cs5.short_id)) | |
315 response.mustcontain("""<a href="/%s/changeset/%s">r6:%s</a>""" % (repo2.repo_name, cs6.raw_id, cs6.short_id)) | |
316 ## files | |
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)) | |
318 #swap | |
319 response.mustcontain("""<a href="/%s/compare/tag@%s...tag@%s?as_form=None&other_repo=%s">[swap]</a>""" % (repo1.repo_name, rev1, rev2, repo2.repo_name)) | |
320 | 310 |
321 def test_compare_cherry_pick_changeset_mixed_branches(self): | 311 def test_compare_cherry_pick_changeset_mixed_branches(self): |
322 """ | 312 """ |
323 | 313 |
324 """ | 314 """ |
326 #TODO write this tastecase | 316 #TODO write this tastecase |
327 | 317 |
328 def test_compare_remote_branches_hg(self): | 318 def test_compare_remote_branches_hg(self): |
329 self.log_user() | 319 self.log_user() |
330 | 320 |
331 _fork_repo(HG_FORK, 'hg') | 321 repo2 = _fork_repo(HG_FORK, 'hg') |
332 | 322 self.r2_id = repo2.repo_id |
333 rev1 = '56349e29c2af' | 323 rev1 = '56349e29c2af' |
334 rev2 = '7d4bc8ec6be5' | 324 rev2 = '7d4bc8ec6be5' |
335 | 325 |
336 response = self.app.get(url(controller='compare', action='index', | 326 response = self.app.get(url(controller='compare', action='index', |
337 repo_name=HG_REPO, | 327 repo_name=HG_REPO, |