Changeset View
Changeset View
Standalone View
Standalone View
swh/web/ui/service.py
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | def lookup_revision(rev_sha1_git): | ||||
Raises: | Raises: | ||||
ValueError if the identifier provided is not of sha1 nature. | ValueError if the identifier provided is not of sha1 nature. | ||||
""" | """ | ||||
_, sha1_git_bin = query.parse_hash_with_algorithms_or_throws( | _, sha1_git_bin = query.parse_hash_with_algorithms_or_throws( | ||||
rev_sha1_git, | rev_sha1_git, | ||||
['sha1'], | ['sha1'], | ||||
'Only sha1_git is supported.') | 'Only sha1_git is supported.') | ||||
res = backend.revision_get(sha1_git_bin) | revision = backend.revision_get(sha1_git_bin) | ||||
ardumont: That would be here that I'd add the unicode conversion with the trap.
I would still not fill in… | |||||
res.pop('message', None) | return converters.from_revision(revision) | ||||
return converters.from_revision(res) | |||||
def lookup_revision_message(rev_sha1_git): | def lookup_revision_message(rev_sha1_git): | ||||
"""Return the raw message of the revision with sha1 revision_sha1_git. | """Return the raw message of the revision with sha1 revision_sha1_git. | ||||
Args: | Args: | ||||
revision_sha1_git: The revision's sha1 as hexadecimal | revision_sha1_git: The revision's sha1 as hexadecimal | ||||
Show All 13 Lines | def lookup_revision_message(rev_sha1_git): | ||||
revision = backend.revision_get(sha1_git_bin) | revision = backend.revision_get(sha1_git_bin) | ||||
if not revision: | if not revision: | ||||
raise NotFoundExc('Revision with sha1_git %s not found.' | raise NotFoundExc('Revision with sha1_git %s not found.' | ||||
% rev_sha1_git) | % rev_sha1_git) | ||||
if 'message' not in revision: | if 'message' not in revision: | ||||
raise NotFoundExc('No message for revision with sha1_git %s.' | raise NotFoundExc('No message for revision with sha1_git %s.' | ||||
% rev_sha1_git) | % rev_sha1_git) | ||||
res = {'message': revision['message']} | res = {'message': revision['message']} | ||||
return converters.from_revision(res) | return res | ||||
def lookup_revision_by(origin_id, | def lookup_revision_by(origin_id, | ||||
branch_name="refs/heads/master", | branch_name="refs/heads/master", | ||||
timestamp=None): | timestamp=None): | ||||
"""Lookup revisions by origin_id, branch_name and timestamp. | """Lookup revisions by origin_id, branch_name and timestamp. | ||||
If: | If: | ||||
▲ Show 20 Lines • Show All 352 Lines • Show Last 20 Lines |
That would be here that I'd add the unicode conversion with the trap.
I would still not fill in the message url (i let the api layer do that).