# HG changeset patch # User Mads Kiilerich # Date 1365451149 -7200 # Node ID 3591b33e0c94a938a8279685f67f9a335a985ad5 # Parent 13b7e04af99b96bc88ab818fc6e744ddf58d23f2 hg: use 'revset injection safe' repo.revs for revsets diff -r 13b7e04af99b -r 3591b33e0c94 rhodecode/controllers/compare.py --- a/rhodecode/controllers/compare.py Mon May 06 23:39:35 2013 +0200 +++ b/rhodecode/controllers/compare.py Mon Apr 08 21:59:09 2013 +0200 @@ -105,14 +105,12 @@ 'rev': 'id', } - org_rev_spec = "max(%s('%s'))" % (_revset_predicates[org_ref[0]], - safe_str(org_ref[1])) - org_revs = scmutil.revrange(org_repo._repo, [org_rev_spec]) + org_rev_spec = "max(%s(%%s))" % _revset_predicates[org_ref[0]] + org_revs = org_repo._repo.revs(org_rev_spec, safe_str(org_ref[1])) org_rev = org_repo._repo[org_revs[-1] if org_revs else -1].hex() - other_rev_spec = "max(%s('%s'))" % (_revset_predicates[other_ref[0]], - safe_str(other_ref[1])) - other_revs = scmutil.revrange(other_repo._repo, [other_rev_spec]) + other_revs_spec = "max(%s(%%s))" % _revset_predicates[other_ref[0]] + other_revs = other_repo._repo.revs(other_revs_spec, safe_str(other_ref[1])) other_rev = other_repo._repo[other_revs[-1] if other_revs else -1].hex() #case two independent repos @@ -128,21 +126,19 @@ hgrepo = other_repo._repo if merge: - revs = ["ancestors(id('%s')) and not ancestors(id('%s')) and not id('%s')" % - (other_rev, org_rev, org_rev)] + revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)", + other_rev, org_rev, org_rev) - ancestors = scmutil.revrange(hgrepo, - ["ancestor(id('%s'), id('%s'))" % (org_rev, other_rev)]) + ancestors = hgrepo.revs("ancestor(id(%s), id(%s))", org_rev, other_rev) if ancestors: # pick arbitrary ancestor - but there is usually only one ancestor = hgrepo[ancestors[0]].hex() else: # TODO: have both + and - changesets - revs = ["id('%s') :: id('%s') - id('%s')" % - (org_rev, other_rev, org_rev)] + revs = hgrepo.revs("id(%s) :: id(%s) - id(%s)", + org_rev, other_rev, org_rev) - changesets = [other_repo.get_changeset(cs) - for cs in scmutil.revrange(hgrepo, revs)] + changesets = [other_repo.get_changeset(rev) for rev in revs] elif alias == 'git': if org_repo != other_repo: diff -r 13b7e04af99b -r 3591b33e0c94 rhodecode/controllers/pullrequests.py --- a/rhodecode/controllers/pullrequests.py Mon May 06 23:39:35 2013 +0200 +++ b/rhodecode/controllers/pullrequests.py Mon Apr 08 21:59:09 2013 +0200 @@ -70,7 +70,10 @@ def _get_repo_refs(self, repo, rev=None, branch_rev=None): """return a structure with repo's interesting changesets, suitable for - the selectors in pullrequest.html""" + the selectors in pullrequest.html + + rev: a revision that must be in the list and selected by default + branch_rev: a revision of which peers should be preferred and available.""" # list named branches that has been merged to this named branch - it should probably merge back peers = [] @@ -81,29 +84,32 @@ branch_rev = safe_str(branch_rev) # not restricting to merge() would also get branch point and be better # (especially because it would get the branch point) ... but is currently too expensive - revs = ["sort(parents(branch(id('%s')) and merge()) - branch(id('%s')))" % - (branch_rev, branch_rev)] otherbranches = {} - for i in scmutil.revrange(repo._repo, revs): + for i in repo._repo.revs( + "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)))", + branch_rev, branch_rev): cs = repo.get_changeset(i) otherbranches[cs.branch] = cs.raw_id - for branch, node in otherbranches.iteritems(): - selected = 'branch:%s:%s' % (branch, node) - peers.append((selected, branch)) + for abranch, node in otherbranches.iteritems(): + selected = 'branch:%s:%s' % (abranch, node) + peers.append((selected, abranch)) selected = None + branches = [] - for branch, branchrev in repo.branches.iteritems(): - n = 'branch:%s:%s' % (branch, branchrev) - branches.append((n, branch)) + for abranch, branchrev in repo.branches.iteritems(): + n = 'branch:%s:%s' % (abranch, branchrev) + branches.append((n, abranch)) if rev == branchrev: selected = n + bookmarks = [] for bookmark, bookmarkrev in repo.bookmarks.iteritems(): n = 'book:%s:%s' % (bookmark, bookmarkrev) bookmarks.append((n, bookmark)) if rev == bookmarkrev: selected = n + tags = [] for tag, tagrev in repo.tags.iteritems(): n = 'tag:%s:%s' % (tag, tagrev)