##// END OF EJS Templates
Use changelog controller for displaying history of files....
marcink -
r3760:6302a142 beta
parent child Browse files
Show More
@@ -589,10 +589,6 b' def make_map(config):'
589 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
589 rmap.connect('shortlog_home', '/{repo_name:.*?}/shortlog',
590 controller='shortlog', conditions=dict(function=check_repo))
590 controller='shortlog', conditions=dict(function=check_repo))
591
591
592 rmap.connect('shortlog_file_home', '/{repo_name:.*?}/shortlog/{revision}/{f_path:.*}',
593 controller='shortlog', f_path=None,
594 conditions=dict(function=check_repo))
595
596 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
592 rmap.connect('branches_home', '/{repo_name:.*?}/branches',
597 controller='branches', conditions=dict(function=check_repo))
593 controller='branches', conditions=dict(function=check_repo))
598
594
@@ -605,6 +601,10 b' def make_map(config):'
605 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
601 rmap.connect('changelog_home', '/{repo_name:.*?}/changelog',
606 controller='changelog', conditions=dict(function=check_repo))
602 controller='changelog', conditions=dict(function=check_repo))
607
603
604 rmap.connect('changelog_file_home', '/{repo_name:.*?}/changelog/{revision}/{f_path:.*}',
605 controller='changelog', f_path=None,
606 conditions=dict(function=check_repo))
607
608 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
608 rmap.connect('changelog_details', '/{repo_name:.*?}/changelog_details/{cs}',
609 controller='changelog', action='changelog_details',
609 controller='changelog', action='changelog_details',
610 conditions=dict(function=check_repo))
610 conditions=dict(function=check_repo))
@@ -36,7 +36,8 b' from rhodecode.lib.base import BaseRepoC'
36 from rhodecode.lib.helpers import RepoPage
36 from rhodecode.lib.helpers import RepoPage
37 from rhodecode.lib.compat import json
37 from rhodecode.lib.compat import json
38 from rhodecode.lib.graphmod import _colored, _dagwalker
38 from rhodecode.lib.graphmod import _colored, _dagwalker
39 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError
39 from rhodecode.lib.vcs.exceptions import RepositoryError, ChangesetDoesNotExistError,\
40 ChangesetError, NodeDoesNotExistError
40 from rhodecode.lib.utils2 import safe_int
41 from rhodecode.lib.utils2 import safe_int
41
42
42 log = logging.getLogger(__name__)
43 log = logging.getLogger(__name__)
@@ -75,7 +76,7 b' class ChangelogController(BaseRepoContro'
75 @LoginRequired()
76 @LoginRequired()
76 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
77 @HasRepoPermissionAnyDecorator('repository.read', 'repository.write',
77 'repository.admin')
78 'repository.admin')
78 def index(self):
79 def index(self, repo_name, revision=None, f_path=None):
79 limit = 100
80 limit = 100
80 default = 20
81 default = 20
81 if request.GET.get('size'):
82 if request.GET.get('size'):
@@ -88,7 +89,25 b' class ChangelogController(BaseRepoContro'
88 c.size = max(c.size, 1)
89 c.size = max(c.size, 1)
89 p = safe_int(request.GET.get('page', 1), 1)
90 p = safe_int(request.GET.get('page', 1), 1)
90 branch_name = request.GET.get('branch', None)
91 branch_name = request.GET.get('branch', None)
92 c.changelog_for_path = f_path
91 try:
93 try:
94
95 if f_path:
96 log.debug('generating changelog for path %s' % f_path)
97 # get the history for the file !
98 tip_cs = c.rhodecode_repo.get_changeset()
99 try:
100 collection = tip_cs.get_file_history(f_path)
101 except (NodeDoesNotExistError, ChangesetError):
102 #this node is not present at tip !
103 try:
104 cs = self.__get_cs_or_redirect(revision, repo_name)
105 collection = cs.get_file_history(f_path)
106 except RepositoryError, e:
107 h.flash(str(e), category='warning')
108 redirect(h.url('changelog_home', repo_name=repo_name))
109 collection = list(reversed(collection))
110 else:
92 collection = c.rhodecode_repo.get_changesets(start=0,
111 collection = c.rhodecode_repo.get_changesets(start=0,
93 branch_name=branch_name)
112 branch_name=branch_name)
94 c.total_cs = len(collection)
113 c.total_cs = len(collection)
@@ -107,9 +126,10 b' class ChangelogController(BaseRepoContro'
107 c.branch_name = branch_name
126 c.branch_name = branch_name
108 c.branch_filters = [('', _('All Branches'))] + \
127 c.branch_filters = [('', _('All Branches'))] + \
109 [(k, k) for k in c.rhodecode_repo.branches.keys()]
128 [(k, k) for k in c.rhodecode_repo.branches.keys()]
110
129 _revs = []
111 self._graph(c.rhodecode_repo, [x.revision for x in c.pagination],
130 if not f_path:
112 c.total_cs, c.size, p)
131 _revs = [x.revision for x in c.pagination]
132 self._graph(c.rhodecode_repo, _revs, c.total_cs, c.size, p)
113
133
114 return render('changelog/changelog.html')
134 return render('changelog/changelog.html')
115
135
@@ -25,6 +25,7 b''
25 <div class="table">
25 <div class="table">
26 % if c.pagination:
26 % if c.pagination:
27 <div id="graph">
27 <div id="graph">
28 <div style="display:${'none' if c.changelog_for_path else ''}">
28 <div class="info_box" style="clear: both;padding: 10px 6px;min-height: 12px;text-align: right;">
29 <div class="info_box" style="clear: both;padding: 10px 6px;min-height: 12px;text-align: right;">
29 <a href="#" class="ui-btn small" id="rev_range_container" style="display:none"></a>
30 <a href="#" class="ui-btn small" id="rev_range_container" style="display:none"></a>
30 <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a>
31 <a href="#" class="ui-btn small" id="rev_range_clear" style="display:none">${_('Clear selection')}</a>
@@ -46,6 +47,7 b''
46 ${h.end_form()}
47 ${h.end_form()}
47 <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div>
48 <div style="float:right">${h.select('branch_filter',c.branch_name,c.branch_filters)}</div>
48 </div>
49 </div>
50 </div>
49 <div id="graph_nodes">
51 <div id="graph_nodes">
50 <canvas id="graph_canvas"></canvas>
52 <canvas id="graph_canvas"></canvas>
51 </div>
53 </div>
@@ -56,7 +58,11 b''
56 %for cnt,cs in enumerate(c.pagination):
58 %for cnt,cs in enumerate(c.pagination):
57 <tr id="chg_${cnt+1}" class="container ${'tablerow%s' % (cnt%2)}">
59 <tr id="chg_${cnt+1}" class="container ${'tablerow%s' % (cnt%2)}">
58 <td class="checkbox">
60 <td class="checkbox">
61 %if c.changelog_for_path:
62 ${h.checkbox(cs.raw_id,class_="changeset_range", disabled="disabled")}
63 %else:
59 ${h.checkbox(cs.raw_id,class_="changeset_range")}
64 ${h.checkbox(cs.raw_id,class_="changeset_range")}
65 %endif
60 <td class="status">
66 <td class="status">
61 %if c.statuses.get(cs.raw_id):
67 %if c.statuses.get(cs.raw_id):
62 <div class="changeset-status-ico">
68 <div class="changeset-status-ico">
@@ -8,7 +8,7 b''
8 ${h.select('diff1',c.file_changeset.raw_id,c.file_history)}
8 ${h.select('diff1',c.file_changeset.raw_id,c.file_history)}
9 ${h.submit('diff',_('Diff to revision'),class_="ui-btn")}
9 ${h.submit('diff',_('Diff to revision'),class_="ui-btn")}
10 ${h.submit('show_rev',_('Show at revision'),class_="ui-btn")}
10 ${h.submit('show_rev',_('Show at revision'),class_="ui-btn")}
11 ${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")}
11 ${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")}
12 ${h.hidden('annotate', c.annotate)}
12 ${h.hidden('annotate', c.annotate)}
13 ${h.end_form()}
13 ${h.end_form()}
14 </div>
14 </div>
@@ -124,3 +124,52 b' class TestChangelogController(TestContro'
124 response.mustcontain(
124 response.mustcontain(
125 """<span class="changeset_hash">r515:636ed213f2f1</span>"""
125 """<span class="changeset_hash">r515:636ed213f2f1</span>"""
126 )
126 )
127
128 def test_index_hg_with_filenode(self):
129 self.log_user()
130 response = self.app.get(url(controller='changelog', action='index',
131 revision='tip', f_path='/vcs/exceptions.py',
132 repo_name=HG_REPO))
133 #history commits messages
134 response.mustcontain('Added exceptions module, this time for real')
135 response.mustcontain('Added not implemented hg backend test case')
136 response.mustcontain('Added BaseChangeset class')
137 # Test response...
138
139 def test_index_git_with_filenode(self):
140 self.log_user()
141 response = self.app.get(url(controller='changelog', action='index',
142 revision='tip', f_path='/vcs/exceptions.py',
143 repo_name=GIT_REPO))
144 #history commits messages
145 response.mustcontain('Added exceptions module, this time for real')
146 response.mustcontain('Added not implemented hg backend test case')
147 response.mustcontain('Added BaseChangeset class')
148
149 def test_index_hg_with_filenode_that_is_dirnode(self):
150 self.log_user()
151 response = self.app.get(url(controller='changelog', action='index',
152 revision='tip', f_path='/tests',
153 repo_name=HG_REPO))
154 self.assertEqual(response.status, '302 Found')
155
156 def test_index_git_with_filenode_that_is_dirnode(self):
157 self.log_user()
158 response = self.app.get(url(controller='changelog', action='index',
159 revision='tip', f_path='/tests',
160 repo_name=GIT_REPO))
161 self.assertEqual(response.status, '302 Found')
162
163 def test_index_hg_with_filenode_not_existing(self):
164 self.log_user()
165 response = self.app.get(url(controller='changelog', action='index',
166 revision='tip', f_path='/wrong_path',
167 repo_name=HG_REPO))
168 self.assertEqual(response.status, '302 Found')
169
170 def test_index_git_with_filenode_not_existing(self):
171 self.log_user()
172 response = self.app.get(url(controller='changelog', action='index',
173 revision='tip', f_path='/wrong_path',
174 repo_name=GIT_REPO))
175 self.assertEqual(response.status, '302 Found')
@@ -14,52 +14,3 b' class TestShortlogController(TestControl'
14 response = self.app.get(url(controller='shortlog', action='index',
14 response = self.app.get(url(controller='shortlog', action='index',
15 repo_name=GIT_REPO))
15 repo_name=GIT_REPO))
16 # Test response...
16 # Test response...
17
18 def test_index_hg_with_filenode(self):
19 self.log_user()
20 response = self.app.get(url(controller='shortlog', action='index',
21 revision='tip', f_path='/vcs/exceptions.py',
22 repo_name=HG_REPO))
23 #history commits messages
24 response.mustcontain('Added exceptions module, this time for real')
25 response.mustcontain('Added not implemented hg backend test case')
26 response.mustcontain('Added BaseChangeset class')
27 # Test response...
28
29 def test_index_git_with_filenode(self):
30 self.log_user()
31 response = self.app.get(url(controller='shortlog', action='index',
32 revision='tip', f_path='/vcs/exceptions.py',
33 repo_name=GIT_REPO))
34 #history commits messages
35 response.mustcontain('Added exceptions module, this time for real')
36 response.mustcontain('Added not implemented hg backend test case')
37 response.mustcontain('Added BaseChangeset class')
38
39 def test_index_hg_with_filenode_that_is_dirnode(self):
40 self.log_user()
41 response = self.app.get(url(controller='shortlog', action='index',
42 revision='tip', f_path='/tests',
43 repo_name=HG_REPO))
44 self.assertEqual(response.status, '302 Found')
45
46 def test_index_git_with_filenode_that_is_dirnode(self):
47 self.log_user()
48 response = self.app.get(url(controller='shortlog', action='index',
49 revision='tip', f_path='/tests',
50 repo_name=GIT_REPO))
51 self.assertEqual(response.status, '302 Found')
52
53 def test_index_hg_with_filenode_not_existing(self):
54 self.log_user()
55 response = self.app.get(url(controller='shortlog', action='index',
56 revision='tip', f_path='/wrong_path',
57 repo_name=HG_REPO))
58 self.assertEqual(response.status, '302 Found')
59
60 def test_index_git_with_filenode_not_existing(self):
61 self.log_user()
62 response = self.app.get(url(controller='shortlog', action='index',
63 revision='tip', f_path='/wrong_path',
64 repo_name=GIT_REPO))
65 self.assertEqual(response.status, '302 Found')
General Comments 0
You need to be logged in to leave comments. Login now