327
327
tree.commit('foo', rev_id='foo', allow_pointless=True)
328
328
self.assertEqual('foo', tree.last_revision())
330
def test_commit_local_unbound(self):
331
# using the library api to do a local commit on unbound branches is
333
tree = self.make_branch_and_tree('tree')
334
self.assertRaises(errors.LocalRequiresBoundBranch,
339
def test_local_commit_ignores_master(self):
340
# a --local commit does not require access to the master branch
341
# at all, or even for it to exist.
342
# we test this by setting up a bound branch and then corrupting
344
master = self.make_branch('master')
345
tree = self.make_branch_and_tree('tree')
347
tree.branch.bind(master)
348
except errors.UpgradeRequired:
351
master.bzrdir.transport.put('branch-format', StringIO('garbage'))
353
# check its corrupted.
354
self.assertRaises(errors.UnknownFormatError,
357
tree.commit('foo', rev_id='foo', local=True)
359
def test_local_commit_does_not_push_to_master(self):
360
# a --local commit does not require access to the master branch
361
# at all, or even for it to exist.
362
# we test that even when its available it does not push to it.
363
master = self.make_branch('master')
364
tree = self.make_branch_and_tree('tree')
366
tree.branch.bind(master)
367
except errors.UpgradeRequired:
370
tree.commit('foo', rev_id='foo', local=True)
371
self.failIf(master.repository.has_revision('foo'))
372
self.assertEqual(None, master.last_revision())
330
374
def test_update_sets_last_revision(self):
331
375
# working tree formats from the meta-dir format and newer support
332
376
# setting the last revision on a tree independently of that on the
391
435
self.assertEqual(1, old_tree.update())
392
436
self.assertEqual('A', old_tree.last_revision())
438
def test_update_updates_bound_branch_no_local_commits(self):
439
# doing an update in a tree updates the branch its bound to too.
440
master_tree = self.make_branch_and_tree('master')
441
tree = self.make_branch_and_tree('tree')
443
tree.branch.bind(master_tree.branch)
444
except errors.UpgradeRequired:
445
# legacy branches cannot bind
447
master_tree.commit('foo', rev_id='foo', allow_pointless=True)
449
self.assertEqual('foo', tree.last_revision())
450
self.assertEqual('foo', tree.branch.last_revision())
452
def test_update_turns_local_commit_into_merge(self):
453
# doing an update with a few local commits and no master commits
454
# makes pending-merges.
455
# this is done so that 'bzr update; bzr revert' will always produce
456
# an exact copy of the 'logical branch' - the referenced branch for
457
# a checkout, and the master for a bound branch.
458
# its possible that we should instead have 'bzr update' when there
459
# is nothing new on the master leave the current commits intact and
460
# alter 'revert' to revert to the master always. But for now, its
462
master_tree = self.make_branch_and_tree('master')
463
tree = self.make_branch_and_tree('tree')
465
tree.branch.bind(master_tree.branch)
466
except errors.UpgradeRequired:
467
# legacy branches cannot bind
469
tree.commit('foo', rev_id='foo', allow_pointless=True, local=True)
470
tree.commit('bar', rev_id='bar', allow_pointless=True, local=True)
472
self.assertEqual(None, tree.last_revision())
473
self.assertEqual([], tree.branch.revision_history())
474
self.assertEqual(['bar'], tree.pending_merges())