Show More
@@ -1,78 +1,75 | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | """ |
|
3 | 3 | rhodecode.controllers.branches |
|
4 | 4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
5 | 5 | |
|
6 | 6 | branches controller for rhodecode |
|
7 | 7 | |
|
8 | 8 | :created_on: Apr 21, 2010 |
|
9 | 9 | :author: marcink |
|
10 | 10 | :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
|
11 | 11 | :license: GPLv3, see COPYING for more details. |
|
12 | 12 | """ |
|
13 | 13 | # This program is free software: you can redistribute it and/or modify |
|
14 | 14 | # it under the terms of the GNU General Public License as published by |
|
15 | 15 | # the Free Software Foundation, either version 3 of the License, or |
|
16 | 16 | # (at your option) any later version. |
|
17 | 17 | # |
|
18 | 18 | # This program is distributed in the hope that it will be useful, |
|
19 | 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
20 | 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
21 | 21 | # GNU General Public License for more details. |
|
22 | 22 | # |
|
23 | 23 | # You should have received a copy of the GNU General Public License |
|
24 | 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | 25 | |
|
26 | 26 | import logging |
|
27 | 27 | |
|
28 | 28 | from pylons import tmpl_context as c |
|
29 | 29 | import binascii |
|
30 | 30 | |
|
31 | 31 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
32 | 32 | from rhodecode.lib.base import BaseRepoController, render |
|
33 | 33 | from rhodecode.lib.compat import OrderedDict |
|
34 | 34 | from rhodecode.lib import safe_unicode |
|
35 | 35 | log = logging.getLogger(__name__) |
|
36 | 36 | |
|
37 | 37 | |
|
38 | 38 | class BranchesController(BaseRepoController): |
|
39 | 39 | |
|
40 | 40 | @LoginRequired() |
|
41 | 41 | @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', |
|
42 | 42 | 'repository.admin') |
|
43 | 43 | def __before__(self): |
|
44 | 44 | super(BranchesController, self).__before__() |
|
45 | 45 | |
|
46 | 46 | def index(self): |
|
47 | 47 | |
|
48 | 48 | def _branchtags(localrepo): |
|
49 | ||
|
50 | bt = {} | |
|
51 | 49 | bt_closed = {} |
|
52 | ||
|
53 | 50 | for bn, heads in localrepo.branchmap().iteritems(): |
|
54 | 51 | tip = heads[-1] |
|
55 |
if 'close' |
|
|
56 | bt[bn] = tip | |
|
57 | else: | |
|
52 | if 'close' in localrepo.changelog.read(tip)[5]: | |
|
58 | 53 | bt_closed[bn] = tip |
|
59 |
return |
|
|
54 | return bt_closed | |
|
60 | 55 | |
|
56 | cs_g = c.rhodecode_repo.get_changeset | |
|
61 | 57 | |
|
62 | bt, bt_closed = _branchtags(c.rhodecode_repo._repo) | |
|
63 | cs_g = c.rhodecode_repo.get_changeset | |
|
64 | _branches = [(safe_unicode(n), cs_g(binascii.hexlify(h)),) for n, h in | |
|
65 | bt.items()] | |
|
58 | c.repo_closed_branches = {} | |
|
59 | if c.rhodecode_db_repo.repo_type == 'hg': | |
|
60 | bt_closed = _branchtags(c.rhodecode_repo._repo) | |
|
61 | _closed_branches = [(safe_unicode(n), cs_g(binascii.hexlify(h)),) | |
|
62 | for n, h in bt_closed.items()] | |
|
66 | 63 | |
|
67 | _closed_branches = [(safe_unicode(n), cs_g(binascii.hexlify(h)),) for n, h in | |
|
68 | bt_closed.items()] | |
|
69 | ||
|
70 | c.repo_branches = OrderedDict(sorted(_branches, | |
|
64 | c.repo_closed_branches = OrderedDict(sorted(_closed_branches, | |
|
71 | 65 | key=lambda ctx: ctx[0], |
|
72 | 66 | reverse=False)) |
|
73 | c.repo_closed_branches = OrderedDict(sorted(_closed_branches, | |
|
67 | ||
|
68 | _branches = [(safe_unicode(n), cs_g(h)) | |
|
69 | for n, h in c.rhodecode_repo.branches.items()] | |
|
70 | c.repo_branches = OrderedDict(sorted(_branches, | |
|
74 | 71 |
|
|
75 | 72 |
|
|
76 | 73 | |
|
77 | 74 | |
|
78 | 75 | return render('branches/branches.html') |
General Comments 0
You need to be logged in to leave comments.
Login now