Revision
diff --git a/swh/web/ui/tests/views/test_browse.py b/swh/web/ui/tests/views/test_browse.py
--- a/swh/web/ui/tests/views/test_browse.py
+++ b/swh/web/ui/tests/views/test_browse.py
@@ -919,6 +919,88 @@
@patch('swh.web.ui.views.browse.api')
@istest
+ def browse_revision_log_by_ko_not_found(self, mock_api):
+ # given
+ mock_api.api_revision_log_by.side_effect = NotFoundExc('Not found!')
+
+ # when
+ rv = self.client.get('/browse/revision/origin/9/log/')
+
+ # then
+ self.assertEqual(rv.status_code, 200)
+ self.assert_template_used('revision-log.html')
+ self.assertEqual(self.get_context_variable('origin_id'), 9)
+ self.assertEqual(
+ self.get_context_variable('message'),
+ 'Not found!')
+ self.assertEqual(self.get_context_variable('revisions'), [])
+
+ mock_api.api_revision_log_by.assert_called_once_with(
+ 9, 'refs/heads/master', None)
+
+ @patch('swh.web.ui.views.browse.api')
+ @istest
+ def browse_revision_log_by_ko_bad_input(self, mock_api):
+ # given
+ mock_api.api_revision_log.side_effect = BadInputExc('wrong input!')
+
+ # when
+ rv = self.client.get('/browse/revision/abcd/log/')
+
+ # then
+ self.assertEqual(rv.status_code, 200)
+ self.assert_template_used('revision-log.html')
+ self.assertEqual(self.get_context_variable('sha1_git'), 'abcd')
+ self.assertEqual(
+ self.get_context_variable('message'),
+ 'wrong input!')
+ self.assertEqual(self.get_context_variable('revisions'), [])
+
+ mock_api.api_revision_log.assert_called_once_with('abcd')
+
+ @patch('swh.web.ui.views.browse.api')
+ @istest
+ def browse_revision_log_by(self, mock_api):
+ # given
+ stub_revisions = [{
+ 'id': 'd770e558e21961ad6cfdf0ff7df0eb5d7d4f0754',
+ 'date': 'Sun, 05 Jul 2015 18:01:52 GMT',
+ 'committer': {
+ 'email': 'torvalds@linux-foundation.org',
+ 'name': 'Linus Torvalds'
+ },
+ 'committer_date': 'Sun, 05 Jul 2015 18:01:52 GMT',
+ 'type': 'git',
+ 'author': {
+ 'email': 'torvalds@linux-foundation.org',
+ 'name': 'Linus Torvalds'
+ },
+ 'message': 'Linux 4.2-rc1\n',
+ 'synthetic': False,
+ 'directory_url': '/api/1/directory/'
+ '2a1dbabeed4dcf1f4a4c441993b2ffc9d972780b/',
+ 'parent_url': [
+ '/api/1/revision/a585d2b738bfa26326b3f1f40f0f1eda0c067ccf/'
+ ],
+ }]
+ mock_api.api_revision_log_by.return_value = stub_revisions
+
+ # when
+ rv = self.client.get('/browse/revision/origin/2/log/')
+
+ # then
+ self.assertEqual(rv.status_code, 200)
+ self.assert_template_used('revision-log.html')
+ self.assertEqual(self.get_context_variable('origin_id'), 2)
+ self.assertTrue(
+ isinstance(self.get_context_variable('revisions'), map))
+ self.assertIsNone(self.get_context_variable('message'))
+
+ mock_api.api_revision_log_by.assert_called_once_with(
+ 2, 'refs/heads/master', None)
+
+ @patch('swh.web.ui.views.browse.api')
+ @istest
def browse_revision_history_ko_not_found(self, mock_api):
# given
mock_api.api_revision_history.side_effect = NotFoundExc(
diff --git a/swh/web/ui/views/browse.py b/swh/web/ui/views/browse.py
--- a/swh/web/ui/views/browse.py
+++ b/swh/web/ui/views/browse.py
@@ -335,10 +335,11 @@
@app.route('/browse/revision/
/log/')
@set_renderers(HTMLRenderer)
def browse_revision_log(sha1_git):
- """Browse revision with sha1_git.
+ """Browse revision with sha1_git's log.
"""
env = {'sha1_git': sha1_git,
+ 'sha1_url': '/browse/revision/' + sha1_git + '/',
'message': None,
'revisions': []}
@@ -351,6 +352,54 @@
return render_template('revision-log.html', **env)
+@app.route('/browse/revision'
+ '/origin/log/')
+@app.route('/browse/revision'
+ '/origin//log/')
+@app.route('/browse/revision'
+ '/origin/'
+ '/branch//log/')
+@app.route('/browse/revision'
+ '/origin/'
+ '/branch/'
+ '/ts//log/')
+@app.route('/browse/revision'
+ '/origin/'
+ '/ts//log/')
+@set_renderers(HTMLRenderer)
+def browse_revision_log_by(origin_id,
+ branch_name='refs/heads/master',
+ timestamp=None):
+ """Browse the revision described by origin, branch name and timestamp's
+ log
+
+ Args:
+ origin_id: the revision's origin
+ branch_name: the revision's branch
+ timestamp: the requested timeframe for the revision
+
+ Returns:
+ The revision log of the described revision as a list of revisions
+ if it is found.
+ """
+ env = {'sha1_git': None,
+ 'origin_id': origin_id,
+ 'origin_url': '/browse/origin/' + str(origin_id) + '/',
+ 'branch_name': branch_name,
+ 'timestamp': timestamp,
+ 'message': None,
+ 'revisions': []}
+
+ try:
+ revisions = api.api_revision_log_by(
+ origin_id, branch_name, timestamp)
+ env['revisions'] = map(utils.prepare_data_for_view, revisions)
+ except (NotFoundExc, BadInputExc) as e:
+ env['message'] = str(e)
+
+ return render_template('revision-log.html', **env)
+
+
@app.route('/browse/revision//history//')
@set_renderers(HTMLRenderer)
def browse_revision_history(sha1_git_root, sha1_git):