##// END OF EJS Templates
hg: use 'revset injection safe' repo.revs for revsets
Mads Kiilerich -
r3811:3591b33e beta
parent child Browse files
Show More
@@ -105,14 +105,12 b' class CompareController(BaseRepoControll'
105 105 'rev': 'id',
106 106 }
107 107
108 org_rev_spec = "max(%s('%s'))" % (_revset_predicates[org_ref[0]],
109 safe_str(org_ref[1]))
110 org_revs = scmutil.revrange(org_repo._repo, [org_rev_spec])
108 org_rev_spec = "max(%s(%%s))" % _revset_predicates[org_ref[0]]
109 org_revs = org_repo._repo.revs(org_rev_spec, safe_str(org_ref[1]))
111 110 org_rev = org_repo._repo[org_revs[-1] if org_revs else -1].hex()
112 111
113 other_rev_spec = "max(%s('%s'))" % (_revset_predicates[other_ref[0]],
114 safe_str(other_ref[1]))
115 other_revs = scmutil.revrange(other_repo._repo, [other_rev_spec])
112 other_revs_spec = "max(%s(%%s))" % _revset_predicates[other_ref[0]]
113 other_revs = other_repo._repo.revs(other_revs_spec, safe_str(other_ref[1]))
116 114 other_rev = other_repo._repo[other_revs[-1] if other_revs else -1].hex()
117 115
118 116 #case two independent repos
@@ -128,21 +126,19 b' class CompareController(BaseRepoControll'
128 126 hgrepo = other_repo._repo
129 127
130 128 if merge:
131 revs = ["ancestors(id('%s')) and not ancestors(id('%s')) and not id('%s')" %
132 (other_rev, org_rev, org_rev)]
129 revs = hgrepo.revs("ancestors(id(%s)) and not ancestors(id(%s)) and not id(%s)",
130 other_rev, org_rev, org_rev)
133 131
134 ancestors = scmutil.revrange(hgrepo,
135 ["ancestor(id('%s'), id('%s'))" % (org_rev, other_rev)])
132 ancestors = hgrepo.revs("ancestor(id(%s), id(%s))", org_rev, other_rev)
136 133 if ancestors:
137 134 # pick arbitrary ancestor - but there is usually only one
138 135 ancestor = hgrepo[ancestors[0]].hex()
139 136 else:
140 137 # TODO: have both + and - changesets
141 revs = ["id('%s') :: id('%s') - id('%s')" %
142 (org_rev, other_rev, org_rev)]
138 revs = hgrepo.revs("id(%s) :: id(%s) - id(%s)",
139 org_rev, other_rev, org_rev)
143 140
144 changesets = [other_repo.get_changeset(cs)
145 for cs in scmutil.revrange(hgrepo, revs)]
141 changesets = [other_repo.get_changeset(rev) for rev in revs]
146 142
147 143 elif alias == 'git':
148 144 if org_repo != other_repo:
@@ -70,7 +70,10 b' class PullrequestsController(BaseRepoCon'
70 70
71 71 def _get_repo_refs(self, repo, rev=None, branch_rev=None):
72 72 """return a structure with repo's interesting changesets, suitable for
73 the selectors in pullrequest.html"""
73 the selectors in pullrequest.html
74
75 rev: a revision that must be in the list and selected by default
76 branch_rev: a revision of which peers should be preferred and available."""
74 77 # list named branches that has been merged to this named branch - it should probably merge back
75 78 peers = []
76 79
@@ -81,29 +84,32 b' class PullrequestsController(BaseRepoCon'
81 84 branch_rev = safe_str(branch_rev)
82 85 # not restricting to merge() would also get branch point and be better
83 86 # (especially because it would get the branch point) ... but is currently too expensive
84 revs = ["sort(parents(branch(id('%s')) and merge()) - branch(id('%s')))" %
85 (branch_rev, branch_rev)]
86 87 otherbranches = {}
87 for i in scmutil.revrange(repo._repo, revs):
88 for i in repo._repo.revs(
89 "sort(parents(branch(id(%s)) and merge()) - branch(id(%s)))",
90 branch_rev, branch_rev):
88 91 cs = repo.get_changeset(i)
89 92 otherbranches[cs.branch] = cs.raw_id
90 for branch, node in otherbranches.iteritems():
91 selected = 'branch:%s:%s' % (branch, node)
92 peers.append((selected, branch))
93 for abranch, node in otherbranches.iteritems():
94 selected = 'branch:%s:%s' % (abranch, node)
95 peers.append((selected, abranch))
93 96
94 97 selected = None
98
95 99 branches = []
96 for branch, branchrev in repo.branches.iteritems():
97 n = 'branch:%s:%s' % (branch, branchrev)
98 branches.append((n, branch))
100 for abranch, branchrev in repo.branches.iteritems():
101 n = 'branch:%s:%s' % (abranch, branchrev)
102 branches.append((n, abranch))
99 103 if rev == branchrev:
100 104 selected = n
105
101 106 bookmarks = []
102 107 for bookmark, bookmarkrev in repo.bookmarks.iteritems():
103 108 n = 'book:%s:%s' % (bookmark, bookmarkrev)
104 109 bookmarks.append((n, bookmark))
105 110 if rev == bookmarkrev:
106 111 selected = n
112
107 113 tags = []
108 114 for tag, tagrev in repo.tags.iteritems():
109 115 n = 'tag:%s:%s' % (tag, tagrev)
General Comments 0
You need to be logged in to leave comments. Login now