267
267
wt = self.make_branch_and_tree('source')
268
268
cloned_dir = wt.bzrdir.clone('target')
269
269
cloned = cloned_dir.open_workingtree()
270
self.assertEqual(cloned.last_revision(), wt.last_revision())
270
self.assertEqual(cloned.get_parent_ids(), wt.get_parent_ids())
272
272
def test_last_revision(self):
273
273
wt = self.make_branch_and_tree('source')
274
self.assertEqual(None, wt.last_revision())
274
self.assertEqual([], wt.get_parent_ids())
275
275
wt.commit('A', allow_pointless=True, rev_id='A')
276
self.assertEqual('A', wt.last_revision())
276
self.assertEqual(['A'], wt.get_parent_ids())
278
278
def test_set_last_revision(self):
279
279
wt = self.make_branch_and_tree('source')
280
self.assertEqual(None, wt.last_revision())
281
280
# set last-revision to one not in the history
282
281
wt.set_last_revision('A')
283
282
# set it back to None for an empty tree.
284
283
wt.set_last_revision(None)
285
284
wt.commit('A', allow_pointless=True, rev_id='A')
286
self.assertEqual('A', wt.last_revision())
285
self.assertEqual(['A'], wt.get_parent_ids())
287
286
# None is aways in the branch
288
287
wt.set_last_revision(None)
289
self.assertEqual(None, wt.last_revision())
288
self.assertEqual([], wt.get_parent_ids())
290
289
# and now we can set it to 'A'
291
290
# because some formats mutate the branch to set it on the tree
292
291
# we need to alter the branch to let this pass.
293
292
wt.branch.set_revision_history(['A', 'B'])
294
293
wt.set_last_revision('A')
295
self.assertEqual('A', wt.last_revision())
294
self.assertEqual(['A'], wt.get_parent_ids())
297
296
def test_set_last_revision_different_to_branch(self):
298
297
# working tree formats from the meta-dir format and newer support
313
312
wt = branch.bzrdir.create_workingtree()
314
313
wt.commit('A', allow_pointless=True, rev_id='A')
315
314
wt.set_last_revision(None)
316
self.assertEqual(None, wt.last_revision())
315
self.assertEqual([], wt.get_parent_ids())
317
316
self.assertEqual('A', wt.branch.last_revision())
318
317
# and now we can set it back to 'A'
319
318
wt.set_last_revision('A')
320
self.assertEqual('A', wt.last_revision())
319
self.assertEqual(['A'], wt.get_parent_ids())
321
320
self.assertEqual('A', wt.branch.last_revision())
323
322
def test_clone_and_commit_preserves_last_revision(self):
323
"""Doing a commit into a clone tree does not affect the source."""
324
324
wt = self.make_branch_and_tree('source')
325
325
cloned_dir = wt.bzrdir.clone('target')
326
326
wt.commit('A', allow_pointless=True, rev_id='A')
327
self.assertNotEqual(cloned_dir.open_workingtree().last_revision(),
327
self.assertNotEqual(cloned_dir.open_workingtree().get_parent_ids(),
330
330
def test_clone_preserves_content(self):
331
331
wt = self.make_branch_and_tree('source')
384
384
source.branch.repository.clone(made_control)
385
385
source.branch.clone(made_control)
386
386
made_tree = self.workingtree_format.initialize(made_control, revision_id='a')
387
self.assertEqual('a', made_tree.last_revision())
387
self.assertEqual(['a'], made_tree.get_parent_ids())
389
389
def test_update_sets_last_revision(self):
390
390
# working tree formats from the meta-dir format and newer support
415
415
# and update old_tree
416
416
self.assertEqual(0, old_tree.update())
417
417
self.failUnlessExists('checkout/file')
418
self.assertEqual('A', old_tree.last_revision())
418
self.assertEqual(['A'], old_tree.get_parent_ids())
420
420
def test_update_returns_conflict_count(self):
421
421
# working tree formats from the meta-dir format and newer support
448
448
old_tree.add('file')
449
449
# and update old_tree
450
450
self.assertEqual(1, old_tree.update())
451
self.assertEqual('A', old_tree.last_revision())
451
self.assertEqual(['A'], old_tree.get_parent_ids())
453
453
def test_merge_revert(self):
454
454
from bzrlib.merge import merge_inner
488
488
master_tree.commit('foo', rev_id='foo', allow_pointless=True)
490
self.assertEqual('foo', tree.last_revision())
490
self.assertEqual(['foo'], tree.get_parent_ids())
491
491
self.assertEqual('foo', tree.branch.last_revision())
493
493
def test_update_turns_local_commit_into_merge(self):
516
516
# sync with master prepatory to committing
518
518
# which should have pivoted the local tip into a merge
519
self.assertEqual(master_tip, tree.last_revision())
520
self.assertEqual([master_tip], tree.branch.revision_history())
521
519
self.assertEqual([master_tip, 'bar'], tree.get_parent_ids())
520
# and the local branch history should match the masters now.
521
self.assertEqual(master_tree.branch.revision_history(),
522
tree.branch.revision_history())
523
524
def test_merge_modified(self):
524
525
tree = self.make_branch_and_tree('master')