def binaryencode(repo, metadataids): """encode snapshot metadata into a binary CBOR stream format (CBOR-encoded): { "metadatafiles": { <metadata oid>: <binary metadata content>, . . . }, "auxfiles": { <file oid>: <binary file content>, . . . } } """ metadataauxfilesinfo = set() bundlepartdict = {"metadatafiles": {}, "auxfiles": {}} store = repo.svfs.snapshotstore # store the metadata files for metadataid in metadataids: data = store.read(metadataid) bundlepartdict["metadatafiles"][metadataid] = data snapmetadata = metadata.snapshotmetadata.deserialize(data) metadataauxfilesinfo.update(snapmetadata.getauxfilesinfo()) # store files that are mentioned in metadata for fileid in metadataauxfilesinfo: bundlepartdict["auxfiles"][fileid] = store.read(fileid) return "".join(cborutil.streamencode(bundlepartdict))
def serialize(self): return "".join(cborutil.streamencode(self.todict()))