Changeset - ded49765b47a
[Not reviewed]
default
0 1 0
Mads Kiilerich - 11 years ago 2015-01-06 00:54:36
madski@unity3d.com
pullrequests: drop expensive listing of unrelated changesets that cannot be used for update

It rarely gave any relevant info and could take several seconds to compute.

Instead, just warn if the branch name has another head.

Loading a pullrequest page on a slow repo did in one setup go from 7 s to 3.5 s.
1 file changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
kallithea/controllers/pullrequests.py
Show inline comments
 
@@ -575,47 +575,47 @@ class PullrequestsController(BaseRepoCon
 
        other_scm_instance = c.a_repo.scm_instance
 
        c.update_msg = ""
 
        c.update_msg_other = ""
 
        if org_scm_instance.alias == 'hg' and c.a_ref_name != 'ancestor':
 
            if c.cs_ref_type != 'branch':
 
                c.cs_branch_name = org_scm_instance.get_changeset(c.cs_ref_name).branch # use ref_type ?
 
            c.a_branch_name = c.a_ref_name
 
            if c.a_ref_type != 'branch':
 
                try:
 
                    c.a_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ?
 
                except EmptyRepositoryError:
 
                    c.a_branch_name = 'null' # not a branch name ... but close enough
 
            arevs = []
 
            # candidates: descendants of old head that are on the right branch
 
            #             and not are the old head itself ...
 
            #             and nothing at all if old head is a descendent of target ref name
 
            if other_scm_instance._repo.revs('present(%s)::&%s', c.cs_ranges[-1].raw_id, c.a_branch_name):
 
                c.update_msg = _('This pull request has already been merged to %s.') % c.a_branch_name
 
            else: # look for children of PR head on source branch in org repo
 
                arevs = org_scm_instance._repo.revs('%s:: & branch(%s) - %s',
 
                                                    revs[0], c.cs_branch_name, revs[0])
 
                if arevs:
 
                    if c.pull_request.is_closed():
 
                        c.update_msg = _('This pull request has been closed and can not be updated with descendent changes on %s:') % c.cs_branch_name
 
                    else:
 
                        c.update_msg = _('This pull request can be updated with descendent changes on %s:') % c.cs_branch_name
 
                    c.available = [org_scm_instance.get_changeset(x) for x in arevs]
 
                else:
 
                    c.update_msg = _('No changesets found for updating this pull request.')
 

	
 
            revs = org_scm_instance._repo.revs('head() & not (%s::) & branch(%s) & !closed()', revs[0], c.cs_branch_name)
 
            if revs:
 
                c.update_msg_other = _('Note: Branch %s also contains unrelated changes, such as %s.') % (c.cs_branch_name,
 
                    h.short_id(org_scm_instance.get_changeset((max(revs))).raw_id))
 
            else:
 
                c.update_msg_other = _('Branch %s does not contain other changes.') % c.cs_branch_name
 
            brevs = org_scm_instance._repo.revs('%s - %d - %ld', c.cs_branch_name, revs[0], arevs)
 
            if brevs:
 
                c.update_msg_other = _('Note: Branch %s has another head: %s.') % (c.cs_branch_name,
 
                    h.short_id(org_scm_instance.get_changeset((max(brevs))).raw_id))
 

	
 
        elif org_scm_instance.alias == 'git':
 
            c.update_msg = _("Git pull requests don't support updates yet.")
 

	
 
        raw_ids = [x.raw_id for x in c.cs_ranges]
 
        c.cs_comments = c.cs_repo.get_comments(raw_ids)
 
        c.statuses = c.cs_repo.statuses(raw_ids)
 

	
 
        ignore_whitespace = request.GET.get('ignorews') == '1'
 
        line_context = request.GET.get('context', 3)
 
        c.ignorews_url = _ignorews_url
 
        c.context_url = _context_url
 
        c.fulldiff = request.GET.get('fulldiff')
0 comments (0 inline, 0 general)