# HG changeset patch # User Mads Kiilerich # Date 2016-05-23 18:02:33 # Node ID 0e9bd6876b428b8677b2e46dc6627aa8eafff52e # Parent 73e44865f204d78d7b2f45544bd33409dba838ca cleanup: remove dead code and templates related to 'Switch To' a33448d81f70 introduced a new 'Switch To' functionality and removed the last reference to branch_tag_switcher and thus to switch_to_list.html and the tags, bookmarks and branches pages. We don't need these pages ... and if we do, we will implement them differently. They are mostly YUI datatables with compare links that only can compare within the same kind of revision names. diff --git a/kallithea/config/routing.py b/kallithea/config/routing.py --- a/kallithea/config/routing.py +++ b/kallithea/config/routing.py @@ -543,8 +543,6 @@ def make_map(config): controller='summary', action='repo_size', conditions=dict(function=check_repo)) - rmap.connect('branch_tag_switcher', '/{repo_name:.*?}/branches-tags', - controller='home', action='branch_tag_switcher') rmap.connect('repo_refs_data', '/{repo_name:.*?}/refs-data', controller='home', action='repo_refs_data') @@ -731,15 +729,6 @@ def make_map(config): rmap.connect('summary_home_summary', '/{repo_name:.*?}/summary', controller='summary', conditions=dict(function=check_repo)) - rmap.connect('branches_home', '/{repo_name:.*?}/branches', - controller='branches', conditions=dict(function=check_repo)) - - rmap.connect('tags_home', '/{repo_name:.*?}/tags', - controller='tags', conditions=dict(function=check_repo)) - - rmap.connect('bookmarks_home', '/{repo_name:.*?}/bookmarks', - controller='bookmarks', conditions=dict(function=check_repo)) - rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', controller='changelog', conditions=dict(function=check_repo)) diff --git a/kallithea/controllers/bookmarks.py b/kallithea/controllers/bookmarks.py deleted file mode 100644 --- a/kallithea/controllers/bookmarks.py +++ /dev/null @@ -1,60 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" -kallithea.controllers.bookmarks -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Bookmarks controller for Kallithea - -This file was forked by the Kallithea project in July 2014. -Original author and date, and relevant copyright and licensing information is below: -:created_on: Dec 1, 2011 -:author: marcink -:copyright: (c) 2013 RhodeCode GmbH, and others. -:license: GPLv3, see LICENSE.md for more details. -""" - -import logging - -from pylons import tmpl_context as c - -from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator -from kallithea.lib.base import BaseRepoController, render -from kallithea.lib.compat import OrderedDict -from webob.exc import HTTPNotFound - -log = logging.getLogger(__name__) - - -class BookmarksController(BaseRepoController): - - def __before__(self): - super(BookmarksController, self).__before__() - - @LoginRequired() - @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', - 'repository.admin') - def index(self): - if c.db_repo_scm_instance.alias != 'hg': - raise HTTPNotFound() - - c.repo_bookmarks = OrderedDict() - - bookmarks = [(name, c.db_repo_scm_instance.get_changeset(hash_)) for \ - name, hash_ in c.db_repo_scm_instance._repo._bookmarks.items()] - ordered_tags = sorted(bookmarks, key=lambda x: x[1].date, reverse=True) - for name, cs_book in ordered_tags: - c.repo_bookmarks[name] = cs_book - - return render('bookmarks/bookmarks.html') diff --git a/kallithea/controllers/branches.py b/kallithea/controllers/branches.py deleted file mode 100644 --- a/kallithea/controllers/branches.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" -kallithea.controllers.branches -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -branches controller for Kallithea - -This file was forked by the Kallithea project in July 2014. -Original author and date, and relevant copyright and licensing information is below: -:created_on: Apr 21, 2010 -:author: marcink -:copyright: (c) 2013 RhodeCode GmbH, and others. -:license: GPLv3, see LICENSE.md for more details. -""" - -import logging -import binascii - -from pylons import tmpl_context as c - -from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator -from kallithea.lib.base import BaseRepoController, render -from kallithea.lib.compat import OrderedDict -from kallithea.lib.utils2 import safe_unicode - -log = logging.getLogger(__name__) - - -class BranchesController(BaseRepoController): - - def __before__(self): - super(BranchesController, self).__before__() - - @LoginRequired() - @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', - 'repository.admin') - def index(self): - - def _branchtags(localrepo): - bt_closed = {} - for bn, heads in localrepo.branchmap().iteritems(): - tip = heads[-1] - if 'close' in localrepo.changelog.read(tip)[5]: - bt_closed[bn] = tip - return bt_closed - - cs_g = c.db_repo_scm_instance.get_changeset - - c.repo_closed_branches = {} - if c.db_repo.repo_type == 'hg': - bt_closed = _branchtags(c.db_repo_scm_instance._repo) - _closed_branches = [(safe_unicode(n), cs_g(binascii.hexlify(h)),) - for n, h in bt_closed.items()] - - c.repo_closed_branches = OrderedDict(sorted(_closed_branches, - key=lambda ctx: ctx[0], - reverse=False)) - - _branches = [(safe_unicode(n), cs_g(h)) - for n, h in c.db_repo_scm_instance.branches.items()] - c.repo_branches = OrderedDict(sorted(_branches, - key=lambda ctx: ctx[0], - reverse=False)) - - return render('branches/branches.html') diff --git a/kallithea/controllers/home.py b/kallithea/controllers/home.py --- a/kallithea/controllers/home.py +++ b/kallithea/controllers/home.py @@ -118,17 +118,6 @@ class HomeController(BaseController): @LoginRequired() @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') - def branch_tag_switcher(self, repo_name): - if request.is_xhr: - c.db_repo = Repository.get_by_repo_name(repo_name) - if c.db_repo: - c.db_repo_scm_instance = c.db_repo.scm_instance - return render('/switch_to_list.html') - raise HTTPBadRequest() - - @LoginRequired() - @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', - 'repository.admin') @jsonify def repo_refs_data(self, repo_name): repo = Repository.get_by_repo_name(repo_name).scm_instance diff --git a/kallithea/controllers/tags.py b/kallithea/controllers/tags.py deleted file mode 100644 --- a/kallithea/controllers/tags.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -""" -kallithea.controllers.tags -~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Tags controller for Kallithea - -This file was forked by the Kallithea project in July 2014. -Original author and date, and relevant copyright and licensing information is below: -:created_on: Apr 21, 2010 -:author: marcink -:copyright: (c) 2013 RhodeCode GmbH, and others. -:license: GPLv3, see LICENSE.md for more details. - -""" - -import logging - -from pylons import tmpl_context as c - -from kallithea.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator -from kallithea.lib.base import BaseRepoController, render -from kallithea.lib.compat import OrderedDict - -log = logging.getLogger(__name__) - - -class TagsController(BaseRepoController): - - def __before__(self): - super(TagsController, self).__before__() - - @LoginRequired() - @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', - 'repository.admin') - def index(self): - c.repo_tags = OrderedDict() - - tags = [(name, c.db_repo_scm_instance.get_changeset(hash_)) for \ - name, hash_ in c.db_repo_scm_instance.tags.items()] - ordered_tags = sorted(tags, key=lambda x: x[1].date, reverse=True) - for name, cs_tag in ordered_tags: - c.repo_tags[name] = cs_tag - - return render('tags/tags.html') diff --git a/kallithea/templates/bookmarks/bookmarks.html b/kallithea/templates/bookmarks/bookmarks.html deleted file mode 100644 --- a/kallithea/templates/bookmarks/bookmarks.html +++ /dev/null @@ -1,96 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/base/base.html"/> - -<%block name="title"> - ${_('%s Bookmarks') % c.repo_name} - - -<%def name="breadcrumbs_links()"> - - ${_('Bookmarks')} - - -<%block name="header_menu"> - ${self.menu('repositories')} - - -<%def name="main()"> -${self.repo_context_bar('switch-to')} -
- -
- ${self.breadcrumbs()} -
- - %if c.repo_bookmarks: - - %endif -
- <%include file='bookmarks_data.html'/> -
-
- - - - diff --git a/kallithea/templates/bookmarks/bookmarks_data.html b/kallithea/templates/bookmarks/bookmarks_data.html deleted file mode 100644 --- a/kallithea/templates/bookmarks/bookmarks_data.html +++ /dev/null @@ -1,44 +0,0 @@ -%if c.repo_bookmarks: -
- - - - ##notranslation - - ##notranslation - - - ##notranslation - - - - - %for cnt,book in enumerate(c.repo_bookmarks.items()): - - - - - - - - - - - %endfor -
Raw name${_('Name')}Raw date${_('Date')}${_('Author')}Raw rev${_('Revision')}${_('Compare')}
${book[0]} - - ${h.link_to(book[0], - h.url('changeset_home',repo_name=c.repo_name,revision=book[1].raw_id))} - - ${book[1]._timestamp}${h.fmt_date(book[1].date)}${h.person(book[1].author)}${book[1].revision} - - - - -
-
-%else: - ${_('There are no bookmarks yet')} -%endif diff --git a/kallithea/templates/branches/branches.html b/kallithea/templates/branches/branches.html deleted file mode 100644 --- a/kallithea/templates/branches/branches.html +++ /dev/null @@ -1,96 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/base/base.html"/> - -<%block name="title"> - ${_('%s Branches') % c.repo_name} - - -<%def name="breadcrumbs_links()"> - - ${_('Branches')} - - -<%block name="header_menu"> - ${self.menu('repositories')} - - -<%def name="main()"> -${self.repo_context_bar('switch-to')} -
- -
- ${self.breadcrumbs()} -
- - %if c.repo_branches: - - %endif -
- <%include file='branches_data.html'/> -
-
- - - - diff --git a/kallithea/templates/branches/branches_data.html b/kallithea/templates/branches/branches_data.html deleted file mode 100644 --- a/kallithea/templates/branches/branches_data.html +++ /dev/null @@ -1,70 +0,0 @@ -%if c.repo_branches: -
- - - - ##notranslation - - ##notranslation - - - ##notranslation - - - - - %for cnt,branch in enumerate(c.repo_branches.items()): - - - - - - - - - - - %endfor - ## closed branches if any - % if hasattr(c,'repo_closed_branches') and c.repo_closed_branches: - %for cnt,branch in enumerate(c.repo_closed_branches.items()): - - - - - - - - - - - %endfor - %endif -
Raw name${_('Name')}Raw date${_('Date')}${_('Author')}Raw rev${_('Revision')}${_('Compare')}
${branch[0]} - - - ${h.link_to(branch[0],h.url('changelog_home',repo_name=c.repo_name,branch=branch[0]))} - - - ${branch[1]._timestamp}${h.fmt_date(branch[1].date)}${h.person(branch[1].author)}${branch[1].revision} - - - - -
${branch[0]} - - - ${h.link_to(branch[0]+' [closed]',h.url('changelog_home',repo_name=c.repo_name,branch=branch[0]))} - - - ${branch[1]._timestamp}${h.fmt_date(branch[1].date)}${h.person(branch[1].author)}${branch[1].revision} - -
-
-%else: - ${_('There are no branches yet')} -%endif diff --git a/kallithea/templates/switch_to_list.html b/kallithea/templates/switch_to_list.html deleted file mode 100644 --- a/kallithea/templates/switch_to_list.html +++ /dev/null @@ -1,49 +0,0 @@ -## -*- coding: utf-8 -*- -
  • - ${'%s (%s)' % (_('Branches'),len(c.db_repo_scm_instance.branches.values()))} -
      - %if c.db_repo_scm_instance.branches.values(): - %for cnt,branch in enumerate(c.db_repo_scm_instance.branches.items()): -
    • ${h.link_to('%s - %s' % (branch[0],h.short_id(branch[1])),h.url('files_home',repo_name=c.repo_name,revision=(branch[0] if '/' not in branch[0] else branch[1]), at=branch[0]))}
    • - %endfor - %else: -
    • ${h.link_to(_('There are no branches yet'),'#')}
    • - %endif -
    -
  • -%if c.db_repo_scm_instance.closed_branches.values(): -
  • - ${'%s (%s)' % (_('Closed Branches'),len(c.db_repo_scm_instance.closed_branches.values()))} -
      - %for cnt,branch in enumerate(c.db_repo_scm_instance.closed_branches.items()): -
    • ${h.link_to('%s - %s' % (branch[0],h.short_id(branch[1])),h.url('files_home',repo_name=c.repo_name,revision=(branch[0] if '/' not in branch[0] else branch[1]), at=branch[0]))}
    • - %endfor -
    -
  • -%endif -
  • - ${'%s (%s)' % (_('Tags'),len(c.db_repo_scm_instance.tags.values()))} -
      - %if c.db_repo_scm_instance.tags.values(): - %for cnt,tag in enumerate(c.db_repo_scm_instance.tags.items()): -
    • ${h.link_to('%s - %s' % (tag[0],h.short_id(tag[1])),h.url('files_home',repo_name=c.repo_name,revision=(tag[0] if '/' not in tag[0] else tag[1]), at=tag[0]))}
    • - %endfor - %else: -
    • ${h.link_to(_('There are no tags yet'),'#')}
    • - %endif -
    -
  • -%if c.db_repo_scm_instance.alias == 'hg': -
  • - ${'%s (%s)' % (_('Bookmarks'),len(c.db_repo_scm_instance.bookmarks.values()))} -
      - %if c.db_repo_scm_instance.bookmarks.values(): - %for cnt,book in enumerate(c.db_repo_scm_instance.bookmarks.items()): -
    • ${h.link_to('%s - %s' % (book[0],h.short_id(book[1])),h.url('files_home',repo_name=c.repo_name,revision=(book[0] if '/' not in book[0] else book[1]), at=book[0]))}
    • - %endfor - %else: -
    • ${h.link_to(_('There are no bookmarks yet'),'#')}
    • - %endif -
    -
  • -%endif diff --git a/kallithea/templates/tags/tags.html b/kallithea/templates/tags/tags.html deleted file mode 100644 --- a/kallithea/templates/tags/tags.html +++ /dev/null @@ -1,96 +0,0 @@ -## -*- coding: utf-8 -*- -<%inherit file="/base/base.html"/> - -<%block name="title"> - ${_('%s Tags') % c.repo_name} - - -<%def name="breadcrumbs_links()"> - - ${_('Tags')} - - -<%block name="header_menu"> - ${self.menu('repositories')} - - -<%def name="main()"> -${self.repo_context_bar('switch-to')} -
    - -
    - ${self.breadcrumbs()} -
    - - %if c.repo_tags: - - %endif -
    - <%include file='tags_data.html'/> -
    -
    - - - - diff --git a/kallithea/templates/tags/tags_data.html b/kallithea/templates/tags/tags_data.html deleted file mode 100644 --- a/kallithea/templates/tags/tags_data.html +++ /dev/null @@ -1,45 +0,0 @@ -%if c.repo_tags: -
    - - - - ##notranslation - - ##notranslation - - - ##notranslation - - - - - %for cnt,tag in enumerate(c.repo_tags.items()): - - - - - - - - - - - %endfor -
    Raw name${_('Name')}Raw date${_('Date')}${_('Author')}Raw rev${_('Revision')}${_('Compare')}
    ${tag[0]} - - ${h.link_to(tag[0], - h.url('changeset_home',repo_name=c.repo_name,revision=tag[1].raw_id))} - - - ${tag[1]._timestamp}${h.fmt_date(tag[1].date)}${h.person(tag[1].author)}${tag[1].revision} - - - - -
    -
    -%else: - ${_('There are no tags yet')} -%endif diff --git a/kallithea/tests/functional/test_branches.py b/kallithea/tests/functional/test_branches.py deleted file mode 100644 --- a/kallithea/tests/functional/test_branches.py +++ /dev/null @@ -1,20 +0,0 @@ -from kallithea.tests import * - - -class TestBranchesController(TestController): - - def test_index_hg(self): - self.log_user() - response = self.app.get(url(controller='branches', - action='index', repo_name=HG_REPO)) - response.mustcontain("""default""" % HG_REPO) - - # closed branches - response.mustcontain("""git [closed]""" % HG_REPO) - response.mustcontain("""web [closed]""" % HG_REPO) - - def test_index_git(self): - self.log_user() - response = self.app.get(url(controller='branches', - action='index', repo_name=GIT_REPO)) - response.mustcontain("""master""" % GIT_REPO) diff --git a/kallithea/tests/functional/test_tags.py b/kallithea/tests/functional/test_tags.py deleted file mode 100644 --- a/kallithea/tests/functional/test_tags.py +++ /dev/null @@ -1,40 +0,0 @@ -from kallithea.tests import * - - -class TestTagsController(TestController): - - def test_index_hg(self): - self.log_user() - response = self.app.get(url(controller='tags', action='index', repo_name=HG_REPO)) - response.mustcontain("""tip""" % HG_REPO) - response.mustcontain("""v0.2.0""" % HG_REPO) - response.mustcontain("""v0.1.11""" % HG_REPO) - response.mustcontain("""v0.1.10""" % HG_REPO) - response.mustcontain("""v0.1.9""" % HG_REPO) - response.mustcontain("""v0.1.8""" % HG_REPO) - response.mustcontain("""v0.1.7""" % HG_REPO) - response.mustcontain("""v0.1.6""" % HG_REPO) - response.mustcontain("""v0.1.5""" % HG_REPO) - response.mustcontain("""v0.1.4""" % HG_REPO) - response.mustcontain("""v0.1.3""" % HG_REPO) - response.mustcontain("""v0.1.2""" % HG_REPO) - response.mustcontain("""v0.1.1""" % HG_REPO) - - def test_index_git(self): - self.log_user() - response = self.app.get(url(controller='tags', action='index', repo_name=GIT_REPO)) - - response.mustcontain("""v0.2.2""" % GIT_REPO) - response.mustcontain("""v0.2.1""" % GIT_REPO) - response.mustcontain("""v0.2.0""" % GIT_REPO) - response.mustcontain("""v0.1.11""" % GIT_REPO) - response.mustcontain("""v0.1.10""" % GIT_REPO) - response.mustcontain("""v0.1.9""" % GIT_REPO) - response.mustcontain("""v0.1.8""" % GIT_REPO) - response.mustcontain("""v0.1.7""" % GIT_REPO) - response.mustcontain("""v0.1.6""" % GIT_REPO) - response.mustcontain("""v0.1.5""" % GIT_REPO) - response.mustcontain("""v0.1.4""" % GIT_REPO) - response.mustcontain("""v0.1.3""" % GIT_REPO) - response.mustcontain("""v0.1.2""" % GIT_REPO) - response.mustcontain("""v0.1.1""" % GIT_REPO)