compare: using f_path shouldn't generate full range of commits.

- in case of comparing just 1 file the range of commits is not relevant.
This in addition speeds rendering the compare page by a LOT.
This commit is contained in:
Marcin Kuzminski 2016-12-23 17:39:32 +01:00
parent 62db642312
commit 8a081ac5db

View file

@ -183,21 +183,28 @@ class CompareController(BaseRepoController):
pre_load = ["author", "branch", "date", "message"]
c.ancestor = None
try:
c.commit_ranges = source_scm.compare(
source_commit.raw_id, target_commit.raw_id,
target_scm, merge, pre_load=pre_load)
if merge:
c.ancestor = source_scm.get_common_ancestor(
source_commit.raw_id, target_commit.raw_id, target_scm)
except RepositoryRequirementError:
msg = _('Could not compare repos with different '
'large file settings')
log.error(msg)
if partial:
return msg
h.flash(msg, category='error')
return redirect(url('compare_home', repo_name=c.repo_name))
if c.file_path:
if source_commit == target_commit:
c.commit_ranges = []
else:
c.commit_ranges = [target_commit]
else:
try:
c.commit_ranges = source_scm.compare(
source_commit.raw_id, target_commit.raw_id,
target_scm, merge, pre_load=pre_load)
if merge:
c.ancestor = source_scm.get_common_ancestor(
source_commit.raw_id, target_commit.raw_id, target_scm)
except RepositoryRequirementError:
msg = _('Could not compare repos with different '
'large file settings')
log.error(msg)
if partial:
return msg
h.flash(msg, category='error')
return redirect(url('compare_home', repo_name=c.repo_name))
c.statuses = c.rhodecode_db_repo.statuses(
[x.raw_id for x in c.commit_ranges])