##// END OF EJS Templates
implements #195 added closed branches to detailed branches view
marcink -
r1440:b074dfa5 beta
parent child Browse files
Show More
@@ -1,51 +1,78 b''
1 # -*- coding: utf-8 -*-
1 # -*- coding: utf-8 -*-
2 """
2 """
3 rhodecode.controllers.branches
3 rhodecode.controllers.branches
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5
5
6 branches controller for rhodecode
6 branches controller for rhodecode
7
7
8 :created_on: Apr 21, 2010
8 :created_on: Apr 21, 2010
9 :author: marcink
9 :author: marcink
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
10 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
11 :license: GPLv3, see COPYING for more details.
11 :license: GPLv3, see COPYING for more details.
12 """
12 """
13 # This program is free software: you can redistribute it and/or modify
13 # This program is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation, either version 3 of the License, or
15 # the Free Software Foundation, either version 3 of the License, or
16 # (at your option) any later version.
16 # (at your option) any later version.
17 #
17 #
18 # This program is distributed in the hope that it will be useful,
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 # GNU General Public License for more details.
21 # GNU General Public License for more details.
22 #
22 #
23 # You should have received a copy of the GNU General Public License
23 # You should have received a copy of the GNU General Public License
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25
25
26 import logging
26 import logging
27
27
28 from pylons import tmpl_context as c
28 from pylons import tmpl_context as c
29 import binascii
29
30
30 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
31 from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
31 from rhodecode.lib.base import BaseRepoController, render
32 from rhodecode.lib.base import BaseRepoController, render
32 from rhodecode.lib.odict import OrderedDict
33 from rhodecode.lib.odict import OrderedDict
33
34 from rhodecode.lib import safe_unicode
34 log = logging.getLogger(__name__)
35 log = logging.getLogger(__name__)
35
36
36
37
37 class BranchesController(BaseRepoController):
38 class BranchesController(BaseRepoController):
38
39
39 @LoginRequired()
40 @LoginRequired()
40 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
41 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
41 'repository.admin')
42 'repository.admin')
42 def __before__(self):
43 def __before__(self):
43 super(BranchesController, self).__before__()
44 super(BranchesController, self).__before__()
44
45
45 def index(self):
46 def index(self):
46
47
47 c.repo_branches = OrderedDict()
48 def _branchtags(localrepo):
48 for name, hash_ in c.rhodecode_repo.branches.items():
49
49 c.repo_branches[name] = c.rhodecode_repo.get_changeset(hash_)
50 bt = {}
51 bt_closed = {}
52
53 for bn, heads in localrepo.branchmap().iteritems():
54 tip = heads[-1]
55 if 'close' not in localrepo.changelog.read(tip)[5]:
56 bt[bn] = tip
57 else:
58 bt_closed[bn] = tip
59 return bt, bt_closed
60
61
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()]
66
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,
71 key=lambda ctx: ctx[0],
72 reverse=False))
73 c.repo_closed_branches = OrderedDict(sorted(_closed_branches,
74 key=lambda ctx: ctx[0],
75 reverse=False))
76
50
77
51 return render('branches/branches.html')
78 return render('branches/branches.html')
@@ -1,34 +1,53 b''
1 % if c.repo_branches:
1 % if c.repo_branches:
2 <table class="table_disp">
2 <table class="table_disp">
3 <tr>
3 <tr>
4 <th class="left">${_('date')}</th>
4 <th class="left">${_('date')}</th>
5 <th class="left">${_('name')}</th>
5 <th class="left">${_('name')}</th>
6 <th class="left">${_('author')}</th>
6 <th class="left">${_('author')}</th>
7 <th class="left">${_('revision')}</th>
7 <th class="left">${_('revision')}</th>
8 <th class="left">${_('links')}</th>
8 <th class="left">${_('links')}</th>
9 </tr>
9 </tr>
10 %for cnt,branch in enumerate(c.repo_branches.items()):
10 %for cnt,branch in enumerate(c.repo_branches.items()):
11 <tr class="parity${cnt%2}">
11 <tr class="parity${cnt%2}">
12 <td><span class="tooltip" title="${h.age(branch[1].date)}">
12 <td><span class="tooltip" title="${h.age(branch[1].date)}">${branch[1].date}</span>
13 ${branch[1].date}</span>
14 </td>
13 </td>
15 <td>
14 <td>
16 <span class="logtags">
15 <span class="logtags">
17 <span class="branchtag">${h.link_to(branch[0],
16 <span class="branchtag">${h.link_to(branch[0],
18 h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
17 h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
19 </span>
18 </span>
20 </td>
19 </td>
21 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
20 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
22 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
21 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
23 <td class="nowrap">
22 <td class="nowrap">
24 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
23 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
25 |
24 |
26 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
25 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
27 </td>
26 </td>
28 </tr>
27 </tr>
29 %endfor
28 %endfor
29 % if hasattr(c,'repo_closed_branches') and c.repo_closed_branches:
30 %for cnt,branch in enumerate(c.repo_closed_branches.items()):
31 <tr class="parity${cnt%2}">
32 <td><span class="tooltip" title="${h.age(branch[1].date)}">${branch[1].date}</span>
33 </td>
34 <td>
35 <span class="logtags">
36 <span class="branchtag">${h.link_to(branch[0]+' [closed]',
37 h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
38 </span>
39 </td>
40 <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
41 <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
42 <td class="nowrap">
43 ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
44 |
45 ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
46 </td>
47 </tr>
48 %endfor
49 %endif
30 </table>
50 </table>
31 %else:
51 %else:
32 ${_('There are no branches yet')}
52 ${_('There are no branches yet')}
33 %endif
53 %endif No newline at end of file
34
General Comments 0
You need to be logged in to leave comments. Login now