changeset 4325:cdb2b5ac95e6

pull requests: work around expensive hidden scm_instance property getter for get_changeset in hot spots
author Mads Kiilerich <madski@unity3d.com>
date Tue, 10 Dec 2013 19:30:37 +0100
parents 494eab6ec837
children fb3b45acd172
files kallithea/controllers/pullrequests.py
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/kallithea/controllers/pullrequests.py	Fri Jul 04 14:12:06 2014 +0200
+++ b/kallithea/controllers/pullrequests.py	Tue Dec 10 19:30:37 2013 +0100
@@ -197,7 +197,8 @@
          c.other_ref_name,
          c.other_rev) = pull_request.other_ref.split(':')
 
-        c.cs_ranges = [c.org_repo.get_changeset(x) for x in pull_request.revisions]
+        org_scm_instance = c.org_repo.scm_instance # property with expensive cache invalidation check!!!
+        c.cs_ranges = [org_scm_instance.get_changeset(x) for x in pull_request.revisions]
         c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ...
 
         c.statuses = c.org_repo.statuses([x.raw_id for x in c.cs_ranges])
@@ -211,8 +212,8 @@
 
         # we swap org/other ref since we run a simple diff on one repo
         log.debug('running diff between %s and %s in %s'
-                  % (c.other_rev, c.org_rev, c.org_repo.scm_instance.path))
-        txtdiff = c.org_repo.scm_instance.get_diff(rev1=safe_str(c.other_rev), rev2=safe_str(c.org_rev),
+                  % (c.other_rev, c.org_rev, org_scm_instance.path))
+        txtdiff = org_scm_instance.get_diff(rev1=safe_str(c.other_rev), rev2=safe_str(c.org_rev),
                                       ignore_whitespace=ignore_whitespace,
                                       context=line_context)