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 HttpResponse | 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 ( | from swh.model.identifiers import ( | ||||
swhid, | swhid, | ||||
CONTENT, | CONTENT, | ||||
DIRECTORY, | DIRECTORY, | ||||
▲ Show 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | def _revision_diff(request, sha1_git): | ||||
changes = service.diff_revision(sha1_git) | changes = service.diff_revision(sha1_git) | ||||
changes_msg = _gen_revision_changes_list(revision, changes, snapshot_context) | changes_msg = _gen_revision_changes_list(revision, changes, snapshot_context) | ||||
diff_data = { | diff_data = { | ||||
"total_nb_changes": len(changes), | "total_nb_changes": len(changes), | ||||
"changes": changes[:_max_displayed_file_diffs], | "changes": changes[:_max_displayed_file_diffs], | ||||
"changes_msg": changes_msg, | "changes_msg": changes_msg, | ||||
} | } | ||||
diff_data_json = json.dumps(diff_data, separators=(",", ": ")) | return JsonResponse(diff_data) | ||||
return HttpResponse(diff_data_json, content_type="application/json") | |||||
NB_LOG_ENTRIES = 100 | NB_LOG_ENTRIES = 100 | ||||
@browse_route( | @browse_route( | ||||
r"revision/(?P<sha1_git>[0-9a-f]+)/log/", | r"revision/(?P<sha1_git>[0-9a-f]+)/log/", | ||||
view_name="browse-revision-log", | view_name="browse-revision-log", | ||||
▲ Show 20 Lines • Show All 407 Lines • Show Last 20 Lines |