Changeset View
Changeset View
Standalone View
Standalone View
swh/web/browse/views/revision.py
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | for i, change in enumerate(changes): | ||||
query_params = {"path": change["path"]} | query_params = {"path": change["path"]} | ||||
change["diff_url"] = reverse( | change["diff_url"] = reverse( | ||||
"diff-contents", url_args=url_args, query_params=query_params | "diff-contents", url_args=url_args, query_params=query_params | ||||
) | ) | ||||
hasher.update(diff_id.encode("utf-8")) | hasher.update(diff_id.encode("utf-8")) | ||||
diff_id = hasher.hexdigest() | diff_id = hasher.hexdigest() | ||||
change["id"] = diff_id | change["id"] = diff_id | ||||
panel_diff_link = "#panel_" + diff_id | diff_link = "#diff_" + diff_id | ||||
if change["type"] == "modify": | if change["type"] == "modify": | ||||
change["content_url"] = _gen_content_url( | change["content_url"] = _gen_content_url( | ||||
revision, to_query_string, change["to_path"], snapshot_context | revision, to_query_string, change["to_path"], snapshot_context | ||||
) | ) | ||||
changes_msg.append( | changes_msg.append( | ||||
"modified: %s" % _gen_diff_link(i, panel_diff_link, change["to_path"]) | "modified: %s" % _gen_diff_link(i, diff_link, change["to_path"]) | ||||
) | ) | ||||
elif change["type"] == "insert": | elif change["type"] == "insert": | ||||
change["content_url"] = _gen_content_url( | change["content_url"] = _gen_content_url( | ||||
revision, to_query_string, change["to_path"], snapshot_context | revision, to_query_string, change["to_path"], snapshot_context | ||||
) | ) | ||||
changes_msg.append( | changes_msg.append( | ||||
"new file: %s" % _gen_diff_link(i, panel_diff_link, change["to_path"]) | "new file: %s" % _gen_diff_link(i, diff_link, change["to_path"]) | ||||
) | ) | ||||
elif change["type"] == "delete": | elif change["type"] == "delete": | ||||
parent = service.lookup_revision(revision["parents"][0]) | parent = service.lookup_revision(revision["parents"][0]) | ||||
change["content_url"] = _gen_content_url( | change["content_url"] = _gen_content_url( | ||||
parent, from_query_string, change["from_path"], snapshot_context | parent, from_query_string, change["from_path"], snapshot_context | ||||
) | ) | ||||
changes_msg.append( | changes_msg.append( | ||||
"deleted: %s" | "deleted: %s" % _gen_diff_link(i, diff_link, change["from_path"]) | ||||
% _gen_diff_link(i, panel_diff_link, change["from_path"]) | |||||
) | ) | ||||
elif change["type"] == "rename": | elif change["type"] == "rename": | ||||
change["content_url"] = _gen_content_url( | change["content_url"] = _gen_content_url( | ||||
revision, to_query_string, change["to_path"], snapshot_context | revision, to_query_string, change["to_path"], snapshot_context | ||||
) | ) | ||||
link_text = change["from_path"] + " → " + change["to_path"] | link_text = change["from_path"] + " → " + change["to_path"] | ||||
changes_msg.append( | changes_msg.append( | ||||
"renamed: %s" % _gen_diff_link(i, panel_diff_link, link_text) | "renamed: %s" % _gen_diff_link(i, diff_link, link_text) | ||||
) | ) | ||||
if not changes: | if not changes: | ||||
changes_msg.append("No changes") | changes_msg.append("No changes") | ||||
return mark_safe("\n".join(changes_msg)) | return mark_safe("\n".join(changes_msg)) | ||||
@browse_route( | @browse_route( | ||||
r"revision/(?P<sha1_git>[0-9a-f]+)/diff/", | r"revision/(?P<sha1_git>[0-9a-f]+)/diff/", | ||||
▲ Show 20 Lines • Show All 447 Lines • Show Last 20 Lines |