summaryrefslogtreecommitdiff
path: root/revision_store.py
diff options
context:
space:
mode:
authorJohn Arbash Meinel <john@arbash-meinel.com>2009-11-12 17:25:04 -0600
committerJohn Arbash Meinel <john@arbash-meinel.com>2009-11-12 17:25:04 -0600
commitaa2c5cc815f2399449af2e5937dc727376424e48 (patch)
tree75643f896aec66c93f064084c54807497d8935a6 /revision_store.py
parent62eecb87827a28696393722f3c2b3b15434b4bdd (diff)
downloadbzr-fastimport-aa2c5cc815f2399449af2e5937dc727376424e48.tar.gz
Fall back to the repository for cases where the content is not present in the stream yet.
Diffstat (limited to 'revision_store.py')
-rw-r--r--revision_store.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/revision_store.py b/revision_store.py
index cd84e6a..4be645e 100644
--- a/revision_store.py
+++ b/revision_store.py
@@ -28,7 +28,8 @@ class _TreeShim(object):
This implements just enough of the tree api to make commit builder happy.
"""
- def __init__(self, basis_inv, inv_delta, content_provider):
+ def __init__(self, repo, basis_inv, inv_delta, content_provider):
+ self._repo = repo
self._content_provider = content_provider
self._basis_inv = basis_inv
self._inv_delta = inv_delta
@@ -49,7 +50,16 @@ class _TreeShim(object):
return self._basis_inv.root.file_id
def get_file_with_stat(self, file_id, path=None):
- content = self._content_provider(file_id)
+ try:
+ content = self._content_provider(file_id)
+ except KeyError:
+ # The content wasn't shown as 'new'. Just validate this fact
+ assert file_id not in self._new_info_by_id
+ old_ie = self._basis_inv[file_id]
+ old_text_key = (file_id, old_ie.revision)
+ stream = self._repo.texts.get_record_stream([old_text_key],
+ 'unordered', True)
+ content = stream.next().get_bytes_as('fulltext')
sio = cStringIO.StringIO(content)
return sio, None
@@ -115,6 +125,7 @@ class _TreeShim(object):
else:
content_modified = (ie.text_sha1 != old_ie.text_sha1
or ie.text_size != old_ie.text_size)
+ # TODO: ie.kind != old_ie.kind
change = (file_id,
(old_path, new_path),
content_modified,
@@ -340,7 +351,7 @@ class AbstractRevisionStore(object):
basis_rev_id = rev.parent_ids[0]
else:
basis_rev_id = _mod_revision.NULL_REVISION
- tree = _TreeShim(basis_inv, inv_delta, text_provider)
+ tree = _TreeShim(self.repo, basis_inv, inv_delta, text_provider)
changes = tree._delta_to_iter_changes()
for (file_id, path, fs_hash) in builder.record_iter_changes(
tree, basis_rev_id, changes):