Changeset - 3591b33e0c94
[Not reviewed]
beta
0 2 0
Mads Kiilerich - 13 years ago 2013-04-08 21:59:09
madski@unity3d.com
hg: use 'revset injection safe' repo.revs for revsets
2 files changed with 26 insertions and 24 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/compare.py
Show inline comments
 
@@ -105,14 +105,12 @@ class CompareController(BaseRepoControll
 
                    '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 @@ class CompareController(BaseRepoControll
 
                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:
rhodecode/controllers/pullrequests.py
Show inline comments
 
@@ -70,7 +70,10 @@ class PullrequestsController(BaseRepoCon
 

	
 
    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 @@ class PullrequestsController(BaseRepoCon
 
            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)
0 comments (0 inline, 0 general)