316
317
# since it computes the sha1 hash for the revision, which
317
318
# only will match if everything is okay, but lets be
318
319
# explicit about it
319
branch_rev = self.b1.get_revision(cset_rev.revision_id)
320
branch_rev = self.b1.repository.get_revision(cset_rev.revision_id)
320
321
for a in ('inventory_sha1', 'revision_id', 'parent_ids'
321
322
, 'timestamp', 'timezone', 'message', 'committer'):
322
323
self.assertEqual(getattr(branch_rev, a), getattr(cset_rev, a))
330
331
def get_checkout(self, rev_id, checkout_dir=None):
331
332
"""Get a new tree, with the specified revision in it.
333
from bzrlib.clone import copy_branch
334
334
from bzrlib.branch import Branch
341
341
if not os.path.exists(checkout_dir):
342
342
os.mkdir(checkout_dir)
343
copy_branch(self.b1, checkout_dir, None)
344
return Branch.open(checkout_dir)
343
self.tree1.bzrdir.clone(checkout_dir)
344
return WorkingTree.open(checkout_dir)
346
346
def valid_apply_changeset(self, base_rev_id, cset,
347
347
auto_commit=False, checkout_dir=None):
348
348
"""Get the base revision, apply the changes, and make
349
349
sure everything matches the builtin branch.
351
from apply_changeset import _apply_cset
351
from bzrlib.changeset.apply_changeset import _apply_cset
353
to_branch = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
354
auto_committed = _apply_cset(to_branch, cset, auto_commit=auto_commit)
353
to_tree = self.get_checkout(base_rev_id, checkout_dir=checkout_dir)
354
auto_committed = _apply_cset(to_tree, cset, auto_commit=auto_commit)
357
repository = to_tree.branch.repository
357
358
for rev in info.real_revisions:
358
self.assert_(rev.revision_id in to_branch.revision_store,
359
self.assert_(repository.has_revision(rev.revision_id),
359
360
'Missing revision {%s} after applying changeset'
360
361
% rev.revision_id)
362
self.assert_(to_branch.has_revision(info.target))
363
self.assert_(to_tree.branch.repository.has_revision(info.target))
363
364
# Do we also want to verify that all the texts have been added?
371
372
# We might also check that all revisions are in the
372
373
# history for some changeset applications which
373
374
# merge multiple revisions.
374
self.assertEqual(to_branch.last_patch(), info.target)
375
self.assertEqual(to_tree.branch.last_patch(), info.target)
376
self.assert_(info.target in to_branch.pending_merges())
377
self.assert_(info.target in to_tree.pending_merges())
379
380
rev = info.real_revisions[-1]
380
base_tree = self.b1.revision_tree(rev.revision_id)
381
to_tree = to_branch.revision_tree(rev.revision_id)
381
base_tree = self.b1.repository.revision_tree(rev.revision_id)
382
to_tree = to_tree.branch.repository.revision_tree(rev.revision_id)
383
384
# TODO: make sure the target tree is identical to base tree
384
385
# we might also check the working tree.