Mercurial > kallithea
comparison rhodecode/controllers/pullrequests.py @ 3811:3591b33e0c94 beta
hg: use 'revset injection safe' repo.revs for revsets
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Mon, 08 Apr 2013 21:59:09 +0200 |
parents | 7d8154837174 |
children | 4324d6899e55 |
comparison
equal
deleted
inserted
replaced
3810:13b7e04af99b | 3811:3591b33e0c94 |
---|---|
68 c.users_array = repo_model.get_users_js() | 68 c.users_array = repo_model.get_users_js() |
69 c.users_groups_array = repo_model.get_users_groups_js() | 69 c.users_groups_array = repo_model.get_users_groups_js() |
70 | 70 |
71 def _get_repo_refs(self, repo, rev=None, branch_rev=None): | 71 def _get_repo_refs(self, repo, rev=None, branch_rev=None): |
72 """return a structure with repo's interesting changesets, suitable for | 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 # list named branches that has been merged to this named branch - it should probably merge back | 77 # list named branches that has been merged to this named branch - it should probably merge back |
75 peers = [] | 78 peers = [] |
76 | 79 |
77 if rev: | 80 if rev: |
78 rev = safe_str(rev) | 81 rev = safe_str(rev) |
79 | 82 |
80 if branch_rev: | 83 if branch_rev: |
81 branch_rev = safe_str(branch_rev) | 84 branch_rev = safe_str(branch_rev) |
82 # not restricting to merge() would also get branch point and be better | 85 # not restricting to merge() would also get branch point and be better |
83 # (especially because it would get the branch point) ... but is currently too expensive | 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 otherbranches = {} | 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 cs = repo.get_changeset(i) | 91 cs = repo.get_changeset(i) |
89 otherbranches[cs.branch] = cs.raw_id | 92 otherbranches[cs.branch] = cs.raw_id |
90 for branch, node in otherbranches.iteritems(): | 93 for abranch, node in otherbranches.iteritems(): |
91 selected = 'branch:%s:%s' % (branch, node) | 94 selected = 'branch:%s:%s' % (abranch, node) |
92 peers.append((selected, branch)) | 95 peers.append((selected, abranch)) |
93 | 96 |
94 selected = None | 97 selected = None |
98 | |
95 branches = [] | 99 branches = [] |
96 for branch, branchrev in repo.branches.iteritems(): | 100 for abranch, branchrev in repo.branches.iteritems(): |
97 n = 'branch:%s:%s' % (branch, branchrev) | 101 n = 'branch:%s:%s' % (abranch, branchrev) |
98 branches.append((n, branch)) | 102 branches.append((n, abranch)) |
99 if rev == branchrev: | 103 if rev == branchrev: |
100 selected = n | 104 selected = n |
105 | |
101 bookmarks = [] | 106 bookmarks = [] |
102 for bookmark, bookmarkrev in repo.bookmarks.iteritems(): | 107 for bookmark, bookmarkrev in repo.bookmarks.iteritems(): |
103 n = 'book:%s:%s' % (bookmark, bookmarkrev) | 108 n = 'book:%s:%s' % (bookmark, bookmarkrev) |
104 bookmarks.append((n, bookmark)) | 109 bookmarks.append((n, bookmark)) |
105 if rev == bookmarkrev: | 110 if rev == bookmarkrev: |
106 selected = n | 111 selected = n |
112 | |
107 tags = [] | 113 tags = [] |
108 for tag, tagrev in repo.tags.iteritems(): | 114 for tag, tagrev in repo.tags.iteritems(): |
109 n = 'tag:%s:%s' % (tag, tagrev) | 115 n = 'tag:%s:%s' % (tag, tagrev) |
110 tags.append((n, tag)) | 116 tags.append((n, tag)) |
111 if rev == tagrev and tag != 'tip': # tip is not a real tag - and its branch is better | 117 if rev == tagrev and tag != 'tip': # tip is not a real tag - and its branch is better |