Changeset View
Changeset View
Standalone View
Standalone View
swh/vault/cookers/revision_gitfast.py
# Copyright (C) 2017 The Software Heritage developers | # Copyright (C) 2017 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 General Public License version 3, or any later version | # License: GNU 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 collections | import collections | ||||
import fastimport.commands | import fastimport.commands | ||||
import functools | import functools | ||||
import os | import os | ||||
import time | import time | ||||
import zlib | import zlib | ||||
from .base import BaseVaultCooker | from .base import BaseVaultCooker, get_filtered_file_content | ||||
from swh.model import hashutil | from swh.model import hashutil | ||||
class RevisionGitfastCooker(BaseVaultCooker): | class RevisionGitfastCooker(BaseVaultCooker): | ||||
"""Cooker to create a git fast-import bundle """ | """Cooker to create a git fast-import bundle """ | ||||
CACHE_TYPE_KEY = 'revision_gitfast' | CACHE_TYPE_KEY = 'revision_gitfast' | ||||
def check_exists(self): | def check_exists(self): | ||||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | class RevisionGitfastCooker(BaseVaultCooker): | ||||
def _compute_blob_command_content(self, file_data): | def _compute_blob_command_content(self, file_data): | ||||
"""Compute the blob command of a file entry if it has not been | """Compute the blob command of a file entry if it has not been | ||||
computed yet. | computed yet. | ||||
""" | """ | ||||
obj_id = file_data['sha1'] | obj_id = file_data['sha1'] | ||||
if obj_id in self.obj_done: | if obj_id in self.obj_done: | ||||
return | return | ||||
content = list(self.storage.content_get([obj_id]))[0]['data'] | content = get_filtered_file_content(self.storage, file_data) | ||||
yield fastimport.commands.BlobCommand( | yield fastimport.commands.BlobCommand( | ||||
mark=self.mark(obj_id), | mark=self.mark(obj_id), | ||||
data=content, | data=content, | ||||
) | ) | ||||
self.obj_done.add(obj_id) | self.obj_done.add(obj_id) | ||||
def _compute_commit_command(self, rev): | def _compute_commit_command(self, rev): | ||||
"""Compute a commit command from a specific revision. | """Compute a commit command from a specific revision. | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |