Changeset View
Changeset View
Standalone View
Standalone View
swh/storage/algos/diff.py
Show All 9 Lines | |||||
# - this blog post: https://blog.sourced.tech/post/difftree/ | # - this blog post: https://blog.sourced.tech/post/difftree/ | ||||
# - the reference implementation in go: | # - the reference implementation in go: | ||||
# https://github.com/src-d/go-git/tree/master/utils/merkletrie | # https://github.com/src-d/go-git/tree/master/utils/merkletrie | ||||
import collections | import collections | ||||
from typing import Any, Dict | from typing import Any, Dict | ||||
from swh.model.hashutil import hash_to_bytes | from swh.model.model import Directory | ||||
from swh.model.identifiers import directory_identifier | |||||
from swh.storage.interface import StorageInterface | from swh.storage.interface import StorageInterface | ||||
from .dir_iterators import DirectoryIterator, DoubleDirectoryIterator, Remaining | from .dir_iterators import DirectoryIterator, DoubleDirectoryIterator, Remaining | ||||
# get the hash identifier for an empty directory | # get the hash identifier for an empty directory | ||||
_empty_dir_hash = hash_to_bytes(directory_identifier({"entries": []})) | _empty_dir_hash = Directory(entries=()).id | ||||
def _get_rev(storage: StorageInterface, rev_id: bytes) -> Dict[str, Any]: | def _get_rev(storage: StorageInterface, rev_id: bytes) -> Dict[str, Any]: | ||||
""" | """ | ||||
Return revision data from swh storage. | Return revision data from swh storage. | ||||
""" | """ | ||||
revision = storage.revision_get([rev_id])[0] | revision = storage.revision_get([rev_id])[0] | ||||
assert revision is not None | assert revision is not None | ||||
▲ Show 20 Lines • Show All 384 Lines • Show Last 20 Lines |