diff --git a/rhodecode/tests/functional/test_compare.py b/rhodecode/tests/functional/test_compare.py --- a/rhodecode/tests/functional/test_compare.py +++ b/rhodecode/tests/functional/test_compare.py @@ -8,10 +8,10 @@ from rhodecode.lib.vcs.backends.base imp class TestCompareController(TestController): - def test_index_tag(self): + def test_compare_tag_hg(self): self.log_user() - tag1 = '0.1.3' - tag2 = '0.1.2' + tag1 = '0.1.2' + tag2 = '0.1.3' response = self.app.get(url(controller='compare', action='index', repo_name=HG_REPO, org_ref_type="tag", @@ -21,13 +21,13 @@ class TestCompareController(TestControll )) response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, tag1, HG_REPO, tag2)) ## outgoing changesets between tags - response.mustcontain('''r120:17544fbfcd33''' % HG_REPO) - response.mustcontain('''r119:36e0fc9d2808''' % HG_REPO) - response.mustcontain('''r118:bb1a3ab98cc4''' % HG_REPO) + response.mustcontain('''r112:c5ddebc06eaa''' % HG_REPO) + response.mustcontain('''r115:70d4cef8a376''' % HG_REPO) + response.mustcontain('''r116:9749bfbfc0d2''' % HG_REPO) response.mustcontain('''r117:41fda979f02f''' % HG_REPO) - response.mustcontain('''r116:9749bfbfc0d2''' % HG_REPO) - response.mustcontain('''r115:70d4cef8a376''' % HG_REPO) - response.mustcontain('''r112:c5ddebc06eaa''' % HG_REPO) + response.mustcontain('''r118:bb1a3ab98cc4''' % HG_REPO) + response.mustcontain('''r119:36e0fc9d2808''' % HG_REPO) + response.mustcontain('''r120:17544fbfcd33''' % HG_REPO) ## files diff response.mustcontain('''
docs/api/utils/index.rst
''' % (HG_REPO, tag1, tag2)) @@ -42,7 +42,43 @@ class TestCompareController(TestControll response.mustcontain('''
vcs/utils/diffs.py
''' % (HG_REPO, tag1, tag2)) response.mustcontain('''
vcs/utils/lazy.py
''' % (HG_REPO, tag1, tag2)) - def test_index_branch(self): + def test_compare_tag_git(self): + self.log_user() + tag1 = 'v0.1.2' + tag2 = 'v0.1.3' + response = self.app.get(url(controller='compare', action='index', + repo_name=GIT_REPO, + org_ref_type="tag", + org_ref=tag1, + other_ref_type="tag", + other_ref=tag2, + bundle=False + )) + response.mustcontain('%s@%s -> %s@%s' % (GIT_REPO, tag1, GIT_REPO, tag2)) + + ## outgoing changesets between tags + response.mustcontain('''r113:794bbdd31545''' % GIT_REPO) + response.mustcontain('''r115:e36d8c502532''' % GIT_REPO) + response.mustcontain('''r116:5c9ff4f6d750''' % GIT_REPO) + response.mustcontain('''r117:b7187fa2b8c1''' % GIT_REPO) + response.mustcontain('''r118:5f3b74262014''' % GIT_REPO) + response.mustcontain('''r119:17438a11f72b''' % GIT_REPO) + response.mustcontain('''r120:5a3a8fb00555''' % GIT_REPO) + + #files + response.mustcontain('''docs/api/utils/index.rst''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''test_and_report.sh''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''.hgignore''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''.hgtags''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''docs/api/index.rst''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''vcs/__init__.py''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''vcs/backends/hg.py''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''vcs/utils/__init__.py''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''vcs/utils/annotate.py''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''vcs/utils/diffs.py''' % (GIT_REPO, tag1, tag2)) + response.mustcontain('''vcs/utils/lazy.py''' % (GIT_REPO, tag1, tag2)) + + def test_index_branch_hg(self): self.log_user() response = self.app.get(url(controller='compare', action='index', repo_name=HG_REPO, @@ -54,12 +90,29 @@ class TestCompareController(TestControll response.mustcontain('%s@default -> %s@default' % (HG_REPO, HG_REPO)) # branch are equal - response.mustcontain('No changesets') + response.mustcontain('No files') + response.mustcontain('No changesets') + + def test_index_branch_git(self): + self.log_user() + response = self.app.get(url(controller='compare', action='index', + repo_name=GIT_REPO, + org_ref_type="branch", + org_ref='master', + other_ref_type="branch", + other_ref='master', + )) + + response.mustcontain('%s@master -> %s@master' % (GIT_REPO, GIT_REPO)) + # branch are equal + response.mustcontain('No files') + response.mustcontain('No changesets') def test_compare_revisions(self): self.log_user() - rev1 = '3d8f361e72ab' - rev2 = 'b986218ba1c9' + rev1 = 'b986218ba1c9' + rev2 = '3d8f361e72ab' + response = self.app.get(url(controller='compare', action='index', repo_name=HG_REPO, org_ref_type="rev", @@ -69,8 +122,7 @@ class TestCompareController(TestControll )) response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2)) ## outgoing changesets between those revisions - response.mustcontain("""r1:%s""" % (HG_REPO, rev1)) - + response.mustcontain("""r1:%s""" % (HG_REPO, rev2)) ## files response.mustcontain(""".hgignore""" % (HG_REPO, rev1, rev2)) @@ -93,8 +145,54 @@ class TestCompareController(TestControll Session().commit() - rev1 = '7d4bc8ec6be5' - rev2 = '56349e29c2af' + rev1 = '56349e29c2af' + rev2 = '7d4bc8ec6be5' + + response = self.app.get(url(controller='compare', action='index', + repo_name=HG_REPO, + org_ref_type="rev", + org_ref=rev1, + other_ref_type="rev", + other_ref=rev2, + repo=HG_FORK, + )) + + try: + response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) + ## outgoing changesets between those revisions + + response.mustcontain("""r4:2dda4e345fac""" % (HG_REPO)) + response.mustcontain("""r5:6fff84722075""" % (HG_REPO)) + response.mustcontain("""r6:%s""" % (HG_REPO, rev2)) + + ## files + response.mustcontain("""vcs/backends/hg.py""" % (HG_REPO, rev1, rev2)) + response.mustcontain("""vcs/backends/__init__.py""" % (HG_REPO, rev1, rev2)) + response.mustcontain("""vcs/backends/base.py""" % (HG_REPO, rev1, rev2)) + finally: + RepoModel().delete(HG_FORK) + + def test_compare_remote_repos_remote_flag_off(self): + self.log_user() + + form_data = dict( + repo_name=HG_FORK, + repo_name_full=HG_FORK, + repo_group=None, + repo_type='hg', + description='', + private=False, + copy_permissions=False, + landing_rev='tip', + update_after_clone=False, + fork_parent_id=Repository.get_by_repo_name(HG_REPO), + ) + RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) + + Session().commit() + + rev1 = '56349e29c2af' + rev2 = '7d4bc8ec6be5' response = self.app.get(url(controller='compare', action='index', repo_name=HG_REPO, @@ -102,16 +200,17 @@ class TestCompareController(TestControll org_ref=rev1, other_ref_type="rev", other_ref=rev2, - repo=HG_FORK + repo=HG_FORK, + bundle=False, )) try: response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_FORK, rev2)) ## outgoing changesets between those revisions - response.mustcontain("""r6:%s""" % (HG_REPO, rev1)) + response.mustcontain("""r4:2dda4e345fac""" % (HG_REPO)) response.mustcontain("""r5:6fff84722075""" % (HG_REPO)) - response.mustcontain("""r4:2dda4e345fac""" % (HG_REPO)) + response.mustcontain("""r6:%s""" % (HG_REPO, rev2)) ## files response.mustcontain("""vcs/backends/hg.py""" % (HG_REPO, rev1, rev2)) @@ -120,6 +219,67 @@ class TestCompareController(TestControll finally: RepoModel().delete(HG_FORK) +# def test_compare_origin_ahead_of_fork(self): +# self.log_user() +# +# form_data = dict( +# repo_name=HG_FORK, +# repo_name_full=HG_FORK, +# repo_group=None, +# repo_type='hg', +# description='', +# private=False, +# copy_permissions=False, +# landing_rev='tip', +# update_after_clone=False, +# fork_parent_id=Repository.get_by_repo_name(HG_REPO), +# ) +# RepoModel().create_fork(form_data, cur_user=TEST_USER_ADMIN_LOGIN) +# +# Session().commit() +# +# repo1 = Repository.get_by_repo_name(HG_REPO) +# r1_name = HG_REPO +# +# #commit something ! +# cs0 = ScmModel().create_node( +# repo=repo1.scm_instance, repo_name=r1_name, +# cs=EmptyChangeset(alias='hg'), user=TEST_USER_ADMIN_LOGIN, +# author=TEST_USER_ADMIN_LOGIN, +# message='extra commit1', +# content='line1', +# f_path='file1' +# ) +# +# +# rev1 = '56349e29c2af' +# rev2 = '7d4bc8ec6be5' +# +# response = self.app.get(url(controller='compare', action='index', +# repo_name=HG_REPO, +# org_ref_type="rev", +# org_ref=rev1, +# other_ref_type="rev", +# other_ref=rev2, +# repo=HG_FORK, +# bundle=False, +# )) +# +# try: +# response.mustcontain('%s@%s -> %s@%s' % (HG_REPO, rev1, HG_REPO, rev2)) +# ## outgoing changesets between those revisions +# +# response.mustcontain("""r4:2dda4e345fac""" % (HG_REPO)) +# response.mustcontain("""r5:6fff84722075""" % (HG_REPO)) +# response.mustcontain("""r6:%s""" % (HG_REPO, rev2)) +# +# ## files +# response.mustcontain("""vcs/backends/hg.py""" % (HG_REPO, rev1, rev2)) +# response.mustcontain("""vcs/backends/__init__.py""" % (HG_REPO, rev1, rev2)) +# response.mustcontain("""vcs/backends/base.py""" % (HG_REPO, rev1, rev2)) +# finally: +# RepoModel().delete(HG_FORK) + def test_compare_extra_commits(self): self.log_user() @@ -178,7 +338,7 @@ class TestCompareController(TestControll try: response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) - response.mustcontain("""
commit2
""") + response.mustcontain("""
commit2
""") response.mustcontain("""r1:%s""" % (r2_name, cs1.raw_id, cs1.short_id)) ## files response.mustcontain("""file1""" % (r2_name, rev1, rev2)) @@ -391,7 +551,7 @@ class TestCompareController(TestControll repo=r1_name, bundle=False )) - rev2 = cs0.parents[0].raw_id + response.mustcontain('%s@%s -> %s@%s' % (r2_name, rev1, r1_name, rev2)) response.mustcontain("""file1-line1-from-fork""") response.mustcontain("""file2-line1-from-fork""")