140
135
def test_push_without_tree(self):
141
136
# bzr push from a branch that does not have a checkout should work.
137
self.thisFailsStrictLockCheck()
142
138
b = self.make_branch('.')
143
139
out, err = self.run_bzr('push pushed-location')
144
140
self.assertEqual('', out)
161
158
def test_push_only_pushes_history(self):
162
159
# Knit branches should only push the history for the current revision.
160
self.thisFailsStrictLockCheck()
163
161
format = bzrdir.BzrDirMetaFormat1()
164
162
format.repository_format = knitrepo.RepositoryFormatKnit1()
165
163
shared_repo = self.make_repository('repo', format=format, shared=True)
197
195
self.assertTrue(pushed_repo.has_revision('b-1'))
199
197
def test_push_funky_id(self):
198
self.thisFailsStrictLockCheck()
200
199
t = self.make_branch_and_tree('tree')
201
200
self.build_tree(['tree/filename'])
202
201
t.add('filename', 'funky-chars<>%&;"\'')
258
258
# upwards without agreement from bzr's network support maintainers.
259
259
self.assertLength(11, self.hpss_calls)
261
def test_push_smart_incremental_acceptance(self):
262
self.setup_smart_server_with_call_log()
263
t = self.make_branch_and_tree('from')
264
rev_id1 = t.commit(allow_pointless=True, message='first commit')
265
rev_id2 = t.commit(allow_pointless=True, message='second commit')
267
['push', self.get_url('to-one'), '-r1'], working_dir='from')
268
self.reset_smart_call_log()
269
self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
270
# This figure represent the amount of work to perform this use case. It
271
# is entirely ok to reduce this number if a test fails due to rpc_count
272
# being too low. If rpc_count increases, more network roundtrips have
273
# become necessary for this use case. Please do not adjust this number
274
# upwards without agreement from bzr's network support maintainers.
275
self.assertLength(11, self.hpss_calls)
277
261
def test_push_smart_with_default_stacking_url_path_segment(self):
278
262
# If the default stacked-on location is a path element then branches
279
263
# we push there over the smart server are stacked and their
340
326
# The push should have created target/a
341
327
self.failUnlessExists('target/a')
343
def test_push_use_existing_into_empty_bzrdir(self):
344
"""'bzr push --use-existing-dir' into a dir with an empty .bzr dir
347
tree = self.create_simple_tree()
348
self.build_tree(['target/', 'target/.bzr/'])
350
['Target directory ../target already contains a .bzr directory, '
351
'but it is not valid.'],
352
'push ../target --use-existing-dir', working_dir='tree')
354
329
def test_push_onto_repo(self):
355
330
"""We should be able to 'bzr push' into an existing bzrdir."""
356
331
tree = self.create_simple_tree()
384
359
def test_push_with_revisionspec(self):
385
360
"""We should be able to push a revision older than the tip."""
361
self.thisFailsStrictLockCheck()
386
362
tree_from = self.make_branch_and_tree('from')
387
363
tree_from.commit("One.", rev_id="from-1")
388
364
tree_from.commit("Two.", rev_id="from-2")
425
401
def test_push_new_branch_stacked_on(self):
426
402
"""Pushing a new branch with --stacked-on creates a stacked branch."""
403
self.thisFailsStrictLockCheck()
427
404
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
428
405
# we publish branch_tree with a reference to the mainline.
429
406
out, err = self.run_bzr(['push', '--stacked-on', trunk_tree.branch.base,
437
414
def test_push_new_branch_stacked_uses_parent_when_no_public_url(self):
438
415
"""When the parent has no public url the parent is used as-is."""
416
self.thisFailsStrictLockCheck()
439
417
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
440
418
# now we do a stacked push, which should determine the public location
450
428
def test_push_new_branch_stacked_uses_parent_public(self):
451
429
"""Pushing a new branch with --stacked creates a stacked branch."""
430
self.thisFailsStrictLockCheck()
452
431
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
453
432
# the trunk is published on a web server
454
433
self.transport_readonly_server = http_server.HttpServer
533
512
out, err = self.run_bzr('push -d repo/local remote -r 3')
535
514
def test_push_verbose_shows_log(self):
515
self.thisFailsStrictLockCheck()
536
516
tree = self.make_branch_and_tree('source')
537
517
tree.commit('rev1')
538
518
out, err = self.run_bzr('push -v -d source target')
546
526
self.assertNotContainsRe(out, 'rev1')
548
528
def test_push_from_subdir(self):
529
self.thisFailsStrictLockCheck()
549
530
t = self.make_branch_and_tree('tree')
550
531
self.build_tree(['tree/dir/', 'tree/dir/file'])
551
532
t.add('dir', 'dir/file')
609
590
tests.TestCaseWithTransport.setUp(self)
610
591
self.memory_server = RedirectingMemoryServer()
611
self.start_server(self.memory_server)
592
self.memory_server.setUp()
593
self.addCleanup(self.memory_server.tearDown)
612
595
# Make the branch and tree that we'll be pushing.
613
596
t = self.make_branch_and_tree('tree')
614
597
self.build_tree(['tree/file'])
661
644
_default_wd = 'local'
662
645
_default_errors = ['Working tree ".*/local/" has uncommitted '
663
646
'changes \(See bzr status\)\.',]
664
_default_additional_error = 'Use --no-strict to force the push.\n'
665
_default_additional_warning = 'Uncommitted changes will not be pushed.'
647
_default_pushed_revid = 'modified'
668
649
def assertPushFails(self, args):
669
out, err = self.run_bzr_error(self._default_errors,
670
self._default_command + args,
671
working_dir=self._default_wd, retcode=3)
672
self.assertContainsRe(err, self._default_additional_error)
650
self.run_bzr_error(self._default_errors, self._default_command + args,
651
working_dir=self._default_wd, retcode=3)
674
def assertPushSucceeds(self, args, with_warning=False, revid_to_push=None):
676
error_regexes = self._default_errors
679
out, err = self.run_bzr(self._default_command + args,
680
working_dir=self._default_wd,
681
error_regexes=error_regexes)
683
self.assertContainsRe(err, self._default_additional_warning)
685
self.assertNotContainsRe(err, self._default_additional_warning)
686
branch_from = branch.Branch.open(self._default_wd)
687
if revid_to_push is None:
688
revid_to_push = branch_from.last_revision()
689
branch_to = branch.Branch.open('to')
690
repo_to = branch_to.repository
691
self.assertTrue(repo_to.has_revision(revid_to_push))
692
self.assertEqual(revid_to_push, branch_to.last_revision())
653
def assertPushSucceeds(self, args, pushed_revid=None):
654
self.run_bzr(self._default_command + args,
655
working_dir=self._default_wd)
656
if pushed_revid is None:
657
pushed_revid = self._default_pushed_revid
658
tree_to = workingtree.WorkingTree.open('to')
659
repo_to = tree_to.branch.repository
660
self.assertTrue(repo_to.has_revision(pushed_revid))
661
self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
701
670
self.make_local_branch_and_tree()
703
672
def test_push_default(self):
673
self.thisFailsStrictLockCheck()
704
674
self.assertPushSucceeds([])
706
676
def test_push_strict(self):
677
self.thisFailsStrictLockCheck()
707
678
self.assertPushSucceeds(['--strict'])
709
680
def test_push_no_strict(self):
681
self.thisFailsStrictLockCheck()
710
682
self.assertPushSucceeds(['--no-strict'])
712
684
def test_push_config_var_strict(self):
685
self.thisFailsStrictLockCheck()
713
686
self.set_config_push_strict('true')
714
687
self.assertPushSucceeds([])
716
689
def test_push_config_var_no_strict(self):
690
self.thisFailsStrictLockCheck()
717
691
self.set_config_push_strict('false')
718
692
self.assertPushSucceeds([])
727
701
super(TestPushStrictWithChanges, self).setUp()
728
# Apply the changes defined in load_tests: one of _uncommitted_changes,
729
# _pending_merges or _out_of_sync_trees
730
702
getattr(self, self._changes_type)()
732
704
def _uncommitted_changes(self):
756
728
self._default_wd = 'checkout'
757
729
self._default_errors = ["Working tree is out of date, please run"
758
730
" 'bzr update'\.",]
731
self._default_pushed_revid = 'modified-in-local'
760
733
def test_push_default(self):
761
self.assertPushSucceeds([], with_warning=True)
734
self.assertPushFails([])
763
736
def test_push_with_revision(self):
764
self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
737
self.thisFailsStrictLockCheck()
738
self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
766
740
def test_push_no_strict(self):
741
self.thisFailsStrictLockCheck()
767
742
self.assertPushSucceeds(['--no-strict'])
769
744
def test_push_strict_with_changes(self):
776
751
def test_push_bogus_config_var_ignored(self):
777
752
self.set_config_push_strict("I don't want you to be strict")
778
self.assertPushSucceeds([], with_warning=True)
753
self.assertPushFails([])
780
755
def test_push_no_strict_command_line_override_config(self):
756
self.thisFailsStrictLockCheck()
781
757
self.set_config_push_strict('yES')
782
758
self.assertPushFails([])
783
759
self.assertPushSucceeds(['--no-strict'])
785
761
def test_push_strict_command_line_override_config(self):
762
self.thisFailsStrictLockCheck()
786
763
self.set_config_push_strict('oFF')
787
764
self.assertPushFails(['--strict'])
788
765
self.assertPushSucceeds([])
791
class TestPushForeign(blackbox.ExternalBase):
794
super(TestPushForeign, self).setUp()
795
test_foreign.register_dummy_foreign_for_test(self)
797
def make_dummy_builder(self, relpath):
798
builder = self.make_branch_builder(
799
relpath, format=test_foreign.DummyForeignVcsDirFormat())
800
builder.build_snapshot('revid', None,
801
[('add', ('', 'TREE_ROOT', 'directory', None)),
802
('add', ('foo', 'fooid', 'file', 'bar'))])
805
def test_no_roundtripping(self):
806
target_branch = self.make_dummy_builder('dp').get_branch()
807
source_tree = self.make_branch_and_tree("dc")
808
output, error = self.run_bzr("push -d dc dp", retcode=3)
809
self.assertEquals("", output)
810
self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
811
" push to dummy. You may want to use dpush instead.\n")