530
530
% re.escape(destination_url)],
531
531
['push', '-d', 'tree', destination_url], retcode=3)
532
532
self.assertEqual('', out)
535
class TestPushStrict(tests.TestCaseWithTransport):
537
def make_local_branch_and_tree(self):
538
tree = self.make_branch_and_tree('local')
539
self.build_tree_contents([('local/file', 'initial')])
541
tree.commit('adding file', rev_id='from-1')
544
def assertTreePushed(self, relpath):
545
tree_to = workingtree.WorkingTree.open(relpath)
546
repo_to = tree_to.branch.repository
547
self.assertTrue(repo_to.has_revision('from-1'))
548
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
550
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')
558
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)
568
def test_push_strict_without_changes(self):
569
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')