# HG changeset patch # User Marcin Kuzminski # Date 2013-04-15 19:58:40 # Node ID 6302a1423a4e6499bc650b6a4dd28ce413e47ab8 # Parent 12ca667b69b6f183293cc863bdcb48ae6d4b8222 Use changelog controller for displaying history of files. step 1 for removing obsolete shortlog diff --git a/rhodecode/config/routing.py b/rhodecode/config/routing.py --- a/rhodecode/config/routing.py +++ b/rhodecode/config/routing.py @@ -589,10 +589,6 @@ def make_map(config): rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog', controller='shortlog', conditions=dict(function=check_repo)) - rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}', - controller='shortlog', f_path=None, - conditions=dict(function=check_repo)) - rmap.connect('branches_home', '/{repo_name:.*?}/branches', controller='branches', conditions=dict(function=check_repo)) @@ -605,6 +601,10 @@ def make_map(config): rmap.connect('changelog_home', '/{repo_name:.*?}/changelog', controller='changelog', conditions=dict(function=check_repo)) + rmap.connect('changelog_file_home', '/{repo_name:.*?}/changelog/{revision}/{f_path:.*}', + controller='changelog', f_path=None, + conditions=dict(function=check_repo)) + rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}', controller='changelog', action='changelog_details', conditions=dict(function=check_repo)) diff --git a/rhodecode/controllers/changelog.py b/rhodecode/controllers/changelog.py --- a/rhodecode/controllers/changelog.py +++ b/rhodecode/controllers/changelog.py @@ -36,7 +36,8 @@ from rhodecode.lib.base import BaseRepoC from rhodecode.lib.helpers import RepoPage from rhodecode.lib.compat import json from rhodecode.lib.graphmod import _colored, _dagwalker -from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError +from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\ + ChangesetError, NodeDoesNotExistError from rhodecode.lib.utils2 import safe_int log = logging.getLogger(__name__) @@ -75,7 +76,7 @@ class ChangelogController(BaseRepoContro @LoginRequired() @HasRepoPermissionAnyDecorator('repository.read', 'repository.write', 'repository.admin') - def index(self): + def index(self, repo_name, revision=None, f_path=None): limit = 100 default = 20 if request.GET.get('size'): @@ -88,9 +89,27 @@ class ChangelogController(BaseRepoContro c.size = max(c.size, 1) p = safe_int(request.GET.get('page', 1), 1) branch_name = request.GET.get('branch', None) + c.changelog_for_path = f_path try: - collection = c.rhodecode_repo.get_changesets(start=0, - branch_name=branch_name) + + if f_path: + log.debug('generating changelog for path %s' % f_path) + # get the history for the file ! + tip_cs = c.rhodecode_repo.get_changeset() + try: + collection = tip_cs.get_file_history(f_path) + except (NodeDoesNotExistError, ChangesetError): + #this node is not present at tip ! + try: + cs = self.__get_cs_or_redirect(revision, repo_name) + collection = cs.get_file_history(f_path) + except RepositoryError, e: + h.flash(str(e), category='warning') + redirect(h.url('changelog_home', repo_name=repo_name)) + collection = list(reversed(collection)) + else: + collection = c.rhodecode_repo.get_changesets(start=0, + branch_name=branch_name) c.total_cs = len(collection) c.pagination = RepoPage(collection, page=p, item_count=c.total_cs, @@ -107,9 +126,10 @@ class ChangelogController(BaseRepoContro c.branch_name = branch_name c.branch_filters = [('', _('All Branches'))] + \ [(k, k) for k in c.rhodecode_repo.branches.keys()] - - self._graph(c.rhodecode_repo, [x.revision for x in c.pagination], - c.total_cs, c.size, p) + _revs = [] + if not f_path: + _revs = [x.revision for x in c.pagination] + self._graph(c.rhodecode_repo, _revs, c.total_cs, c.size, p) return render('changelog/changelog.html') diff --git a/rhodecode/templates/changelog/changelog.html b/rhodecode/templates/changelog/changelog.html --- a/rhodecode/templates/changelog/changelog.html +++ b/rhodecode/templates/changelog/changelog.html @@ -25,26 +25,28 @@
% if c.pagination:
-
- - +
+
+ + - %if c.rhodecode_db_repo.fork: - ${_('Compare fork with parent')} - %endif - %if h.is_hg(c.rhodecode_repo): - ${_('Open new pull request')} - %endif -
-
- ${h.form(h.url.current(),method='get')} -
- ${h.submit('set',_('Show'),class_="ui-btn")} - ${h.text('size',size=1,value=c.size)} - ${_('revisions')} + %if c.rhodecode_db_repo.fork: + ${_('Compare fork with parent')} + %endif + %if h.is_hg(c.rhodecode_repo): + ${_('Open new pull request')} + %endif
- ${h.end_form()} -
${h.select('branch_filter',c.branch_name,c.branch_filters)}
+
+ ${h.form(h.url.current(),method='get')} +
+ ${h.submit('set',_('Show'),class_="ui-btn")} + ${h.text('size',size=1,value=c.size)} + ${_('revisions')} +
+ ${h.end_form()} +
${h.select('branch_filter',c.branch_name,c.branch_filters)}
+
@@ -56,7 +58,11 @@ %for cnt,cs in enumerate(c.pagination): - ${h.checkbox(cs.raw_id,class_="changeset_range")} + %if c.changelog_for_path: + ${h.checkbox(cs.raw_id,class_="changeset_range", disabled="disabled")} + %else: + ${h.checkbox(cs.raw_id,class_="changeset_range")} + %endif %if c.statuses.get(cs.raw_id):
diff --git a/rhodecode/templates/files/files_history_box.html b/rhodecode/templates/files/files_history_box.html --- a/rhodecode/templates/files/files_history_box.html +++ b/rhodecode/templates/files/files_history_box.html @@ -8,7 +8,7 @@ ${h.select('diff1',c.file_changeset.raw_id,c.file_history)} ${h.submit('diff',_('Diff to revision'),class_="ui-btn")} ${h.submit('show_rev',_('Show at revision'),class_="ui-btn")} - ${h.link_to(_('Show full history'),h.url('shortlog_file_home',repo_name=c.repo_name, revision=c.file_changeset.raw_id, f_path=c.f_path),class_="ui-btn")} + ${h.link_to(_('Show full history'),h.url('changelog_file_home',repo_name=c.repo_name, revision=c.file_changeset.raw_id, f_path=c.f_path),class_="ui-btn")} ${h.hidden('annotate', c.annotate)} ${h.end_form()}
diff --git a/rhodecode/tests/functional/test_changelog.py b/rhodecode/tests/functional/test_changelog.py --- a/rhodecode/tests/functional/test_changelog.py +++ b/rhodecode/tests/functional/test_changelog.py @@ -124,3 +124,52 @@ class TestChangelogController(TestContro response.mustcontain( """r515:636ed213f2f1""" ) + + def test_index_hg_with_filenode(self): + self.log_user() + response = self.app.get(url(controller='changelog', action='index', + revision='tip', f_path='/vcs/exceptions.py', + repo_name=HG_REPO)) + #history commits messages + response.mustcontain('Added exceptions module, this time for real') + response.mustcontain('Added not implemented hg backend test case') + response.mustcontain('Added BaseChangeset class') + # Test response... + + def test_index_git_with_filenode(self): + self.log_user() + response = self.app.get(url(controller='changelog', action='index', + revision='tip', f_path='/vcs/exceptions.py', + repo_name=GIT_REPO)) + #history commits messages + response.mustcontain('Added exceptions module, this time for real') + response.mustcontain('Added not implemented hg backend test case') + response.mustcontain('Added BaseChangeset class') + + def test_index_hg_with_filenode_that_is_dirnode(self): + self.log_user() + response = self.app.get(url(controller='changelog', action='index', + revision='tip', f_path='/tests', + repo_name=HG_REPO)) + self.assertEqual(response.status, '302 Found') + + def test_index_git_with_filenode_that_is_dirnode(self): + self.log_user() + response = self.app.get(url(controller='changelog', action='index', + revision='tip', f_path='/tests', + repo_name=GIT_REPO)) + self.assertEqual(response.status, '302 Found') + + def test_index_hg_with_filenode_not_existing(self): + self.log_user() + response = self.app.get(url(controller='changelog', action='index', + revision='tip', f_path='/wrong_path', + repo_name=HG_REPO)) + self.assertEqual(response.status, '302 Found') + + def test_index_git_with_filenode_not_existing(self): + self.log_user() + response = self.app.get(url(controller='changelog', action='index', + revision='tip', f_path='/wrong_path', + repo_name=GIT_REPO)) + self.assertEqual(response.status, '302 Found') diff --git a/rhodecode/tests/functional/test_shortlog.py b/rhodecode/tests/functional/test_shortlog.py --- a/rhodecode/tests/functional/test_shortlog.py +++ b/rhodecode/tests/functional/test_shortlog.py @@ -14,52 +14,3 @@ class TestShortlogController(TestControl response = self.app.get(url(controller='shortlog', action='index', repo_name=GIT_REPO)) # Test response... - - def test_index_hg_with_filenode(self): - self.log_user() - response = self.app.get(url(controller='shortlog', action='index', - revision='tip', f_path='/vcs/exceptions.py', - repo_name=HG_REPO)) - #history commits messages - response.mustcontain('Added exceptions module, this time for real') - response.mustcontain('Added not implemented hg backend test case') - response.mustcontain('Added BaseChangeset class') - # Test response... - - def test_index_git_with_filenode(self): - self.log_user() - response = self.app.get(url(controller='shortlog', action='index', - revision='tip', f_path='/vcs/exceptions.py', - repo_name=GIT_REPO)) - #history commits messages - response.mustcontain('Added exceptions module, this time for real') - response.mustcontain('Added not implemented hg backend test case') - response.mustcontain('Added BaseChangeset class') - - def test_index_hg_with_filenode_that_is_dirnode(self): - self.log_user() - response = self.app.get(url(controller='shortlog', action='index', - revision='tip', f_path='/tests', - repo_name=HG_REPO)) - self.assertEqual(response.status, '302 Found') - - def test_index_git_with_filenode_that_is_dirnode(self): - self.log_user() - response = self.app.get(url(controller='shortlog', action='index', - revision='tip', f_path='/tests', - repo_name=GIT_REPO)) - self.assertEqual(response.status, '302 Found') - - def test_index_hg_with_filenode_not_existing(self): - self.log_user() - response = self.app.get(url(controller='shortlog', action='index', - revision='tip', f_path='/wrong_path', - repo_name=HG_REPO)) - self.assertEqual(response.status, '302 Found') - - def test_index_git_with_filenode_not_existing(self): - self.log_user() - response = self.app.get(url(controller='shortlog', action='index', - revision='tip', f_path='/wrong_path', - repo_name=GIT_REPO)) - self.assertEqual(response.status, '302 Found')