Mercurial > kallithea
comparison rhodecode/controllers/pullrequests.py @ 3598:7d774f09dba5 beta
pullrequests: only create special select entry for a changeset if it has no symbolic name
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Tue, 26 Mar 2013 01:23:35 +0100 |
parents | 54e011cb21fd |
children | ceb6d57d1998 |
comparison
equal
deleted
inserted
replaced
3597:54e011cb21fd | 3598:7d774f09dba5 |
---|---|
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 branches = [('branch:%s:%s' % (k, v), k) | |
75 for k, v in repo.branches.iteritems()] | |
76 bookmarks = [('book:%s:%s' % (k, v), k) | |
77 for k, v in repo.bookmarks.iteritems()] | |
78 tags = [('tag:%s:%s' % (k, v), k) | |
79 for k, v in repo.tags.iteritems() | |
80 if k != 'tip'] | |
81 | |
82 tip = repo.tags['tip'] | |
83 colontip = ':' + tip | |
84 tips = [x[1] for x in branches + bookmarks + tags | |
85 if x[0].endswith(colontip)] | |
86 selected = 'tag:tip:%s' % tip | |
87 special = [(selected, 'tip: %s' % ', '.join(tips))] | |
88 | |
89 if rev: | |
90 selected = 'rev:%s:%s' % (rev, rev) | |
91 special.append((selected, '%s: %s' % (_("Selected"), rev[:12]))) | |
92 | 74 |
93 # list named branches that has been merged to this named branch - it should probably merge back | 75 # list named branches that has been merged to this named branch - it should probably merge back |
76 peers = [] | |
94 if branch_rev: | 77 if branch_rev: |
95 # not restricting to merge() would also get branch point and be better | 78 # not restricting to merge() would also get branch point and be better |
96 # (especially because it would get the branch point) ... but is currently too expensive | 79 # (especially because it would get the branch point) ... but is currently too expensive |
97 revs = ["sort(parents(branch(id('%s')) and merge()) - branch(id('%s')))" % | 80 revs = ["sort(parents(branch(id('%s')) and merge()) - branch(id('%s')))" % |
98 (branch_rev, branch_rev)] | 81 (branch_rev, branch_rev)] |
100 for i in scmutil.revrange(repo._repo, revs): | 83 for i in scmutil.revrange(repo._repo, revs): |
101 cs = repo.get_changeset(i) | 84 cs = repo.get_changeset(i) |
102 otherbranches[cs.branch] = cs.raw_id | 85 otherbranches[cs.branch] = cs.raw_id |
103 for branch, node in otherbranches.iteritems(): | 86 for branch, node in otherbranches.iteritems(): |
104 selected = 'branch:%s:%s' % (branch, node) | 87 selected = 'branch:%s:%s' % (branch, node) |
105 special.append((selected, '%s: %s' % (_('Peer'), branch))) | 88 peers.append((selected, branch)) |
106 | 89 |
107 return [(special, _("Special")), | 90 selected = None |
108 (bookmarks, _("Bookmarks")), | 91 branches = [] |
109 (branches, _("Branches")), | 92 for branch, branchrev in repo.branches.iteritems(): |
110 (tags, _("Tags")), | 93 n = 'branch:%s:%s' % (branch, branchrev) |
111 ], selected | 94 branches.append((n, branch)) |
95 if rev == branchrev: | |
96 selected = n | |
97 bookmarks = [] | |
98 for bookmark, bookmarkrev in repo.bookmarks.iteritems(): | |
99 n = 'book:%s:%s' % (bookmark, bookmarkrev) | |
100 bookmarks.append((n, bookmark)) | |
101 if rev == bookmarkrev: | |
102 selected = n | |
103 tags = [] | |
104 for tag, tagrev in repo.tags.iteritems(): | |
105 n = 'tag:%s:%s' % (tag, tagrev) | |
106 tags.append((n, tag)) | |
107 if rev == tagrev and tag != 'tip': # tip is not a real tag - and its branch is better | |
108 selected = n | |
109 | |
110 # prio 1: rev was selected as existing entry above | |
111 | |
112 # prio 2: create special entry for rev; rev _must_ be used | |
113 specials = [] | |
114 if rev and selected is None: | |
115 selected = 'rev:%s:%s' % (rev, rev) | |
116 specials = [(selected, '%s: %s' % (_("Changeset"), rev[:12]))] | |
117 | |
118 # prio 3: most recent peer branch | |
119 if peers and not selected: | |
120 selected = peers[0][0][0] | |
121 | |
122 # prio 4: tip revision | |
123 if not selected: | |
124 selected = 'tag:tip:%s' % repo.tags['tip'] | |
125 | |
126 groups = [(specials, _("Special")), | |
127 (peers, _("Peer branches")), | |
128 (bookmarks, _("Bookmarks")), | |
129 (branches, _("Branches")), | |
130 (tags, _("Tags")), | |
131 ] | |
132 return [g for g in groups if g[0]], selected | |
112 | 133 |
113 def _get_is_allowed_change_status(self, pull_request): | 134 def _get_is_allowed_change_status(self, pull_request): |
114 owner = self.rhodecode_user.user_id == pull_request.user_id | 135 owner = self.rhodecode_user.user_id == pull_request.user_id |
115 reviewer = self.rhodecode_user.user_id in [x.user_id for x in | 136 reviewer = self.rhodecode_user.user_id in [x.user_id for x in |
116 pull_request.reviewers] | 137 pull_request.reviewers] |