1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2005, 2007, 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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)
150
146
# bzr push of a branch with revisions to a new location
151
147
# should print the number of revisions equal to the length of the
149
self.thisFailsStrictLockCheck()
153
150
t = self.make_branch_and_tree('tree')
154
151
self.build_tree(['tree/file'])
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<>%&;"\'')
204
203
self.run_bzr('push -d tree new-tree')
206
205
def test_push_dash_d(self):
206
self.thisFailsStrictLockCheck()
207
207
t = self.make_branch_and_tree('from')
208
208
t.commit(allow_pointless=True,
209
209
message='first commit')
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
309
293
def test_push_create_prefix(self):
310
294
"""'bzr push --create-prefix' will create leading directories."""
295
self.thisFailsStrictLockCheck()
311
296
tree = self.create_simple_tree()
313
298
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
325
310
By default, 'bzr push' will not use an existing, non-versioned dir.
312
self.thisFailsStrictLockCheck()
327
313
tree = self.create_simple_tree()
328
314
self.build_tree(['target/'])
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'])
687
670
self.make_local_branch_and_tree()
689
672
def test_push_default(self):
673
self.thisFailsStrictLockCheck()
690
674
self.assertPushSucceeds([])
692
676
def test_push_strict(self):
677
self.thisFailsStrictLockCheck()
693
678
self.assertPushSucceeds(['--strict'])
695
680
def test_push_no_strict(self):
681
self.thisFailsStrictLockCheck()
696
682
self.assertPushSucceeds(['--no-strict'])
698
684
def test_push_config_var_strict(self):
685
self.thisFailsStrictLockCheck()
699
686
self.set_config_push_strict('true')
700
687
self.assertPushSucceeds([])
702
689
def test_push_config_var_no_strict(self):
690
self.thisFailsStrictLockCheck()
703
691
self.set_config_push_strict('false')
704
692
self.assertPushSucceeds([])
713
701
super(TestPushStrictWithChanges, self).setUp()
714
# Apply the changes defined in load_tests: one of _uncommitted_changes,
715
# _pending_merges or _out_of_sync_trees
716
702
getattr(self, self._changes_type)()
718
704
def _uncommitted_changes(self):
748
734
self.assertPushFails([])
750
736
def test_push_with_revision(self):
737
self.thisFailsStrictLockCheck()
751
738
self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
753
740
def test_push_no_strict(self):
741
self.thisFailsStrictLockCheck()
754
742
self.assertPushSucceeds(['--no-strict'])
756
744
def test_push_strict_with_changes(self):
765
753
self.assertPushFails([])
767
755
def test_push_no_strict_command_line_override_config(self):
756
self.thisFailsStrictLockCheck()
768
757
self.set_config_push_strict('yES')
769
758
self.assertPushFails([])
770
759
self.assertPushSucceeds(['--no-strict'])
772
761
def test_push_strict_command_line_override_config(self):
762
self.thisFailsStrictLockCheck()
773
763
self.set_config_push_strict('oFF')
774
764
self.assertPushFails(['--strict'])
775
765
self.assertPushSucceeds([])
778
class TestPushForeign(blackbox.ExternalBase):
781
super(TestPushForeign, self).setUp()
782
test_foreign.register_dummy_foreign_for_test(self)
784
def make_dummy_builder(self, relpath):
785
builder = self.make_branch_builder(
786
relpath, format=test_foreign.DummyForeignVcsDirFormat())
787
builder.build_snapshot('revid', None,
788
[('add', ('', 'TREE_ROOT', 'directory', None)),
789
('add', ('foo', 'fooid', 'file', 'bar'))])
792
def test_no_roundtripping(self):
793
target_branch = self.make_dummy_builder('dp').get_branch()
794
source_tree = self.make_branch_and_tree("dc")
795
output, error = self.run_bzr("push -d dc dp", retcode=3)
796
self.assertEquals("", output)
797
self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
798
" push to dummy. You may want to use dpush instead.\n")