# HG changeset patch # User Mads Kiilerich # Date 2013-02-28 16:54:42 # Node ID b3680a200f756b789a81203bb500c3974f9b321a # Parent c4bb2b22110ed5f357063b19f53483d7b8367392 compare: cleanup of as_form handling as_form is only used when loaded 'partial' from pullrequest.html. Including it in the 'Detailed compare view' url did thus not do any harm. as_form is never used in pullrequest_show.html or compare_diff.html and it is thus never used together with swap_url ... which is why the wrong 'as_form=None' or 'as_form=False' in urls didn't do any harm. diff --git a/rhodecode/controllers/compare.py b/rhodecode/controllers/compare.py --- a/rhodecode/controllers/compare.py +++ b/rhodecode/controllers/compare.py @@ -91,15 +91,17 @@ class CompareController(BaseRepoControll c.fulldiff = fulldiff = request.GET.get('fulldiff') rev_start = request.GET.get('rev_start') rev_end = request.GET.get('rev_end') - - c.swap_url = h.url('compare_url', as_form=request.GET.get('as_form'), + # partial uses compare_cs.html template directly + partial = request.environ.get('HTTP_X_PARTIAL_XHR') + # as_form puts hidden input field with changeset revisions + c.as_form = partial and request.GET.get('as_form') + # swap url for compare_diff page - never partial and never as_form + c.swap_url = h.url('compare_url', repo_name=other_repo, org_ref_type=other_ref[0], org_ref=other_ref[1], other_repo=org_repo, other_ref_type=org_ref[0], other_ref=org_ref[1]) - partial = request.environ.get('HTTP_X_PARTIAL_XHR') - org_repo = Repository.get_by_repo_name(org_repo) other_repo = Repository.get_by_repo_name(other_repo) @@ -148,8 +150,6 @@ class CompareController(BaseRepoControll c.statuses = c.rhodecode_db_repo.statuses([x.raw_id for x in c.cs_ranges]) - # defines that we need hidden inputs with changesets - c.as_form = request.GET.get('as_form', False) if partial: return render('compare/compare_cs.html') diff --git a/rhodecode/controllers/pullrequests.py b/rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py +++ b/rhodecode/controllers/pullrequests.py @@ -291,8 +291,6 @@ class PullrequestsController(BaseRepoCon else EmptyChangeset(), 'raw_id')) c.statuses = org_repo.statuses([x.raw_id for x in c.cs_ranges]) - # defines that we need hidden inputs with changesets - c.as_form = request.GET.get('as_form', False) c.org_ref = org_ref[1] c.org_ref_type = org_ref[0] @@ -391,6 +389,7 @@ class PullrequestsController(BaseRepoCon ) c.changeset_statuses = ChangesetStatus.STATUSES + c.as_form = False return render('/pullrequests/pullrequest_show.html') @NotAnonymous() 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 @@ -120,7 +120,7 @@ class TestCompareController(TestControll ## files response.mustcontain("""file1""" % (repo1.repo_name, rev2, rev1, repo2.repo_name)) #swap - response.mustcontain("""[swap]""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) + response.mustcontain("""[swap]""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self): self.log_user() @@ -173,7 +173,7 @@ class TestCompareController(TestControll ## files response.mustcontain("""file1""" % (repo1.repo_name, rev2, rev1, repo2.repo_name)) #swap - response.mustcontain("""[swap]""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) + response.mustcontain("""[swap]""" % (repo2.repo_name, rev1, rev2, repo1.repo_name)) def test_compare_cherry_pick_changesets_from_bottom(self):