541
541
tree.commit('adding file', rev_id='from-1')
544
def assertTreePushed(self, relpath):
545
tree_to = workingtree.WorkingTree.open(relpath)
544
def make_local_branch_and_tree_with_changes(self):
545
tree = self.make_local_branch_and_tree()
547
self.build_tree_contents([('local/file', 'modified')])
550
def set_config_push_strict(self, tree, value):
551
# set config var (any of bazaar.conf, locations.conf, branch.conf
553
conf = tree.branch.get_config()
554
conf.set_user_option('push_strict', value)
556
def assertPushFails(self, location, *args):
557
self.run_bzr_error(['Working tree ".*/local/"'
558
' has uncommitted changes.$',],
559
['push', '../' + location] + list(args),
560
working_dir='local', retcode=3)
562
def assertPushSucceeds(self, location, *args):
563
self.run_bzr(['push', '../' + location] + list(args),
565
tree_to = workingtree.WorkingTree.open(location)
546
566
repo_to = tree_to.branch.repository
547
567
self.assertTrue(repo_to.has_revision('from-1'))
548
568
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
550
570
def test_push_default(self):
551
tree = self.make_local_branch_and_tree()
553
self.build_tree_contents([('local/file', 'modified')])
554
# Push with some uncommitted changes works
555
self.run_bzr(['push', '../to'], working_dir='local')
556
self.assertTreePushed('to')
571
tree = self.make_local_branch_and_tree_with_changes()
572
self.assertPushSucceeds('to')
574
def test_push_no_strict_with_changes(self):
575
tree = self.make_local_branch_and_tree_with_changes()
576
self.assertPushSucceeds('to', '--no-strict')
558
578
def test_push_strict_with_changes(self):
559
tree = self.make_local_branch_and_tree()
561
self.build_tree_contents([('local/file', 'modified')])
562
# Push with some uncommitted changes fails
563
self.run_bzr_error(['Working tree ".*/local/"'
564
' has uncommitted changes.$',],
565
['push', '--strict', '../to'],
566
working_dir='local', retcode=3)
579
tree = self.make_local_branch_and_tree_with_changes()
580
self.assertPushFails('to', '--strict')
568
582
def test_push_strict_without_changes(self):
569
583
tree = self.make_local_branch_and_tree()
570
self.run_bzr(['push', '--strict', '../to'], working_dir='local')
571
self.assertTreePushed('to')
573
def test_push_respect_config_var(self):
574
tree = self.make_local_branch_and_tree()
576
self.build_tree_contents([('local/file', 'modified')])
577
# set config var (any of bazaar.conf, locations.conf, branch.conf
579
conf = tree.branch.get_config()
580
conf.set_user_option('push_strict', 'true')
581
# Push --strict (inherited from config) with some uncommitted changes
583
self.run_bzr_error(['Working tree ".*/local/"'
584
' has uncommitted changes.$',],
586
working_dir='local', retcode=3)
588
def test_push_command_line_override_config(self):
589
tree = self.make_local_branch_and_tree()
591
self.build_tree_contents([('local/file', 'modified')])
592
# set config var (any of bazaar.conf, locations.conf, branch.conf
594
conf = tree.branch.get_config()
595
conf.set_user_option('push_strict', 'true')
596
self.run_bzr(['push', '--no-strict', '../to'], working_dir='local')
597
self.assertTreePushed('to')
584
self.assertPushSucceeds('to', '--strict')
586
def test_push_respect_config_var_strict(self):
587
tree = self.make_local_branch_and_tree_with_changes()
588
self.set_config_push_strict(tree, 'true')
589
# Push --strict (inherited from config) fails
590
self.assertPushFails('to')
592
def test_push_no_strict_command_line_override_config(self):
593
tree = self.make_local_branch_and_tree_with_changes()
594
self.set_config_push_strict(tree, 'true')
595
self.assertPushSucceeds('to', '--no-strict')
597
def test_push_strict_command_line_override_config(self):
598
tree = self.make_local_branch_and_tree_with_changes()
599
self.set_config_push_strict(tree, 'False')
600
self.assertPushFails('to', '--strict')