15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Black-box tests for bzr push."""
18
"""Black-box tests for brz push."""
34
from bzrlib.repofmt import knitrepo
35
from bzrlib.tests import (
34
from breezy.repofmt import knitrepo
35
from breezy.tests import (
41
from bzrlib.tests.matchers import ContainsNoVfsCalls
42
from bzrlib.transport import memory
41
from breezy.tests.matchers import ContainsNoVfsCalls
42
from breezy.transport import memory
45
45
load_tests = scenarios.load_tests_apply_scenarios
66
66
# If there is no parent location set, :parent isn't mentioned.
67
67
out = self.run_bzr('push', working_dir='a', retcode=3)
68
68
self.assertEqual(out,
69
('','bzr: ERROR: No push location known or specified.\n'))
69
('','brz: ERROR: No push location known or specified.\n'))
71
71
# If there is a parent location set, the error suggests :parent.
72
72
tree_a.branch.set_parent(tree_b.branch.base)
73
73
out = self.run_bzr('push', working_dir='a', retcode=3)
74
74
self.assertEqual(out,
75
('','bzr: ERROR: No push location known or specified. '
75
('','brz: ERROR: No push location known or specified. '
76
76
'To push to the parent branch '
77
'(at %s), use \'bzr push :parent\'.\n' %
77
'(at %s), use \'brz push :parent\'.\n' %
78
78
urlutils.unescape_for_display(tree_b.branch.base, 'utf-8')))
80
80
def test_push_remember(self):
101
101
# test push for failure without push location set
102
102
out = self.run_bzr('push', working_dir='branch_a', retcode=3)
103
103
self.assertEqual(out,
104
('','bzr: ERROR: No push location known or specified.\n'))
104
('','brz: ERROR: No push location known or specified.\n'))
106
106
# test not remembered if cannot actually push
107
107
self.run_bzr('push path/which/doesnt/exist',
108
108
working_dir='branch_a', retcode=3)
109
109
out = self.run_bzr('push', working_dir='branch_a', retcode=3)
110
110
self.assertEqual(
111
('', 'bzr: ERROR: No push location known or specified.\n'),
111
('', 'brz: ERROR: No push location known or specified.\n'),
114
114
# test implicit --remember when no push location set, push fails
115
115
out = self.run_bzr('push ../branch_b',
116
116
working_dir='branch_a', retcode=3)
117
117
self.assertEqual(out,
118
('','bzr: ERROR: These branches have diverged. '
119
'See "bzr help diverged-branches" for more information.\n'))
118
('','brz: ERROR: These branches have diverged. '
119
'See "brz help diverged-branches" for more information.\n'))
120
120
# Refresh the branch as 'push' modified it
121
121
branch_a = branch_a.bzrdir.open_branch()
122
122
self.assertEqual(osutils.abspath(branch_a.get_push_location()),
144
144
branch_c.bzrdir.root_transport.base)
146
146
def test_push_without_tree(self):
147
# bzr push from a branch that does not have a checkout should work.
147
# brz push from a branch that does not have a checkout should work.
148
148
b = self.make_branch('.')
149
149
out, err = self.run_bzr('push pushed-location')
150
150
self.assertEqual('', out)
153
153
self.assertEndsWith(b2.base, 'pushed-location/')
155
155
def test_push_no_tree(self):
156
# bzr push --no-tree of a branch with working trees
156
# brz push --no-tree of a branch with working trees
157
157
b = self.make_branch_and_tree('push-from')
158
158
self.build_tree(['push-from/file'])
164
164
self.assertPathDoesNotExist('push-to/file')
166
166
def test_push_new_branch_revision_count(self):
167
# bzr push of a branch with revisions to a new location
167
# brz push of a branch with revisions to a new location
168
168
# should print the number of revisions equal to the length of the
170
170
t = self.make_branch_and_tree('tree')
367
367
def test_push_create_prefix(self):
368
"""'bzr push --create-prefix' will create leading directories."""
368
"""'brz push --create-prefix' will create leading directories."""
369
369
tree = self.create_simple_tree()
371
371
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
378
378
self.assertPathExists('new/tree/a')
380
380
def test_push_use_existing(self):
381
"""'bzr push --use-existing-dir' can push into an existing dir.
381
"""'brz push --use-existing-dir' can push into an existing dir.
383
By default, 'bzr push' will not use an existing, non-versioned dir.
383
By default, 'brz push' will not use an existing, non-versioned dir.
385
385
tree = self.create_simple_tree()
386
386
self.build_tree(['target/'])
399
399
self.assertPathExists('target/a')
401
401
def test_push_use_existing_into_empty_bzrdir(self):
402
"""'bzr push --use-existing-dir' into a dir with an empty .bzr dir
402
"""'brz push --use-existing-dir' into a dir with an empty .bzr dir
405
405
tree = self.create_simple_tree()
410
410
'push ../target --use-existing-dir', working_dir='tree')
412
412
def test_push_onto_repo(self):
413
"""We should be able to 'bzr push' into an existing bzrdir."""
413
"""We should be able to 'brz push' into an existing bzrdir."""
414
414
tree = self.create_simple_tree()
415
415
repo = self.make_repository('repo', shared=True)
456
456
tree_to.changes_from(tree_to.basis_tree()).has_changed())
458
458
self.run_bzr_error(
459
['bzr: ERROR: bzr push --revision '
459
['brz: ERROR: brz push --revision '
460
460
'takes exactly one revision identifier\n'],
461
461
'push -r0..2 ../to', working_dir='from')
735
735
_default_command = ['push', '../to']
736
736
_default_wd = 'local'
737
737
_default_errors = ['Working tree ".*/local/" has uncommitted '
738
'changes \(See bzr status\)\.',]
738
'changes \(See brz status\)\.',]
739
739
_default_additional_error = 'Use --no-strict to force the push.\n'
740
740
_default_additional_warning = 'Uncommitted changes will not be pushed.'
841
841
# Exercise commands from the checkout directory
842
842
self._default_wd = 'checkout'
843
843
self._default_errors = ["Working tree is out of date, please run"
846
846
def test_push_default(self):
847
847
self.assertPushSucceeds([], with_warning=True)
893
893
source_tree = self.make_branch_and_tree("dc")
894
894
output, error = self.run_bzr("push -d dc dp", retcode=3)
895
895
self.assertEqual("", output)
896
self.assertEqual(error, "bzr: ERROR: It is not possible to losslessly"
896
self.assertEqual(error, "brz: ERROR: It is not possible to losslessly"
897
897
" push to dummy. You may want to use dpush instead.\n")
902
902
def test_push_log_format(self):
903
903
self.run_script("""
905
905
Created a standalone tree (format: 2a)
907
907
$ echo foo > file
910
$ bzr commit -m 'we need some foo'
910
$ brz commit -m 'we need some foo'
911
911
2>Committing to:...trunk/
913
913
2>Committed revision 1.
914
$ bzr init ../feature
914
$ brz init ../feature
915
915
Created a standalone tree (format: 2a)
916
$ bzr push -v ../feature -Olog_format=line
916
$ brz push -v ../feature -Olog_format=line
918
918
1: jrandom@example.com ...we need some foo
919
919
2>All changes applied successfully.
923
923
def test_push_with_revspec(self):
924
924
self.run_script("""
926
926
Shared repository with trees (format: 2a)
928
928
shared repository: .
930
930
Created a repository tree (format: 2a)
931
931
Using shared repository...
933
$ bzr commit -m 'first rev' --unchanged
933
$ brz commit -m 'first rev' --unchanged
934
934
2>Committing to:...trunk/
935
935
2>Committed revision 1.
936
936
$ echo foo > file
939
$ bzr commit -m 'we need some foo'
939
$ brz commit -m 'we need some foo'
940
940
2>Committing to:...trunk/
942
942
2>Committed revision 2.
943
$ bzr push -r 1 ../other
943
$ brz push -r 1 ../other
944
944
2>Created new branch.
945
$ bzr st ../other # checking that file is not created (#484516)
945
$ brz st ../other # checking that file is not created (#484516)