Rev 5838: (jelmer) Avoid Repository.texts.add_lines in the testsuite as it is not in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Sun May 8 17:37:09 UTC 2011
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5838 [merge]
revision-id: pqm at pqm.ubuntu.com-20110508173705-uvxqfb8c0rtzqj2c
parent: pqm at pqm.ubuntu.com-20110507235836-c277kl3ugz0s8nlw
parent: jelmer at samba.org-20110508160252-akovn3laoln5sfx9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2011-05-08 17:37:05 +0000
message:
(jelmer) Avoid Repository.texts.add_lines in the testsuite as it is not
available for some repository implementations. (Jelmer Vernooij)
modified:
bzrlib/tests/per_workingtree/test_parents.py test_set_parents.py-20060807231740-yicmnlci1mj8smu1-1
=== modified file 'bzrlib/tests/per_workingtree/test_parents.py'
--- a/bzrlib/tests/per_workingtree/test_parents.py 2011-05-04 21:10:36 +0000
+++ b/bzrlib/tests/per_workingtree/test_parents.py 2011-05-08 16:02:52 +0000
@@ -16,6 +16,7 @@
"""Tests of the parent related functions of WorkingTrees."""
+from cStringIO import StringIO
import os
from bzrlib import (
@@ -30,7 +31,7 @@
InventoryDirectory,
InventoryLink,
)
-from bzrlib.revision import Revision
+from bzrlib.revisiontree import InventoryRevisionTree
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
from bzrlib.uncommit import uncommit
@@ -384,32 +385,41 @@
return delta
def fake_up_revision(self, tree, revid, shape):
+
+ class ShapeTree(InventoryRevisionTree):
+
+ def __init__(self, shape):
+ self._repository = tree.branch.repository
+ self._inventory = shape
+
+ def get_file_text(self, file_id, path=None):
+ ie = self.inventory[file_id]
+ if ie.kind != "file":
+ return ""
+ return 'a' * ie.text_size
+
+ def get_file(self, file_id, path=None):
+ return StringIO(self.get_file_text(file_id))
+
tree.lock_write()
try:
- tree.branch.repository.start_write_group()
- try:
- if shape.root.revision is None:
- shape.root.revision = revid
- # Create the text records for this inventory.
- for path, ie in shape.iter_entries():
- if ie.text_size:
- lines = ['a' * ie.text_size]
- else:
- lines = []
- tree.branch.repository.texts.add_lines(
- (ie.file_id, ie.revision), [], lines)
- sha1 = tree.branch.repository.add_inventory(revid, shape, [])
- rev = Revision(timestamp=0,
- timezone=None,
- committer="Foo Bar <foo at example.com>",
- message="Message",
- inventory_sha1=sha1,
- revision_id=revid)
- tree.branch.repository.add_revision(revid, rev)
- tree.branch.repository.commit_write_group()
- except:
- tree.branch.repository.abort_write_group()
- raise
+ if shape.root.revision is None:
+ shape.root.revision = revid
+ builder = tree.branch.get_commit_builder(
+ parents=[],
+ timestamp=0,
+ timezone=None,
+ committer="Foo Bar <foo at example.com>",
+ revision_id=revid)
+ shape_tree = ShapeTree(shape)
+ base_tree = tree.branch.repository.revision_tree(
+ _mod_revision.NULL_REVISION)
+ changes = shape_tree.iter_changes(
+ base_tree)
+ list(builder.record_iter_changes(shape_tree,
+ base_tree.get_revision_id(), changes))
+ builder.finish_inventory()
+ builder.commit("Message")
finally:
tree.unlock()
More information about the bazaar-commits
mailing list