Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/revision.py
# Copyright (C) 2017-2020 The Software Heritage developers | # Copyright (C) 2017-2020 The Software Heritage developers | ||||
# See the AUTHORS file at the top-level directory of this distribution | # See the AUTHORS file at the top-level directory of this distribution | ||||
# License: GNU Affero General Public License version 3, or any later version | # License: GNU Affero General Public License version 3, or any later version | ||||
# See top-level LICENSE file for more information | # See top-level LICENSE file for more information | ||||
import hashlib | import hashlib | ||||
import json | import json | ||||
import textwrap | import textwrap | ||||
from django.http import JsonResponse | from django.http import JsonResponse | ||||
from django.shortcuts import render | from django.shortcuts import render | ||||
from django.template.defaultfilters import filesizeformat | from django.template.defaultfilters import filesizeformat | ||||
from django.utils.safestring import mark_safe | from django.utils.safestring import mark_safe | ||||
from swh.model.identifiers import CONTENT, DIRECTORY, REVISION, SNAPSHOT, swhid | from swh.model.hashutil import hash_to_bytes | ||||
from swh.model.identifiers import ( | |||||
CONTENT, | |||||
DIRECTORY, | |||||
REVISION, | |||||
SNAPSHOT, | |||||
CoreSWHID, | |||||
ObjectType, | |||||
) | |||||
from swh.web.browse.browseurls import browse_route | from swh.web.browse.browseurls import browse_route | ||||
from swh.web.browse.snapshot_context import get_snapshot_context | from swh.web.browse.snapshot_context import get_snapshot_context | ||||
from swh.web.browse.utils import ( | from swh.web.browse.utils import ( | ||||
content_display_max_size, | content_display_max_size, | ||||
format_log_entries, | format_log_entries, | ||||
gen_link, | gen_link, | ||||
gen_person_mail_link, | gen_person_mail_link, | ||||
gen_revision_url, | gen_revision_url, | ||||
▲ Show 20 Lines • Show All 235 Lines • ▼ Show 20 Lines | if offset != 0: | ||||
"per_page": per_page, | "per_page": per_page, | ||||
"offset": offset - per_page, | "offset": offset - per_page, | ||||
"revs_ordering": revs_ordering or None, | "revs_ordering": revs_ordering or None, | ||||
}, | }, | ||||
) | ) | ||||
revision_log_data = format_log_entries(revision_log, per_page) | revision_log_data = format_log_entries(revision_log, per_page) | ||||
swh_rev_id = swhid("revision", sha1_git) | swh_rev_id = str( | ||||
CoreSWHID(object_type=ObjectType.REVISION, object_id=hash_to_bytes(sha1_git)) | |||||
) | |||||
return render( | return render( | ||||
request, | request, | ||||
"browse/revision-log.html", | "browse/revision-log.html", | ||||
{ | { | ||||
"heading": "Revision history", | "heading": "Revision history", | ||||
"swh_object_id": swh_rev_id, | "swh_object_id": swh_rev_id, | ||||
"swh_object_name": "Revisions history", | "swh_object_name": "Revisions history", | ||||
▲ Show 20 Lines • Show All 307 Lines • Show Last 20 Lines |