summaryrefslogtreecommitdiff
path: root/revision_store.py
diff options
context:
space:
mode:
authorIan Clatworthy <ian.clatworthy@internode.on.net>2009-04-05 00:33:50 +1000
committerIan Clatworthy <ian.clatworthy@internode.on.net>2009-04-05 00:33:50 +1000
commitcbdb6bccf51f59c40052d959e25fd974957f1187 (patch)
treeb01b777562172b668058a0043645fc3b71365b50 /revision_store.py
parent33e441d46bc8690ebb4d5906a43d4d782eff81eb (diff)
downloadpython-fastimport-cbdb6bccf51f59c40052d959e25fd974957f1187.tar.gz
use inv deltas by default for all formats now: --classic to get old algorithm for packs
Diffstat (limited to 'revision_store.py')
-rw-r--r--revision_store.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/revision_store.py b/revision_store.py
index 02ed289..d2ab2d3 100644
--- a/revision_store.py
+++ b/revision_store.py
@@ -205,12 +205,12 @@ class AbstractRevisionStore(object):
self.repo.add_signature_text(rev.revision_id, signature)
self._add_revision(rev, inv)
- def chk_load(self, rev, basis_inv, inv_delta, signature,
+ def load_using_delta(self, rev, basis_inv, inv_delta, signature,
text_provider, parents_provider, inventories_provider=None):
- """Load a revision for a CHKInventory.
+ """Load a revision by applying a delta to a (CHK)Inventory.
:param rev: the Revision
- :param basis_inv: the basis CHKInventory
+ :param basis_inv: the basis Inventory or CHKInventory
:param inv_delta: the inventory delta
:param signature: signing information
:param text_provider: a callable expecting a file_id parameter
@@ -292,7 +292,7 @@ class AbstractRevisionStore(object):
parents, parent_invs):
"""Add the inventory to the repository as revision_id.
- :param basis_inv: the basis CHKInventory
+ :param basis_inv: the basis Inventory or CHKInventory
:param inv_delta: the inventory delta
:param parents: The revision ids of the parents that revision_id
is known to have and are in the repository already.
@@ -304,11 +304,21 @@ class AbstractRevisionStore(object):
inv is the generated inventory
"""
if len(parents):
- validator, new_inv = self.repo.add_inventory_by_delta(parents[0],
- inv_delta, revision_id, parents, basis_inv=basis_inv,
- propagate_caches=False)
+ if self._supports_chks:
+ validator, new_inv = self.repo.add_inventory_by_delta(parents[0],
+ inv_delta, revision_id, parents, basis_inv=basis_inv,
+ propagate_caches=False)
+ else:
+ validator, new_inv = self.repo.add_inventory_by_delta(parents[0],
+ inv_delta, revision_id, parents)
else:
- new_inv = basis_inv.create_by_apply_delta(inv_delta, revision_id)
+ if hasattr(basis_inv, 'create_by_apply_delta'):
+ new_inv = basis_inv.create_by_apply_delta(inv_delta, revision_id)
+ else:
+ new_inv = inventory.Inventory(revision_id=revision_id)
+ # This is set in the delta so remove it to prevent a duplicate
+ del new_inv[inventory.ROOT_ID]
+ new_inv.apply_delta(inv_delta)
validator = self.repo.add_inventory(revision_id, new_inv, parents)
return validator, new_inv