diff --git a/rhodecode/apps/home/views.py b/rhodecode/apps/home/views.py --- a/rhodecode/apps/home/views.py +++ b/rhodecode/apps/home/views.py @@ -469,7 +469,7 @@ class HomeView(BaseAppView): _query=query_modifier()) } - if repo_context in ['commit', 'changelog']: + if repo_context in ['commit', 'commits']: queries.extend([commit_qry, file_qry]) elif repo_context in ['files', 'summary']: queries.extend([file_qry, commit_qry]) @@ -509,7 +509,7 @@ class HomeView(BaseAppView): _query=query_modifier()) } - if repo_context in ['commit', 'changelog']: + if repo_context in ['commit', 'commits']: queries.extend([commit_qry, file_qry]) elif repo_context in ['files', 'summary']: queries.extend([file_qry, commit_qry]) diff --git a/rhodecode/apps/journal/views.py b/rhodecode/apps/journal/views.py --- a/rhodecode/apps/journal/views.py +++ b/rhodecode/apps/journal/views.py @@ -153,7 +153,7 @@ class JournalView(BaseAppView): desc = action_extra() _url = h.route_url('home') if entry.repository is not None: - _url = h.route_url('repo_changelog', + _url = h.route_url('repo_commits', repo_name=entry.repository.repo_name) feed.add_item( @@ -199,7 +199,7 @@ class JournalView(BaseAppView): desc = action_extra() _url = h.route_url('home') if entry.repository is not None: - _url = h.route_url('repo_changelog', + _url = h.route_url('repo_commits', repo_name=entry.repository.repo_name) feed.add_item( diff --git a/rhodecode/apps/repository/__init__.py b/rhodecode/apps/repository/__init__.py --- a/rhodecode/apps/repository/__init__.py +++ b/rhodecode/apps/repository/__init__.py @@ -193,19 +193,27 @@ def includeme(config): name='repo_stats', pattern='/{repo_name:.*?[^/]}/repo_stats/{commit_id}', repo_route=True) - # Changelog + # Commits + config.add_route( + name='repo_commits', + pattern='/{repo_name:.*?[^/]}/commits', repo_route=True) + config.add_route( + name='repo_commits_file', + pattern='/{repo_name:.*?[^/]}/commits/{commit_id}/{f_path:.*}', repo_route=True) + config.add_route( + name='repo_commits_elements', + pattern='/{repo_name:.*?[^/]}/commits_elements', repo_route=True) + config.add_route( + name='repo_commits_elements_file', + pattern='/{repo_name:.*?[^/]}/commits_elements/{commit_id}/{f_path:.*}', repo_route=True) + + # Changelog (old deprecated name for commits page) config.add_route( name='repo_changelog', pattern='/{repo_name:.*?[^/]}/changelog', repo_route=True) config.add_route( name='repo_changelog_file', pattern='/{repo_name:.*?[^/]}/changelog/{commit_id}/{f_path:.*}', repo_route=True) - config.add_route( - name='repo_changelog_elements', - pattern='/{repo_name:.*?[^/]}/changelog_elements', repo_route=True) - config.add_route( - name='repo_changelog_elements_file', - pattern='/{repo_name:.*?[^/]}/changelog_elements/{commit_id}/{f_path:.*}', repo_route=True) # Compare config.add_route( diff --git a/rhodecode/apps/repository/tests/test_repo_changelog.py b/rhodecode/apps/repository/tests/test_repo_changelog.py --- a/rhodecode/apps/repository/tests/test_repo_changelog.py +++ b/rhodecode/apps/repository/tests/test_repo_changelog.py @@ -32,9 +32,10 @@ def route_path(name, params=None, **kwar import urllib base_url = { - 'repo_changelog':'/{repo_name}/changelog', - 'repo_changelog_file':'/{repo_name}/changelog/{commit_id}/{f_path}', - 'repo_changelog_elements':'/{repo_name}/changelog_elements', + 'repo_changelog': '/{repo_name}/changelog', + 'repo_commits': '/{repo_name}/commits', + 'repo_commits_file': '/{repo_name}/commits/{commit_id}/{f_path}', + 'repo_commits_elements': '/{repo_name}/commits_elements', }[name].format(**kwargs) if params: @@ -42,8 +43,23 @@ def route_path(name, params=None, **kwar return base_url +def assert_commits_on_page(response, indexes): + found_indexes = [int(idx) for idx in MATCH_HASH.findall(response.body)] + assert found_indexes == indexes + + class TestChangelogController(TestController): + def test_commits_page(self, backend): + self.log_user() + response = self.app.get( + route_path('repo_commits', repo_name=backend.repo_name)) + + first_idx = -1 + last_idx = -DEFAULT_CHANGELOG_SIZE + self.assert_commit_range_on_page( + response, first_idx, last_idx, backend) + def test_changelog(self, backend): self.log_user() response = self.app.get( @@ -62,6 +78,14 @@ class TestChangelogController(TestContro params=dict(branch=backend.default_branch_name)), status=200) + @pytest.mark.backends("hg", "git") + def test_commits_filtered_by_branch(self, backend): + self.log_user() + self.app.get( + route_path('repo_commits', repo_name=backend.repo_name, + params=dict(branch=backend.default_branch_name)), + status=200) + @pytest.mark.backends("svn") def test_changelog_filtered_by_branch_svn(self, autologin_user, backend): repo = backend['svn-simple-layout'] @@ -70,27 +94,22 @@ class TestChangelogController(TestContro params=dict(branch='trunk')), status=200) - self.assert_commits_on_page( - response, indexes=[15, 12, 7, 3, 2, 1]) + assert_commits_on_page(response, indexes=[15, 12, 7, 3, 2, 1]) - def test_changelog_filtered_by_wrong_branch(self, backend): + def test_commits_filtered_by_wrong_branch(self, backend): self.log_user() branch = 'wrong-branch-name' response = self.app.get( - route_path('repo_changelog', repo_name=backend.repo_name, + route_path('repo_commits', repo_name=backend.repo_name, params=dict(branch=branch)), status=302) - expected_url = '/{repo}/changelog/{branch}'.format( + expected_url = '/{repo}/commits/{branch}'.format( repo=backend.repo_name, branch=branch) assert expected_url in response.location response = response.follow() expected_warning = 'Branch {} is not found.'.format(branch) assert expected_warning in response.body - def assert_commits_on_page(self, response, indexes): - found_indexes = [int(idx) for idx in MATCH_HASH.findall(response.body)] - assert found_indexes == indexes - @pytest.mark.xfail_backends("svn", reason="Depends on branch support") def test_changelog_filtered_by_branch_with_merges( self, autologin_user, backend): @@ -112,21 +131,20 @@ class TestChangelogController(TestContro status=200) @pytest.mark.backends("hg") - def test_changelog_closed_branches(self, autologin_user, backend): + def test_commits_closed_branches(self, autologin_user, backend): repo = backend['closed_branch'] response = self.app.get( - route_path('repo_changelog', repo_name=repo.repo_name, + route_path('repo_commits', repo_name=repo.repo_name, params=dict(branch='experimental')), status=200) - self.assert_commits_on_page( - response, indexes=[3, 1]) + assert_commits_on_page(response, indexes=[3, 1]) def test_changelog_pagination(self, backend): self.log_user() # pagination, walk up to page 6 changelog_url = route_path( - 'repo_changelog', repo_name=backend.repo_name) + 'repo_commits', repo_name=backend.repo_name) for page in range(1, 7): response = self.app.get(changelog_url, {'page': page}) @@ -168,10 +186,10 @@ class TestChangelogController(TestContro '/vcs/exceptions.py', '//vcs/exceptions.py' ]) - def test_changelog_with_filenode(self, backend, test_path): + def test_commits_with_filenode(self, backend, test_path): self.log_user() response = self.app.get( - route_path('repo_changelog_file', repo_name=backend.repo_name, + route_path('repo_commits_file', repo_name=backend.repo_name, commit_id='tip', f_path=test_path), ) @@ -180,16 +198,16 @@ class TestChangelogController(TestContro response.mustcontain('Added not implemented hg backend test case') response.mustcontain('Added BaseChangeset class') - def test_changelog_with_filenode_that_is_dirnode(self, backend): + def test_commits_with_filenode_that_is_dirnode(self, backend): self.log_user() self.app.get( - route_path('repo_changelog_file', repo_name=backend.repo_name, + route_path('repo_commits_file', repo_name=backend.repo_name, commit_id='tip', f_path='/tests'), status=302) - def test_changelog_with_filenode_not_existing(self, backend): + def test_commits_with_filenode_not_existing(self, backend): self.log_user() self.app.get( - route_path('repo_changelog_file', repo_name=backend.repo_name, + route_path('repo_commits_file', repo_name=backend.repo_name, commit_id='tip', f_path='wrong_path'), status=302) diff --git a/rhodecode/apps/repository/tests/test_repo_pullrequests.py b/rhodecode/apps/repository/tests/test_repo_pullrequests.py --- a/rhodecode/apps/repository/tests/test_repo_pullrequests.py +++ b/rhodecode/apps/repository/tests/test_repo_pullrequests.py @@ -40,6 +40,8 @@ def route_path(name, params=None, **kwar base_url = { 'repo_changelog': '/{repo_name}/changelog', 'repo_changelog_file': '/{repo_name}/changelog/{commit_id}/{f_path}', + 'repo_commits': '/{repo_name}/changelog', + 'repo_commits_file': '/{repo_name}/changelog/{commit_id}/{f_path}', 'pullrequest_show': '/{repo_name}/pull-request/{pull_request_id}', 'pullrequest_show_all': '/{repo_name}/pull-request', 'pullrequest_show_all_data': '/{repo_name}/pull-request-data', @@ -998,11 +1000,11 @@ class TestPullrequestsView(object): assert len(target_children) == 1 expected_origin_link = route_path( - 'repo_changelog', + 'repo_commits', repo_name=pull_request.source_repo.scm_instance().name, params=dict(branch='origin')) expected_target_link = route_path( - 'repo_changelog', + 'repo_commits', repo_name=pull_request.target_repo.scm_instance().name, params=dict(branch='target')) assert origin_children[0].attrib['href'] == expected_origin_link diff --git a/rhodecode/apps/repository/views/repo_changelog.py b/rhodecode/apps/repository/views/repo_changelog.py --- a/rhodecode/apps/repository/views/repo_changelog.py +++ b/rhodecode/apps/repository/views/repo_changelog.py @@ -113,7 +113,7 @@ class RepoChangelogView(RepoAppView): h.flash('Branch {} is not found.'.format(h.escape(branch_name)), category='warning') redirect_url = h.route_path( - 'repo_changelog_file', repo_name=repo_name, + 'repo_commits_file', repo_name=repo_name, commit_id=branch_name, f_path=f_path or '') raise HTTPFound(redirect_url) @@ -127,13 +127,13 @@ class RepoChangelogView(RepoAppView): if f_path: # changelog for file return h.route_path( - 'repo_changelog_file', + 'repo_commits_file', repo_name=c.rhodecode_db_repo.repo_name, commit_id=commit_id, f_path=f_path, _query=query_params) else: return h.route_path( - 'repo_changelog', + 'repo_commits', repo_name=c.rhodecode_db_repo.repo_name, _query=query_params) c.total_cs = len(collection) @@ -171,11 +171,18 @@ class RepoChangelogView(RepoAppView): @HasRepoPermissionAnyDecorator( 'repository.read', 'repository.write', 'repository.admin') @view_config( + route_name='repo_commits', request_method='GET', + renderer='rhodecode:templates/commits/changelog.mako') + @view_config( + route_name='repo_commits_file', request_method='GET', + renderer='rhodecode:templates/commits/changelog.mako') + # old routes for backward compat + @view_config( route_name='repo_changelog', request_method='GET', - renderer='rhodecode:templates/changelog/changelog.mako') + renderer='rhodecode:templates/commits/changelog.mako') @view_config( route_name='repo_changelog_file', request_method='GET', - renderer='rhodecode:templates/changelog/changelog.mako') + renderer='rhodecode:templates/commits/changelog.mako') def repo_changelog(self): c = self.load_default_context() @@ -224,7 +231,7 @@ class RepoChangelogView(RepoAppView): except RepositoryError as e: h.flash(safe_str(e), category='warning') redirect_url = h.route_path( - 'repo_changelog', repo_name=self.db_repo_name) + 'repo_commits', repo_name=self.db_repo_name) raise HTTPFound(redirect_url) collection = list(reversed(collection)) else: @@ -246,14 +253,14 @@ class RepoChangelogView(RepoAppView): log.exception(safe_str(e)) h.flash(safe_str(h.escape(e)), category='error') raise HTTPFound( - h.route_path('repo_changelog', repo_name=self.db_repo_name)) + h.route_path('repo_commits', repo_name=self.db_repo_name)) if partial_xhr or self.request.environ.get('HTTP_X_PJAX'): # case when loading dynamic file history in file view # loading from ajax, we don't want the first result, it's popped # in the code above html = render( - 'rhodecode:templates/changelog/changelog_file_history.mako', + 'rhodecode:templates/commits/changelog_file_history.mako', self._get_template_context(c), self.request) return Response(html) @@ -271,14 +278,14 @@ class RepoChangelogView(RepoAppView): @HasRepoPermissionAnyDecorator( 'repository.read', 'repository.write', 'repository.admin') @view_config( - route_name='repo_changelog_elements', request_method=('GET', 'POST'), - renderer='rhodecode:templates/changelog/changelog_elements.mako', + route_name='repo_commits_elements', request_method=('GET', 'POST'), + renderer='rhodecode:templates/commits/changelog_elements.mako', xhr=True) @view_config( - route_name='repo_changelog_elements_file', request_method=('GET', 'POST'), - renderer='rhodecode:templates/changelog/changelog_elements.mako', + route_name='repo_commits_elements_file', request_method=('GET', 'POST'), + renderer='rhodecode:templates/commits/changelog_elements.mako', xhr=True) - def repo_changelog_elements(self): + def repo_commits_elements(self): c = self.load_default_context() commit_id = self.request.matchdict.get('commit_id') f_path = self._get_f_path(self.request.matchdict) @@ -312,7 +319,7 @@ class RepoChangelogView(RepoAppView): except (RepositoryError, CommitDoesNotExistError, Exception) as e: log.exception(safe_str(e)) raise HTTPFound( - h.route_path('repo_changelog', repo_name=self.db_repo_name)) + h.route_path('repo_commits', repo_name=self.db_repo_name)) collection = base_commit.get_path_history( f_path, limit=hist_limit, pre_load=pre_load) diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -2061,7 +2061,8 @@ def reviewer_as_json(*args, **kwargs): def get_repo_view_type(request): route_name = request.matched_route.name route_to_view_type = { - 'repo_changelog': 'changelog', + 'repo_changelog': 'commits', + 'repo_commits': 'commits', 'repo_files': 'files', 'repo_summary': 'summary', 'repo_commit': 'commit' diff --git a/rhodecode/lib/vcs/backends/hg/repository.py b/rhodecode/lib/vcs/backends/hg/repository.py --- a/rhodecode/lib/vcs/backends/hg/repository.py +++ b/rhodecode/lib/vcs/backends/hg/repository.py @@ -478,11 +478,11 @@ class MercurialRepository(BaseRepository ``end`` could not be found. """ # actually we should check now if it's not an empty repo - branch_ancestors = False if self.is_empty(): raise EmptyRepositoryError("There are no commits yet") self._validate_branch_name(branch_name) + branch_ancestors = False if start_id is not None: self._validate_commit_id(start_id) c_start = self.get_commit(commit_id=start_id) diff --git a/rhodecode/lib/vcs/backends/svn/repository.py b/rhodecode/lib/vcs/backends/svn/repository.py --- a/rhodecode/lib/vcs/backends/svn/repository.py +++ b/rhodecode/lib/vcs/backends/svn/repository.py @@ -277,7 +277,7 @@ class SubversionRepository(base.BaseRepo try: commit_id = self.commit_ids[commit_idx] except IndexError: - raise CommitDoesNotExistError + raise CommitDoesNotExistError('No commit with idx: {}'.format(commit_idx)) commit_id = self._sanitize_commit_id(commit_id) commit = SubversionCommit(repository=self, commit_id=commit_id) diff --git a/rhodecode/public/js/rhodecode/base/keyboard-bindings.js b/rhodecode/public/js/rhodecode/base/keyboard-bindings.js --- a/rhodecode/public/js/rhodecode/base/keyboard-bindings.js +++ b/rhodecode/public/js/rhodecode/base/keyboard-bindings.js @@ -98,7 +98,7 @@ function setRCMouseBindings(repoName, re }); Mousetrap.bind(['g c'], function(e) { window.location = pyroutes.url( - 'repo_changelog', {'repo_name': repoName}); + 'repo_commits', {'repo_name': repoName}); }); Mousetrap.bind(['g F'], function(e) { window.location = pyroutes.url( diff --git a/rhodecode/public/js/rhodecode/routes.js b/rhodecode/public/js/rhodecode/routes.js --- a/rhodecode/public/js/rhodecode/routes.js +++ b/rhodecode/public/js/rhodecode/routes.js @@ -196,14 +196,17 @@ function registerRCRoutes() { pyroutes.register('repo_files_edit_file', '/%(repo_name)s/edit_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); pyroutes.register('repo_files_update_file', '/%(repo_name)s/update_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); pyroutes.register('repo_files_add_file', '/%(repo_name)s/add_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); + pyroutes.register('repo_files_upload_file', '/%(repo_name)s/upload_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); pyroutes.register('repo_files_create_file', '/%(repo_name)s/create_file/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); pyroutes.register('repo_refs_data', '/%(repo_name)s/refs-data', ['repo_name']); pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']); pyroutes.register('repo_stats', '/%(repo_name)s/repo_stats/%(commit_id)s', ['repo_name', 'commit_id']); + pyroutes.register('repo_commits', '/%(repo_name)s/commits', ['repo_name']); + pyroutes.register('repo_commits_file', '/%(repo_name)s/commits/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); + pyroutes.register('repo_commits_elements', '/%(repo_name)s/commits_elements', ['repo_name']); + pyroutes.register('repo_commits_elements_file', '/%(repo_name)s/commits_elements/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); pyroutes.register('repo_changelog', '/%(repo_name)s/changelog', ['repo_name']); pyroutes.register('repo_changelog_file', '/%(repo_name)s/changelog/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); - pyroutes.register('repo_changelog_elements', '/%(repo_name)s/changelog_elements', ['repo_name']); - pyroutes.register('repo_changelog_elements_file', '/%(repo_name)s/changelog_elements/%(commit_id)s/%(f_path)s', ['repo_name', 'commit_id', 'f_path']); pyroutes.register('repo_compare_select', '/%(repo_name)s/compare', ['repo_name']); pyroutes.register('repo_compare', '/%(repo_name)s/compare/%(source_ref_type)s@%(source_ref)s...%(target_ref_type)s@%(target_ref)s', ['repo_name', 'source_ref_type', 'source_ref', 'target_ref_type', 'target_ref']); pyroutes.register('tags_home', '/%(repo_name)s/tags', ['repo_name']); diff --git a/rhodecode/public/js/src/rhodecode/changelog.js b/rhodecode/public/js/src/rhodecode/changelog.js --- a/rhodecode/public/js/src/rhodecode/changelog.js +++ b/rhodecode/public/js/src/rhodecode/changelog.js @@ -112,10 +112,10 @@ var CommitsController = function () { } if (urlData['commit_id'] && urlData['f_path']) { - return pyroutes.url('repo_changelog_elements_file', urlData); + return pyroutes.url('repo_commits_elements_file', urlData); } else { - return pyroutes.url('repo_changelog_elements', urlData); + return pyroutes.url('repo_commits_elements', urlData); } }; diff --git a/rhodecode/templates/base/base.mako b/rhodecode/templates/base/base.mako --- a/rhodecode/templates/base/base.mako +++ b/rhodecode/templates/base/base.mako @@ -283,7 +283,7 @@