changeset 3442:b3680a200f75 beta

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.
author Mads Kiilerich <madski@unity3d.com>
date Thu, 28 Feb 2013 17:54:42 +0100
parents c4bb2b22110e
children 3ac76dfdab8e
files rhodecode/controllers/compare.py rhodecode/controllers/pullrequests.py rhodecode/tests/functional/test_compare.py
diffstat 3 files changed, 9 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/rhodecode/controllers/compare.py	Thu Feb 28 23:21:46 2013 +0100
+++ b/rhodecode/controllers/compare.py	Thu Feb 28 17:54:42 2013 +0100
@@ -91,15 +91,17 @@
         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 @@
 
         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')
 
--- a/rhodecode/controllers/pullrequests.py	Thu Feb 28 23:21:46 2013 +0100
+++ b/rhodecode/controllers/pullrequests.py	Thu Feb 28 17:54:42 2013 +0100
@@ -291,8 +291,6 @@
                                   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 @@
                                          )
         c.changeset_statuses = ChangesetStatus.STATUSES
 
+        c.as_form = False
         return render('/pullrequests/pullrequest_show.html')
 
     @NotAnonymous()
--- a/rhodecode/tests/functional/test_compare.py	Thu Feb 28 23:21:46 2013 +0100
+++ b/rhodecode/tests/functional/test_compare.py	Thu Feb 28 17:54:42 2013 +0100
@@ -120,7 +120,7 @@
         ## files
         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))
         #swap
-        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))
+        response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s">[swap]</a>""" % (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 @@
         ## files
         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))
         #swap
-        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))
+        response.mustcontain("""<a href="/%s/compare/branch@%s...branch@%s?other_repo=%s">[swap]</a>""" % (repo2.repo_name, rev1, rev2, repo1.repo_name))
 
     def test_compare_cherry_pick_changesets_from_bottom(self):