Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/views/browse.py
Show First 20 Lines • Show All 292 Lines • ▼ Show 20 Lines | def browse_release(sha1_git): | ||||
except (NotFoundExc, BadInputExc) as e: | except (NotFoundExc, BadInputExc) as e: | ||||
env['message'] = str(e) | env['message'] = str(e) | ||||
return render_template('release.html', **env) | return render_template('release.html', **env) | ||||
@app.route('/browse/revision/') | @app.route('/browse/revision/') | ||||
@app.route('/browse/revision/<string:sha1_git>/') | @app.route('/browse/revision/<string:sha1_git>/') | ||||
@app.route('/browse/revision/<string:sha1_git>/prev/<path:prev_sha1s>/') | |||||
@set_renderers(HTMLRenderer) | @set_renderers(HTMLRenderer) | ||||
def browse_revision(sha1_git): | def browse_revision(sha1_git, prev_sha1s=None): | ||||
"""Browse revision with sha1_git. | """Browse the revision with git SHA1 sha1_git_cur, while optionally keeping | ||||
the context from which we came as a list of previous (i.e. later) | |||||
revisions' sha1s. | |||||
Args: | |||||
sha1_git: the requested revision's sha1_git. | |||||
prev_sha1s: an optional string of /-separated sha1s representing our | |||||
context, ordered by descending revision date. | |||||
Returns: | |||||
Information about revision of git SHA1 sha1_git_cur, with relevant URLS | |||||
pointing to the context augmented with sha1_git_cur. | |||||
Example: | |||||
GET /browse/revision/ | |||||
""" | """ | ||||
env = {'sha1_git': sha1_git, | env = {'sha1_git': sha1_git, | ||||
'message': None, | 'message': None, | ||||
'revision': None} | 'revision': None} | ||||
try: | try: | ||||
rev = api.api_revision(sha1_git) | rev = api.api_revision(sha1_git, prev_sha1s) | ||||
env['revision'] = utils.prepare_data_for_view(rev) | env['revision'] = utils.prepare_data_for_view(rev) | ||||
except (NotFoundExc, BadInputExc) as e: | except (NotFoundExc, BadInputExc) as e: | ||||
env['message'] = str(e) | env['message'] = str(e) | ||||
return render_template('revision.html', **env) | return render_template('revision.html', **env) | ||||
@app.route('/browse/revision/<string:sha1_git>/raw/') | @app.route('/browse/revision/<string:sha1_git>/raw/') | ||||
def browse_revision_raw_message(sha1_git): | def browse_revision_raw_message(sha1_git): | ||||
"""Given a sha1_git, display the corresponding revision's raw message. | """Given a sha1_git, display the corresponding revision's raw message. | ||||
""" | """ | ||||
return redirect(url_for('api_revision_raw_message', sha1_git=sha1_git)) | return redirect(url_for('api_revision_raw_message', sha1_git=sha1_git)) | ||||
@app.route('/browse/revision/<string:sha1_git>/log/') | @app.route('/browse/revision/<string:sha1_git>/log/') | ||||
@app.route('/browse/revision/<string:sha1_git>/prev/<path:prev_sha1s>/log/') | |||||
@set_renderers(HTMLRenderer) | @set_renderers(HTMLRenderer) | ||||
def browse_revision_log(sha1_git): | def browse_revision_log(sha1_git, prev_sha1s=None): | ||||
ardumont: throught? | |||||
"""Browse revision with sha1_git's log. | """Browse revision with sha1_git's log. If the navigation path throught the | ||||
commit tree is specified, we intersect the earliest revision's log with the | |||||
Done Inline Actionshis/her. ardumont: his/her. | |||||
revisions the user browsed through (ie his path) to the specified revision. | |||||
Args: | |||||
sha1_git: the current revision's SHA1_git checksum | |||||
prev_sha1s: optionally, the path through which we want log information | |||||
""" | """ | ||||
env = {'sha1_git': sha1_git, | env = {'sha1_git': sha1_git, | ||||
'sha1_url': '/browse/revision/%s/' % sha1_git, | 'sha1_url': '/browse/revision/%s/' % sha1_git, | ||||
'message': None, | 'message': None, | ||||
'revisions': []} | 'revisions': []} | ||||
try: | try: | ||||
revisions = api.api_revision_log(sha1_git) | revisions = api.api_revision_log(sha1_git, prev_sha1s) | ||||
env['revisions'] = map(utils.prepare_data_for_view, revisions) | env['revisions'] = map(utils.prepare_data_for_view, revisions) | ||||
except (NotFoundExc, BadInputExc) as e: | except (NotFoundExc, BadInputExc) as e: | ||||
env['message'] = str(e) | env['message'] = str(e) | ||||
return render_template('revision-log.html', **env) | return render_template('revision-log.html', **env) | ||||
@app.route('/browse/revision' | @app.route('/browse/revision' | ||||
Show All 39 Lines | try: | ||||
origin_id, branch_name, timestamp) | origin_id, branch_name, timestamp) | ||||
env['revisions'] = map(utils.prepare_data_for_view, revisions) | env['revisions'] = map(utils.prepare_data_for_view, revisions) | ||||
except (NotFoundExc, BadInputExc) as e: | except (NotFoundExc, BadInputExc) as e: | ||||
env['message'] = str(e) | env['message'] = str(e) | ||||
return render_template('revision-log.html', **env) | return render_template('revision-log.html', **env) | ||||
@app.route('/browse/revision/<string:sha1_git_cur>/prev/<path:sha1s>/') | |||||
@set_renderers(HTMLRenderer) | |||||
def browse_with_rev_context(sha1_git_cur, sha1s): | |||||
"""Browse the revision with git SHA1 sha1_git_cur, while keeping the context | |||||
from which we came as a list of previous (i.e. later) revisions' sha1s. | |||||
Args: | |||||
sha1_git_cur: the requested revision's sha1_git. | |||||
sha1s: a string of /-separated sha1s representing our context, ordered | |||||
by descending revision date. | |||||
Returns: | |||||
Information about revision of git SHA1 sha1_git_cur, with relevant URLS | |||||
pointing to the context augmented with sha1_git_cur. | |||||
Example: | |||||
GET /browse/revision/ | |||||
""" | |||||
Done Inline Actionsis it a todo or fixme? ardumont: is it a todo or fixme? | |||||
# in service: change enrichment function to prepare data with context | |||||
env = {'sha1_git': sha1_git_cur, | |||||
'message': None, | |||||
'revision': None} | |||||
try: | |||||
revision = api.api_revision( | |||||
sha1_git_cur, '%s' % sha1s) | |||||
env['revision'] = utils.prepare_data_for_view(revision) | |||||
except (BadInputExc, NotFoundExc) as e: | |||||
env['message'] = str(e) | |||||
return render_template('revision.html', **env) | |||||
@app.route('/browse/revision/<string:sha1_git_root>/history/<sha1_git>/') | @app.route('/browse/revision/<string:sha1_git_root>/history/<sha1_git>/') | ||||
@set_renderers(HTMLRenderer) | @set_renderers(HTMLRenderer) | ||||
def browse_revision_history(sha1_git_root, sha1_git): | def browse_revision_history(sha1_git_root, sha1_git): | ||||
"""Display information about revision sha1_git, limited to the | """Display information about revision sha1_git, limited to the | ||||
sub-graph of all transitive parents of sha1_git_root. | sub-graph of all transitive parents of sha1_git_root. | ||||
In other words, sha1_git is an ancestor of sha1_git_root. | In other words, sha1_git is an ancestor of sha1_git_root. | ||||
▲ Show 20 Lines • Show All 391 Lines • Show Last 20 Lines |
throught?