def _add_mp_records_keys(self, repo_kind, vf, keys): """Add multi-parent diff records to a bundle""" ordered_keys = list(multiparent.topo_iter_keys(vf, keys)) mpdiffs = vf.make_mpdiffs(ordered_keys) sha1s = vf.get_sha1s(ordered_keys) parent_map = vf.get_parent_map(ordered_keys) for mpdiff, item_key, in zip(mpdiffs, ordered_keys): sha1 = sha1s[item_key] parents = [key[-1] for key in parent_map[item_key]] text = ''.join(mpdiff.to_patch()) # Infer file id records as appropriate. if len(item_key) == 2: file_id = item_key[0] else: file_id = None self.bundle.add_multiparent_record(text, sha1, parents, repo_kind, item_key[-1], file_id)
def write_revisions(self): """Write bundle records for all revisions and signatures""" inv_vf = self.repository.inventories revision_order = [key[-1] for key in multiparent.topo_iter_keys(inv_vf, self.revision_keys)] if self.target is not None and self.target in self.revision_ids: revision_order.remove(self.target) revision_order.append(self.target) self._add_mp_records_keys('inventory', inv_vf, [(revid,) for revid in revision_order]) parent_map = self.repository.get_parent_map(revision_order) for revision_id in revision_order: parents = parent_map.get(revision_id, None) revision_text = self.repository.get_revision_xml(revision_id) self.bundle.add_fulltext_record(revision_text, parents, 'revision', revision_id) try: self.bundle.add_fulltext_record( self.repository.get_signature_text( revision_id), parents, 'signature', revision_id) except errors.NoSuchRevision: pass
def write_revisions(self): """Write bundle records for all revisions and signatures""" inv_vf = self.repository.inventories topological_order = [key[-1] for key in multiparent.topo_iter_keys( inv_vf, self.revision_keys)] revision_order = topological_order if self.target is not None and self.target in self.revision_ids: # Make sure the target revision is always the last entry revision_order = list(topological_order) revision_order.remove(self.target) revision_order.append(self.target) if self.repository._serializer.support_altered_by_hack: # Repositories that support_altered_by_hack means that # inventories.make_mpdiffs() contains all the data about the tree # shape. Formats without support_altered_by_hack require # chk_bytes/etc, so we use a different code path. self._add_mp_records_keys('inventory', inv_vf, [(revid,) for revid in topological_order]) else: # Inventories should always be added in pure-topological order, so # that we can apply the mpdiff for the child to the parent texts. self._add_inventory_mpdiffs_from_serializer(topological_order) self._add_revision_texts(revision_order)
def write_revisions(self): """Write bundle records for all revisions and signatures""" inv_vf = self.repository.inventories revision_order = [ key[-1] for key in multiparent.topo_iter_keys(inv_vf, self.revision_keys) ] if self.target is not None and self.target in self.revision_ids: revision_order.remove(self.target) revision_order.append(self.target) self._add_mp_records_keys('inventory', inv_vf, [(revid, ) for revid in revision_order]) parent_map = self.repository.get_parent_map(revision_order) for revision_id in revision_order: parents = parent_map.get(revision_id, None) revision_text = self.repository.get_revision_xml(revision_id) self.bundle.add_fulltext_record(revision_text, parents, 'revision', revision_id) try: self.bundle.add_fulltext_record( self.repository.get_signature_text(revision_id), parents, 'signature', revision_id) except errors.NoSuchRevision: pass