475
475
# subsequent log is accurate
476
476
self.assertNotContainsRe(out, 'rev1')
478
def test_push_from_subdir(self):
479
t = self.make_branch_and_tree('tree')
480
self.build_tree(['tree/dir/', 'tree/dir/file'])
481
t.add('dir', 'dir/file')
483
out, err = self.run_bzr('push ../../pushloc', working_dir='tree/dir')
484
self.assertEqual('', out)
485
self.assertEqual('Created new branch.\n', err)
488
479
class RedirectingMemoryTransport(memory.MemoryTransport):
564
555
% re.escape(destination_url)],
565
556
['push', '-d', 'tree', destination_url], retcode=3)
566
557
self.assertEqual('', out)
569
class TestPushStrict(tests.TestCaseWithTransport):
571
def make_local_branch_and_tree(self):
572
tree = self.make_branch_and_tree('local')
573
self.build_tree_contents([('local/file', 'initial')])
575
tree.commit('adding file', rev_id='from-1')
578
def make_local_branch_and_tree_with_changes(self):
579
tree = self.make_local_branch_and_tree()
581
self.build_tree_contents([('local/file', 'modified')])
584
def set_config_push_strict(self, tree, value):
585
# set config var (any of bazaar.conf, locations.conf, branch.conf
587
conf = tree.branch.get_config()
588
conf.set_user_option('push_strict', value)
590
def assertPushFails(self, location, *args):
591
self.run_bzr_error(['Working tree ".*/local/"'
592
' has uncommitted changes.$',],
593
['push', '../' + location] + list(args),
594
working_dir='local', retcode=3)
596
def assertPushSucceeds(self, location, *args):
597
self.run_bzr(['push', '../' + location] + list(args),
599
tree_to = workingtree.WorkingTree.open(location)
600
repo_to = tree_to.branch.repository
601
self.assertTrue(repo_to.has_revision('from-1'))
602
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
604
def test_push_default(self):
605
tree = self.make_local_branch_and_tree_with_changes()
606
self.assertPushSucceeds('to')
608
def test_push_no_strict_with_changes(self):
609
tree = self.make_local_branch_and_tree_with_changes()
610
self.assertPushSucceeds('to', '--no-strict')
612
def test_push_strict_with_changes(self):
613
tree = self.make_local_branch_and_tree_with_changes()
614
self.assertPushFails('to', '--strict')
616
def test_push_strict_without_changes(self):
617
tree = self.make_local_branch_and_tree()
618
self.assertPushSucceeds('to', '--strict')
620
def test_push_respect_config_var_strict(self):
621
tree = self.make_local_branch_and_tree_with_changes()
622
self.set_config_push_strict(tree, 'true')
623
self.assertPushFails('to')
625
def test_push_bogus_config_var_ignored(self):
626
tree = self.make_local_branch_and_tree_with_changes()
627
self.set_config_push_strict(tree, "I don't want you to be strict")
628
self.assertPushSucceeds('to')
630
def test_push_no_strict_command_line_override_config(self):
631
tree = self.make_local_branch_and_tree_with_changes()
632
self.set_config_push_strict(tree, 'yES')
633
self.assertPushFails('to')
634
self.assertPushSucceeds('to', '--no-strict')
636
def test_push_strict_command_line_override_config(self):
637
tree = self.make_local_branch_and_tree_with_changes()
638
self.set_config_push_strict(tree, 'oFF')
639
self.assertPushFails('to', '--strict')
640
self.assertPushSucceeds('to')