1
# Copyright (C) 2006-2012 Canonical Ltd
1
# Copyright (C) 2006-2012, 2016 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
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
self.assertEquals(out,
69
69
('','bzr: 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
self.assertEquals(out,
75
75
('','bzr: ERROR: No push location known or specified. '
76
76
'To push to the parent branch '
77
77
'(at %s), use \'bzr push :parent\'.\n' %
101
101
# test push for failure without push location set
102
102
out = self.run_bzr('push', working_dir='branch_a', retcode=3)
103
self.assertEquals(out,
103
self.assertEqual(out,
104
104
('','bzr: 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)
111
111
('', 'bzr: 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
self.assertEquals(out,
117
self.assertEqual(out,
118
118
('','bzr: ERROR: These branches have diverged. '
119
119
'See "bzr 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
self.assertEquals(osutils.abspath(branch_a.get_push_location()),
122
self.assertEqual(osutils.abspath(branch_a.get_push_location()),
123
123
osutils.abspath(branch_b.bzrdir.root_transport.base))
125
125
# test implicit --remember after resolving previous failure
140
140
self.run_bzr('push ../branch_c --remember', working_dir='branch_a')
141
141
# Refresh the branch as 'push' modified it
142
142
branch_a = branch_a.bzrdir.open_branch()
143
self.assertEquals(branch_a.get_push_location(),
143
self.assertEqual(branch_a.get_push_location(),
144
144
branch_c.bzrdir.root_transport.base)
146
146
def test_push_without_tree(self):
452
452
self.assertTrue(repo_to.has_revision('from-1'))
453
453
self.assertFalse(repo_to.has_revision('from-2'))
454
454
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
456
tree_to.changes_from(tree_to.basis_tree()).has_changed())
456
458
self.run_bzr_error(
457
459
['bzr: ERROR: bzr push --revision '
613
615
self.assertEqual('', out)
614
616
self.assertEqual('Created new branch.\n', err)
618
def test_overwrite_tags(self):
619
"""--overwrite-tags only overwrites tags, not revisions."""
620
from_tree = self.make_branch_and_tree('from')
621
from_tree.branch.tags.set_tag("mytag", "somerevid")
622
to_tree = self.make_branch_and_tree('to')
623
to_tree.branch.tags.set_tag("mytag", "anotherrevid")
624
revid1 = to_tree.commit('my commit')
625
out = self.run_bzr(['push', '-d', 'from', 'to'])
626
self.assertEqual(out,
627
('Conflicting tags:\n mytag\n', 'No new revisions to push.\n'))
628
out = self.run_bzr(['push', '-d', 'from', '--overwrite-tags', 'to'])
629
self.assertEqual(out, ('', '1 tag updated.\n'))
630
self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
632
self.assertEqual(to_tree.branch.last_revision(), revid1)
617
635
class RedirectingMemoryTransport(memory.MemoryTransport):
665
683
class TestPushRedirect(tests.TestCaseWithTransport):
668
tests.TestCaseWithTransport.setUp(self)
686
super(TestPushRedirect, self).setUp()
669
687
self.memory_server = RedirectingMemoryServer()
670
688
self.start_server(self.memory_server)
671
689
# Make the branch and tree that we'll be pushing.
874
892
target_branch = self.make_dummy_builder('dp').get_branch()
875
893
source_tree = self.make_branch_and_tree("dc")
876
894
output, error = self.run_bzr("push -d dc dp", retcode=3)
877
self.assertEquals("", output)
878
self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
895
self.assertEqual("", output)
896
self.assertEqual(error, "bzr: ERROR: It is not possible to losslessly"
879
897
" push to dummy. You may want to use dpush instead.\n")
901
919
2>All changes applied successfully.
902
920
2>Pushed up to revision 1.
923
def test_push_with_revspec(self):
926
Shared repository with trees (format: 2a)
930
Created a repository tree (format: 2a)
931
Using shared repository...
933
$ bzr commit -m 'first rev' --unchanged
934
2>Committing to:...trunk/
935
2>Committed revision 1.
939
$ bzr commit -m 'we need some foo'
940
2>Committing to:...trunk/
942
2>Committed revision 2.
943
$ bzr push -r 1 ../other
944
2>Created new branch.
945
$ bzr st ../other # checking that file is not created (#484516)