Show More
@@ -39,6 +39,7 b' from rhodecode.lib import diffs' | |||||
39 |
|
39 | |||
40 | from rhodecode.model.db import Repository |
|
40 | from rhodecode.model.db import Repository | |
41 | from rhodecode.model.pull_request import PullRequestModel |
|
41 | from rhodecode.model.pull_request import PullRequestModel | |
|
42 | from webob.exc import HTTPBadRequest | |||
42 |
|
43 | |||
43 | log = logging.getLogger(__name__) |
|
44 | log = logging.getLogger(__name__) | |
44 |
|
45 | |||
@@ -51,10 +52,12 b' class CompareController(BaseRepoControll' | |||||
51 | def __before__(self): |
|
52 | def __before__(self): | |
52 | super(CompareController, self).__before__() |
|
53 | super(CompareController, self).__before__() | |
53 |
|
54 | |||
54 |
def __get_cs_or_redirect(self, rev, repo, redirect_after=True |
|
55 | def __get_cs_or_redirect(self, rev, repo, redirect_after=True, | |
|
56 | partial=False): | |||
55 | """ |
|
57 | """ | |
56 | Safe way to get changeset if error occur it redirects to changeset with |
|
58 | Safe way to get changeset if error occur it redirects to changeset with | |
57 | proper message |
|
59 | proper message. If partial is set then don't do redirect raise Exception | |
|
60 | instead | |||
58 |
|
61 | |||
59 | :param rev: revision to fetch |
|
62 | :param rev: revision to fetch | |
60 | :param repo: repo instance |
|
63 | :param repo: repo instance | |
@@ -73,7 +76,9 b' class CompareController(BaseRepoControll' | |||||
73 | except RepositoryError, e: |
|
76 | except RepositoryError, e: | |
74 | log.error(traceback.format_exc()) |
|
77 | log.error(traceback.format_exc()) | |
75 | h.flash(str(e), category='warning') |
|
78 | h.flash(str(e), category='warning') | |
76 | redirect(h.url('summary_home', repo_name=repo.repo_name)) |
|
79 | if not partial: | |
|
80 | redirect(h.url('summary_home', repo_name=repo.repo_name)) | |||
|
81 | raise HTTPBadRequest() | |||
77 |
|
82 | |||
78 | def index(self, org_ref_type, org_ref, other_ref_type, other_ref): |
|
83 | def index(self, org_ref_type, org_ref, other_ref_type, other_ref): | |
79 |
|
84 | |||
@@ -97,9 +102,9 b' class CompareController(BaseRepoControll' | |||||
97 | if c.org_repo.scm_instance.alias != 'hg': |
|
102 | if c.org_repo.scm_instance.alias != 'hg': | |
98 | log.error('Review not available for GIT REPOS') |
|
103 | log.error('Review not available for GIT REPOS') | |
99 | raise HTTPNotFound |
|
104 | raise HTTPNotFound | |
100 |
|
105 | partial = request.environ.get('HTTP_X_PARTIAL_XHR') | ||
101 | self.__get_cs_or_redirect(rev=org_ref, repo=org_repo) |
|
106 | self.__get_cs_or_redirect(rev=org_ref, repo=org_repo, partial=partial) | |
102 | self.__get_cs_or_redirect(rev=other_ref, repo=other_repo) |
|
107 | self.__get_cs_or_redirect(rev=other_ref, repo=other_repo, partial=partial) | |
103 |
|
108 | |||
104 | c.cs_ranges, discovery_data = PullRequestModel().get_compare_data( |
|
109 | c.cs_ranges, discovery_data = PullRequestModel().get_compare_data( | |
105 | org_repo, org_ref, other_repo, other_ref |
|
110 | org_repo, org_ref, other_repo, other_ref | |
@@ -110,7 +115,7 b' class CompareController(BaseRepoControll' | |||||
110 | c.target_repo = c.repo_name |
|
115 | c.target_repo = c.repo_name | |
111 | # defines that we need hidden inputs with changesets |
|
116 | # defines that we need hidden inputs with changesets | |
112 | c.as_form = request.GET.get('as_form', False) |
|
117 | c.as_form = request.GET.get('as_form', False) | |
113 | if request.environ.get('HTTP_X_PARTIAL_XHR'): |
|
118 | if partial: | |
114 | return render('compare/compare_cs.html') |
|
119 | return render('compare/compare_cs.html') | |
115 |
|
120 | |||
116 | c.org_ref = org_ref[1] |
|
121 | c.org_ref = org_ref[1] |
@@ -135,6 +135,7 b'' | |||||
135 | PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA); |
|
135 | PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA); | |
136 |
|
136 | |||
137 | var other_repos_info = ${c.other_repos_info|n}; |
|
137 | var other_repos_info = ${c.other_repos_info|n}; | |
|
138 | ||||
138 | var loadPreview = function(){ |
|
139 | var loadPreview = function(){ | |
139 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none'); |
|
140 | YUD.setStyle(YUD.get('pull_request_overview_url').parentElement,'display','none'); | |
140 | var url = "${h.url('compare_url', |
|
141 | var url = "${h.url('compare_url', | |
@@ -167,6 +168,12 b'' | |||||
167 | } |
|
168 | } | |
168 | } |
|
169 | } | |
169 |
|
170 | |||
|
171 | YUE.on('other_repo', 'change', function(e){ | |||
|
172 | var repo_name = e.currentTarget.value; | |||
|
173 | // replace the <select> of changed repo | |||
|
174 | YUD.get('other_ref').innerHTML = other_repos_info[repo_name]['revs']; | |||
|
175 | }); | |||
|
176 | ||||
170 | ypjax(url,'pull_request_overview', function(data){ |
|
177 | ypjax(url,'pull_request_overview', function(data){ | |
171 | var sel_box = YUQ('#pull_request_form #other_repo')[0]; |
|
178 | var sel_box = YUQ('#pull_request_form #other_repo')[0]; | |
172 | var repo_name = sel_box.options[sel_box.selectedIndex].value; |
|
179 | var repo_name = sel_box.options[sel_box.selectedIndex].value; |
General Comments 0
You need to be logged in to leave comments.
Login now