diff --git a/rhodecode/api/utils.py b/rhodecode/api/utils.py --- a/rhodecode/api/utils.py +++ b/rhodecode/api/utils.py @@ -30,7 +30,7 @@ from rhodecode.lib.auth import ( HasPermissionAnyApi, HasRepoPermissionAnyApi, HasRepoGroupPermissionAnyApi) from rhodecode.lib.utils import safe_unicode from rhodecode.lib.vcs.exceptions import RepositoryError -from rhodecode.controllers.utils import get_commit_from_ref_name +from rhodecode.lib.view_utils import get_commit_from_ref_name from rhodecode.lib.utils2 import str2bool log = logging.getLogger(__name__) diff --git a/rhodecode/apps/repository/views/repo_compare.py b/rhodecode/apps/repository/views/repo_compare.py --- a/rhodecode/apps/repository/views/repo_compare.py +++ b/rhodecode/apps/repository/views/repo_compare.py @@ -27,12 +27,13 @@ from pyramid.renderers import render from pyramid.response import Response from rhodecode.apps._base import RepoAppView -from rhodecode.controllers.utils import parse_path_ref, get_commit_from_ref_name + from rhodecode.lib import helpers as h from rhodecode.lib import diffs, codeblocks from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator from rhodecode.lib.utils import safe_str from rhodecode.lib.utils2 import safe_unicode, str2bool +from rhodecode.lib.view_utils import parse_path_ref, get_commit_from_ref_name from rhodecode.lib.vcs.exceptions import ( EmptyRepositoryError, RepositoryError, RepositoryRequirementError, NodeDoesNotExistError) diff --git a/rhodecode/apps/repository/views/repo_files.py b/rhodecode/apps/repository/views/repo_files.py --- a/rhodecode/apps/repository/views/repo_files.py +++ b/rhodecode/apps/repository/views/repo_files.py @@ -33,9 +33,10 @@ from pyramid.response import Response import rhodecode from rhodecode.apps._base import RepoAppView -from rhodecode.controllers.utils import parse_path_ref + from rhodecode.lib import diffs, helpers as h, rc_cache from rhodecode.lib import audit_logger +from rhodecode.lib.view_utils import parse_path_ref from rhodecode.lib.exceptions import NonRelativePathError from rhodecode.lib.codeblocks import ( filenode_as_lines_tokens, filenode_as_annotated_lines_tokens) diff --git a/rhodecode/apps/repository/views/repo_summary.py b/rhodecode/apps/repository/views/repo_summary.py --- a/rhodecode/apps/repository/views/repo_summary.py +++ b/rhodecode/apps/repository/views/repo_summary.py @@ -24,7 +24,7 @@ import rhodecode from pyramid.view import view_config -from rhodecode.controllers import utils +from rhodecode.lib.view_utils import get_format_ref_id from rhodecode.apps._base import RepoAppView from rhodecode.config.conf import (LANGUAGES_EXTENSIONS_MAP) from rhodecode.lib import helpers as h, rc_cache @@ -351,7 +351,7 @@ class RepoSummaryView(RepoAppView): return data def _create_reference_data(self, repo, full_repo_name, refs_to_create): - format_ref_id = utils.get_format_ref_id(repo) + format_ref_id = get_format_ref_id(repo) result = [] for title, refs, ref_type in refs_to_create: diff --git a/rhodecode/controllers/__init__.py b/rhodecode/controllers/__init__.py deleted file mode 100644 --- a/rhodecode/controllers/__init__.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -# Copyright (C) 2010-2018 RhodeCode GmbH -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License, version 3 -# (only), as published by the Free Software Foundation. -# -# 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 Affero General Public License -# along with this program. If not, see . -# -# This program is dual-licensed. If you wish to learn more about the -# RhodeCode Enterprise Edition, including its added features, Support services, -# and proprietary license terms, please see https://rhodecode.com/licenses/ diff --git a/rhodecode/controllers/utils.py b/rhodecode/lib/view_utils.py rename from rhodecode/controllers/utils.py rename to rhodecode/lib/view_utils.py diff --git a/rhodecode/tests/other/test_views_utils.py b/rhodecode/tests/other/test_views_utils.py --- a/rhodecode/tests/other/test_views_utils.py +++ b/rhodecode/tests/other/test_views_utils.py @@ -20,7 +20,7 @@ import pytest -from rhodecode.controllers import utils +from rhodecode.lib import view_utils from rhodecode.lib.vcs.exceptions import RepositoryError import mock @@ -34,11 +34,11 @@ def test_parse_path_ref_understands_form repo = mock.Mock(alias=alias) # Formatting of reference ids as it is used by controllers - format_ref_id = utils.get_format_ref_id(repo) + format_ref_id = view_utils.get_format_ref_id(repo) formatted_ref_id = format_ref_id(name='name', raw_id='raw_id') # Parsing such a reference back as it is used by controllers - result = utils.parse_path_ref(formatted_ref_id) + result = view_utils.parse_path_ref(formatted_ref_id) assert list(result) == expected @@ -50,7 +50,7 @@ def test_parse_path_ref_understands_form ('p@a', None, ('p', 'a')), ]) def test_parse_path_ref(ref, default_path, expected): - result = utils.parse_path_ref(ref, default_path) + result = view_utils.parse_path_ref(ref, default_path) assert list(result) == list(expected) @@ -61,7 +61,7 @@ def test_parse_path_ref(ref, default_pat ]) def test_format_ref_id(alias, expected): repo = mock.Mock(alias=alias) - format_ref_id = utils.get_format_ref_id(repo) + format_ref_id = view_utils.get_format_ref_id(repo) result = format_ref_id(name='name', raw_id='raw_id') assert result == expected @@ -77,7 +77,7 @@ class TestGetCommit(object): scm_instance.bookmarks = {ref_name: 'a_book_id'} scm_instance.get_commit.return_value = 'test' - commit = utils.get_commit_from_ref_name(repo, ref_name, ref_type) + commit = view_utils.get_commit_from_ref_name(repo, ref_name, ref_type) scm_instance.get_commit.assert_called_once_with('a_%s_id' % ref_type) assert commit == 'test' @@ -90,4 +90,4 @@ class TestGetCommit(object): repo.scm_instance().tags = {} repo.scm_instance().bookmarks = {} with pytest.raises(RepositoryError): - utils.get_commit_from_ref_name(repo, ref_name, ref_type) + view_utils.get_commit_from_ref_name(repo, ref_name, ref_type)