215
215
remote = branch.Branch.open('public')
216
216
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
218
def test_push_smart_with_default_stacking_url_path_segment(self):
219
# If the default stacked-on location is a path element then branches
220
# we push there over the smart server are stacked and their
221
# stacked_on_url is that exact path segment. Added to nail bug 385132.
222
self.setup_smart_server_with_call_log()
223
self.make_branch('stack-on', format='1.9')
224
self.make_bzrdir('.').get_config().set_default_stack_on(
226
self.make_branch('from', format='1.9')
227
out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')])
228
b = branch.Branch.open(self.get_url('to'))
229
self.assertEqual('/extra/stack-on', b.get_stacked_on_url())
231
def test_push_smart_with_default_stacking_relative_path(self):
232
# If the default stacked-on location is a relative path then branches
233
# we push there over the smart server are stacked and their
234
# stacked_on_url is a relative path. Added to nail bug 385132.
235
self.setup_smart_server_with_call_log()
236
self.make_branch('stack-on', format='1.9')
237
self.make_bzrdir('.').get_config().set_default_stack_on('stack-on')
238
self.make_branch('from', format='1.9')
239
out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')])
240
b = branch.Branch.open(self.get_url('to'))
241
self.assertEqual('../stack-on', b.get_stacked_on_url())
218
243
def create_simple_tree(self):
219
244
tree = self.make_branch_and_tree('tree')
220
245
self.build_tree(['tree/a'])
530
555
% re.escape(destination_url)],
531
556
['push', '-d', 'tree', destination_url], retcode=3)
532
557
self.assertEqual('', out)
560
class TestPushStrict(tests.TestCaseWithTransport):
562
def make_local_branch_and_tree(self):
563
tree = self.make_branch_and_tree('local')
564
self.build_tree_contents([('local/file', 'initial')])
566
tree.commit('adding file', rev_id='from-1')
569
def make_local_branch_and_tree_with_changes(self):
570
tree = self.make_local_branch_and_tree()
572
self.build_tree_contents([('local/file', 'modified')])
575
def set_config_push_strict(self, tree, value):
576
# set config var (any of bazaar.conf, locations.conf, branch.conf
578
conf = tree.branch.get_config()
579
conf.set_user_option('push_strict', value)
581
def assertPushFails(self, location, *args):
582
self.run_bzr_error(['Working tree ".*/local/"'
583
' has uncommitted changes.$',],
584
['push', '../' + location] + list(args),
585
working_dir='local', retcode=3)
587
def assertPushSucceeds(self, location, *args):
588
self.run_bzr(['push', '../' + location] + list(args),
590
tree_to = workingtree.WorkingTree.open(location)
591
repo_to = tree_to.branch.repository
592
self.assertTrue(repo_to.has_revision('from-1'))
593
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
595
def test_push_default(self):
596
tree = self.make_local_branch_and_tree_with_changes()
597
self.assertPushSucceeds('to')
599
def test_push_no_strict_with_changes(self):
600
tree = self.make_local_branch_and_tree_with_changes()
601
self.assertPushSucceeds('to', '--no-strict')
603
def test_push_strict_with_changes(self):
604
tree = self.make_local_branch_and_tree_with_changes()
605
self.assertPushFails('to', '--strict')
607
def test_push_strict_without_changes(self):
608
tree = self.make_local_branch_and_tree()
609
self.assertPushSucceeds('to', '--strict')
611
def test_push_respect_config_var_strict(self):
612
tree = self.make_local_branch_and_tree_with_changes()
613
self.set_config_push_strict(tree, 'true')
614
self.assertPushFails('to')
616
def test_push_bogus_config_var_ignored(self):
617
tree = self.make_local_branch_and_tree_with_changes()
618
self.set_config_push_strict(tree, "I don't want you to be strict")
619
self.assertPushSucceeds('to')
621
def test_push_no_strict_command_line_override_config(self):
622
tree = self.make_local_branch_and_tree_with_changes()
623
self.set_config_push_strict(tree, 'yES')
624
self.assertPushFails('to')
625
self.assertPushSucceeds('to', '--no-strict')
627
def test_push_strict_command_line_override_config(self):
628
tree = self.make_local_branch_and_tree_with_changes()
629
self.set_config_push_strict(tree, 'oFF')
630
self.assertPushFails('to', '--strict')
631
self.assertPushSucceeds('to')