diff --git a/kallithea/controllers/compare.py b/kallithea/controllers/compare.py --- a/kallithea/controllers/compare.py +++ b/kallithea/controllers/compare.py @@ -149,9 +149,9 @@ class CompareController(BaseRepoControll c.compare_home = True org_repo = c.db_repo.repo_name other_repo = request.GET.get('other_repo', org_repo) - c.org_repo = Repository.get_by_repo_name(org_repo) - c.other_repo = Repository.get_by_repo_name(other_repo) - c.org_ref_name = c.other_ref_name = _('Select changeset') + c.a_repo = Repository.get_by_repo_name(org_repo) + c.cs_repo = Repository.get_by_repo_name(other_repo) + c.a_ref_name = c.cs_ref_name = _('Select changeset') return render('compare/compare_diff.html') @LoginRequired() @@ -210,27 +210,27 @@ class CompareController(BaseRepoControll h.flash(msg, category='error') return redirect(url('compare_home', repo_name=c.repo_name)) - c.org_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name) - c.other_rev = self._get_ref_rev(other_repo, other_ref_type, other_ref_name) + c.a_rev = self._get_ref_rev(org_repo, org_ref_type, org_ref_name) + c.cs_rev = self._get_ref_rev(other_repo, other_ref_type, other_ref_name) c.compare_home = False - c.org_repo = org_repo - c.other_repo = other_repo - c.org_ref_name = org_ref_name - c.other_ref_name = other_ref_name - c.org_ref_type = org_ref_type - c.other_ref_type = other_ref_type + c.a_repo = org_repo + c.cs_repo = other_repo + c.a_ref_name = org_ref_name + c.cs_ref_name = other_ref_name + c.a_ref_type = org_ref_type + c.cs_ref_type = other_ref_type c.cs_repo = other_repo c.cs_ranges, c.cs_ranges_org, c.ancestor = self._get_changesets( - org_repo.scm_instance.alias, org_repo.scm_instance, c.org_rev, - other_repo.scm_instance, c.other_rev) + org_repo.scm_instance.alias, org_repo.scm_instance, c.a_rev, + other_repo.scm_instance, c.cs_rev) raw_ids = [x.raw_id for x in c.cs_ranges] c.cs_comments = other_repo.get_comments(raw_ids) c.statuses = other_repo.statuses(raw_ids) revs = [ctx.revision for ctx in reversed(c.cs_ranges)] - c.jsdata = json.dumps(graph_data(c.other_repo.scm_instance, revs)) + c.jsdata = json.dumps(graph_data(c.cs_repo.scm_instance, revs)) if partial: return render('compare/compare_cs.html') @@ -239,7 +239,7 @@ class CompareController(BaseRepoControll # previewing what will be merged. # Make the diff on the other repo (which is known to have other_rev) log.debug('Using ancestor %s as rev1 instead of %s' - % (c.ancestor, c.org_rev)) + % (c.ancestor, c.a_rev)) rev1 = c.ancestor org_repo = other_repo else: # comparing tips, not necessarily linearly related @@ -250,13 +250,13 @@ class CompareController(BaseRepoControll log.error('cannot compare across repos %s and %s', org_repo, other_repo) h.flash(_('Cannot compare repositories without using common ancestor'), category='error') raise HTTPBadRequest - rev1 = c.org_rev + rev1 = c.a_rev diff_limit = self.cut_off_limit if not c.fulldiff else None log.debug('running diff between %s and %s in %s' - % (rev1, c.other_rev, org_repo.scm_instance.path)) - txtdiff = org_repo.scm_instance.get_diff(rev1=rev1, rev2=c.other_rev, + % (rev1, c.cs_rev, org_repo.scm_instance.path)) + txtdiff = org_repo.scm_instance.get_diff(rev1=rev1, rev2=c.cs_rev, ignore_whitespace=ignore_whitespace, context=line_context) diff --git a/kallithea/controllers/pullrequests.py b/kallithea/controllers/pullrequests.py --- a/kallithea/controllers/pullrequests.py +++ b/kallithea/controllers/pullrequests.py @@ -259,26 +259,26 @@ class PullrequestsController(BaseRepoCon #other_rev = request.POST.get('rev_start') branch = request.GET.get('branch') - c.org_repos = [(org_repo.repo_name, org_repo.repo_name)] - c.default_org_repo = org_repo.repo_name - c.org_refs, c.default_org_ref = self._get_repo_refs(org_scm_instance, rev=org_rev, branch=branch) + c.cs_repos = [(org_repo.repo_name, org_repo.repo_name)] + c.default_cs_repo = org_repo.repo_name + c.cs_refs, c.default_cs_ref = self._get_repo_refs(org_scm_instance, rev=org_rev, branch=branch) # add org repo to other so we can open pull request against peer branches on itself - c.other_repos = [(org_repo.repo_name, '%s (self)' % org_repo.repo_name)] + c.a_repos = [(org_repo.repo_name, '%s (self)' % org_repo.repo_name)] # add parent of this fork also and select it if org_repo.parent: - c.other_repos.append((org_repo.parent.repo_name, '%s (parent)' % org_repo.parent.repo_name)) - c.other_repo = org_repo.parent - c.other_refs, c.default_other_ref = self._get_repo_refs(org_repo.parent.scm_instance) + c.a_repos.append((org_repo.parent.repo_name, '%s (parent)' % org_repo.parent.repo_name)) + c.a_repo = org_repo.parent + c.a_refs, c.default_a_ref = self._get_repo_refs(org_repo.parent.scm_instance) else: - c.other_repo = org_repo - c.other_refs, c.default_other_ref = self._get_repo_refs(org_scm_instance) # without rev and branch + c.a_repo = org_repo + c.a_refs, c.default_a_ref = self._get_repo_refs(org_scm_instance) # without rev and branch # gather forks and add to this list ... even though it is rare to # request forks to pull from their parent for fork in org_repo.forks: - c.other_repos.append((fork.repo_name, fork.repo_name)) + c.a_repos.append((fork.repo_name, fork.repo_name)) return render('/pullrequests/pullrequest.html') @@ -553,32 +553,32 @@ class PullrequestsController(BaseRepoCon raise HTTPNotFound # load compare data into template context - c.org_repo = c.pull_request.org_repo - (c.org_ref_type, - c.org_ref_name, - c.org_rev) = c.pull_request.org_ref.split(':') + c.cs_repo = c.pull_request.org_repo + (c.cs_ref_type, + c.cs_ref_name, + c.cs_rev) = c.pull_request.org_ref.split(':') - c.other_repo = c.pull_request.other_repo - (c.other_ref_type, - c.other_ref_name, - c.other_rev) = c.pull_request.other_ref.split(':') # other_rev is ancestor + c.a_repo = c.pull_request.other_repo + (c.a_ref_type, + c.a_ref_name, + c.a_rev) = c.pull_request.other_ref.split(':') # other_rev is ancestor - org_scm_instance = c.org_repo.scm_instance # property with expensive cache invalidation check!!! - c.cs_repo = c.org_repo + org_scm_instance = c.cs_repo.scm_instance # property with expensive cache invalidation check!!! + c.cs_repo = c.cs_repo c.cs_ranges = [org_scm_instance.get_changeset(x) for x in c.pull_request.revisions] c.cs_ranges_org = None # not stored and not important and moving target - could be calculated ... revs = [ctx.revision for ctx in reversed(c.cs_ranges)] c.jsdata = json.dumps(graph_data(org_scm_instance, revs)) c.available = [] - c.org_branch_name = c.org_ref_name - other_scm_instance = c.other_repo.scm_instance - if org_scm_instance.alias == 'hg' and c.other_ref_name != 'ancestor': - if c.org_ref_type != 'branch': - c.org_branch_name = org_scm_instance.get_changeset(c.org_ref_name).branch # use ref_type ? - other_branch_name = c.other_ref_name - if c.other_ref_type != 'branch': - other_branch_name = other_scm_instance.get_changeset(c.other_ref_name).branch # use ref_type ? + c.cs_branch_name = c.cs_ref_name + other_scm_instance = c.a_repo.scm_instance + 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 ? + other_branch_name = c.a_ref_name + if c.a_ref_type != 'branch': + other_branch_name = other_scm_instance.get_changeset(c.a_ref_name).branch # use ref_type ? # 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 @@ -586,26 +586,26 @@ class PullrequestsController(BaseRepoCon c.update_msg = _('This pull request has already been merged to %s.') % other_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.org_branch_name, revs[0]) + 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.org_branch_name + 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.org_branch_name + 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.org_branch_name) + 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.org_branch_name, + 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.org_branch_name + c.update_msg_other = _('Branch %s does not contain other changes.') % c.cs_branch_name raw_ids = [x.raw_id for x in c.cs_ranges] - c.cs_comments = c.org_repo.get_comments(raw_ids) - c.statuses = c.org_repo.statuses(raw_ids) + 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) @@ -616,8 +616,8 @@ class PullrequestsController(BaseRepoCon # 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, org_scm_instance.path)) - txtdiff = org_scm_instance.get_diff(rev1=safe_str(c.other_rev), rev2=safe_str(c.org_rev), + % (c.a_rev, c.cs_rev, org_scm_instance.path)) + txtdiff = org_scm_instance.get_diff(rev1=safe_str(c.a_rev), rev2=safe_str(c.cs_rev), ignore_whitespace=ignore_whitespace, context=line_context) diff --git a/kallithea/templates/changeset/diff_block.html b/kallithea/templates/changeset/diff_block.html --- a/kallithea/templates/changeset/diff_block.html +++ b/kallithea/templates/changeset/diff_block.html @@ -78,20 +78,20 @@ ## TODO: link to ancestor and head of other instead of exactly other %if op == 'A': ${_('Added')} - ${h.short_id(c.org_ref_name) if c.org_ref_type=='rev' else c.org_ref_name} + ${h.short_id(c.cs_ref_name) if c.cs_ref_type=='rev' else c.cs_ref_name} %elif op == 'M': - ${h.short_id(c.org_ref_name) if c.org_ref_type=='rev' else c.org_ref_name} + ${h.short_id(c.cs_ref_name) if c.cs_ref_type=='rev' else c.cs_ref_name} - ${h.short_id(c.other_ref_name) if c.other_ref_type=='rev' else c.other_ref_name} + ${h.short_id(c.a_ref_name) if c.a_ref_type=='rev' else c.a_ref_name} %elif op == 'D': ${_('Deleted')} - ${h.short_id(c.other_ref_name) if c.other_ref_type=='rev' else c.other_ref_name} + ${h.short_id(c.a_ref_name) if c.a_ref_type=='rev' else c.a_ref_name} %else: ${op}??? %endif