Changeset - b074dfa51292
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 14 years ago 2011-08-06 22:13:23
marcin@python-works.com
implements #195 added closed branches to detailed branches view
2 files changed with 55 insertions and 9 deletions:
0 comments (0 inline, 0 general)
rhodecode/controllers/branches.py
Show inline comments
 
@@ -23,17 +23,18 @@
 
# You should have received a copy of the GNU General Public License
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 

	
 
import logging
 

	
 
from pylons import tmpl_context as c
 
import binascii
 

	
 
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
 
from rhodecode.lib.base import BaseRepoController, render
 
from rhodecode.lib.odict import OrderedDict
 

	
 
from rhodecode.lib import safe_unicode
 
log = logging.getLogger(__name__)
 

	
 

	
 
class BranchesController(BaseRepoController):
 

	
 
    @LoginRequired()
 
@@ -41,11 +42,37 @@ class BranchesController(BaseRepoControl
 
                                   'repository.admin')
 
    def __before__(self):
 
        super(BranchesController, self).__before__()
 

	
 
    def index(self):
 

	
 
        c.repo_branches = OrderedDict()
 
        for name, hash_ in c.rhodecode_repo.branches.items():
 
            c.repo_branches[name] = c.rhodecode_repo.get_changeset(hash_)
 
        def _branchtags(localrepo):
 

	
 
            bt = {}
 
            bt_closed = {}
 

	
 
            for bn, heads in localrepo.branchmap().iteritems():
 
                tip = heads[-1]
 
                if 'close' not in localrepo.changelog.read(tip)[5]:
 
                    bt[bn] = tip
 
                else:
 
                    bt_closed[bn] = tip
 
            return bt, bt_closed
 

	
 

	
 
        bt, bt_closed = _branchtags(c.rhodecode_repo._repo)
 
        cs_g = c.rhodecode_repo.get_changeset
 
        _branches = [(safe_unicode(n), cs_g(binascii.hexlify(h)),) for n, h in
 
                     bt.items()]
 

	
 
        _closed_branches = [(safe_unicode(n), cs_g(binascii.hexlify(h)),) for n, h in
 
                     bt_closed.items()]
 

	
 
        c.repo_branches = OrderedDict(sorted(_branches,
 
                                             key=lambda ctx: ctx[0],
 
                                             reverse=False))
 
        c.repo_closed_branches = OrderedDict(sorted(_closed_branches,
 
                                                    key=lambda ctx: ctx[0],
 
                                                    reverse=False))
 

	
 

	
 
        return render('branches/branches.html')
rhodecode/templates/branches/branches_data.html
Show inline comments
 
@@ -6,14 +6,13 @@
 
            <th class="left">${_('author')}</th>
 
            <th class="left">${_('revision')}</th>
 
            <th class="left">${_('links')}</th>
 
        </tr>
 
		%for cnt,branch in enumerate(c.repo_branches.items()):
 
		<tr class="parity${cnt%2}">
 
            <td><span class="tooltip" title="${h.age(branch[1].date)}">
 
                      ${branch[1].date}</span>
 
            <td><span class="tooltip" title="${h.age(branch[1].date)}">${branch[1].date}</span>
 
            </td>
 
            <td>
 
                <span class="logtags">
 
                    <span class="branchtag">${h.link_to(branch[0],
 
                    h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
 
                </span>         
 
@@ -24,11 +23,31 @@
 
			${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			|
 
			${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
			</td>
 
		</tr>	
 
		%endfor
 
        % if hasattr(c,'repo_closed_branches') and c.repo_closed_branches:
 
          %for cnt,branch in enumerate(c.repo_closed_branches.items()):
 
          <tr class="parity${cnt%2}">
 
              <td><span class="tooltip" title="${h.age(branch[1].date)}">${branch[1].date}</span>
 
              </td>
 
              <td>
 
                  <span class="logtags">
 
                      <span class="branchtag">${h.link_to(branch[0]+' [closed]',
 
                      h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}</span>
 
                  </span>         
 
              </td>       
 
              <td title="${branch[1].author}">${h.person(branch[1].author)}</td>
 
              <td>r${branch[1].revision}:${h.short_id(branch[1].raw_id)}</td>
 
              <td class="nowrap">
 
              ${h.link_to(_('changeset'),h.url('changeset_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
              |
 
              ${h.link_to(_('files'),h.url('files_home',repo_name=c.repo_name,revision=branch[1].raw_id))}
 
              </td>
 
          </tr>   
 
          %endfor
 
        %endif  
 
    </table>
 
%else:
 
	${_('There are no branches yet')}
 
%endif
 

	
 
    ${_('There are no branches yet')}
 
%endif
 
\ No newline at end of file
0 comments (0 inline, 0 general)