~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_push.py

  • Committer: Ross Lagerwall
  • Date: 2012-08-07 06:32:51 UTC
  • mto: (6437.63.5 2.5)
  • mto: This revision was merged to the branch mainline in revision 6558.
  • Revision ID: rosslagerwall@gmail.com-20120807063251-x9p03ghg2ws8oqjc
Add bzrlib/locale to .bzrignore

bzrlib/locale is generated with ./setup.py build_mo which is in turn called
by ./setup.py build

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2011 Canonical Ltd
2
2
#
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
65
65
 
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.assertEqual(out,
 
68
        self.assertEquals(out,
69
69
                ('','bzr: ERROR: No push location known or specified.\n'))
70
70
 
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.assertEqual(out,
 
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' %
100
100
 
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.assertEqual(out,
 
103
        self.assertEquals(out,
104
104
                ('','bzr: ERROR: No push location known or specified.\n'))
105
105
 
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
 
        self.assertEqual(
 
110
        self.assertEquals(
111
111
                ('', 'bzr: ERROR: No push location known or specified.\n'),
112
112
                out)
113
113
 
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.assertEqual(out,
 
117
        self.assertEquals(out,
118
118
                ('','bzr: ERROR: These branches have diverged.  '
119
119
                 'See "bzr help diverged-branches" for more information.\n'))
120
 
        # Refresh the branch as 'push' modified it
121
 
        branch_a = branch_a.bzrdir.open_branch()
122
 
        self.assertEqual(osutils.abspath(branch_a.get_push_location()),
 
120
        self.assertEquals(osutils.abspath(branch_a.get_push_location()),
123
121
                          osutils.abspath(branch_b.bzrdir.root_transport.base))
124
122
 
125
123
        # test implicit --remember after resolving previous failure
126
124
        uncommit.uncommit(branch=branch_b, tree=tree_b)
127
125
        transport.delete('branch_b/c')
128
126
        out, err = self.run_bzr('push', working_dir='branch_a')
129
 
        # Refresh the branch as 'push' modified it
130
 
        branch_a = branch_a.bzrdir.open_branch()
131
127
        path = branch_a.get_push_location()
132
128
        self.assertEqual(err,
133
129
                         'Using saved push location: %s\n'
138
134
                         branch_b.bzrdir.root_transport.base)
139
135
        # test explicit --remember
140
136
        self.run_bzr('push ../branch_c --remember', working_dir='branch_a')
141
 
        # Refresh the branch as 'push' modified it
142
 
        branch_a = branch_a.bzrdir.open_branch()
143
 
        self.assertEqual(branch_a.get_push_location(),
 
137
        self.assertEquals(branch_a.get_push_location(),
144
138
                          branch_c.bzrdir.root_transport.base)
145
139
 
146
140
    def test_push_without_tree(self):
182
176
        t.add('file')
183
177
        t.commit('commit 1')
184
178
        self.run_bzr('push -d tree pushed-to')
185
 
        # Refresh the branch as 'push' modified it and get the push location
186
 
        push_loc = t.branch.bzrdir.open_branch().get_push_location()
 
179
        path = t.branch.get_push_location()
187
180
        out, err = self.run_bzr('push', working_dir="tree")
188
181
        self.assertEqual('Using saved push location: %s\n'
189
182
                         'No new revisions or tags to push.\n' %
190
 
                         urlutils.local_path_from_url(push_loc), err)
 
183
                         urlutils.local_path_from_url(path), err)
191
184
        out, err = self.run_bzr('push -q', working_dir="tree")
192
185
        self.assertEqual('', out)
193
186
        self.assertEqual('', err)
292
285
        # being too low. If rpc_count increases, more network roundtrips have
293
286
        # become necessary for this use case. Please do not adjust this number
294
287
        # upwards without agreement from bzr's network support maintainers.
295
 
        self.assertLength(15, self.hpss_calls)
 
288
        self.assertLength(14, self.hpss_calls)
296
289
        self.assertLength(1, self.hpss_connections)
297
290
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
298
291
        remote = branch.Branch.open('public')
452
445
        self.assertTrue(repo_to.has_revision('from-1'))
453
446
        self.assertFalse(repo_to.has_revision('from-2'))
454
447
        self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
455
 
        self.assertFalse(
456
 
            tree_to.changes_from(tree_to.basis_tree()).has_changed())
457
448
 
458
449
        self.run_bzr_error(
459
450
            ['bzr: ERROR: bzr push --revision '
515
506
        trunk_public = self.make_branch('public_trunk', format='1.9')
516
507
        trunk_public.pull(trunk_tree.branch)
517
508
        trunk_public_url = self.get_readonly_url('public_trunk')
518
 
        br = trunk_tree.branch
519
 
        br.set_public_branch(trunk_public_url)
 
509
        trunk_tree.branch.set_public_branch(trunk_public_url)
520
510
        # now we do a stacked push, which should determine the public location
521
511
        # for us.
522
512
        out, err = self.run_bzr(['push', '--stacked',
615
605
        self.assertEqual('', out)
616
606
        self.assertEqual('Created new branch.\n', err)
617
607
 
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'),
631
 
                          'somerevid')
632
 
        self.assertEqual(to_tree.branch.last_revision(), revid1)
633
 
 
634
608
 
635
609
class RedirectingMemoryTransport(memory.MemoryTransport):
636
610
 
683
657
class TestPushRedirect(tests.TestCaseWithTransport):
684
658
 
685
659
    def setUp(self):
686
 
        super(TestPushRedirect, self).setUp()
 
660
        tests.TestCaseWithTransport.setUp(self)
687
661
        self.memory_server = RedirectingMemoryServer()
688
662
        self.start_server(self.memory_server)
689
663
        # Make the branch and tree that we'll be pushing.
729
703
        self.tree.commit('modify file', rev_id='modified')
730
704
 
731
705
    def set_config_push_strict(self, value):
732
 
        br = branch.Branch.open('local')
733
 
        br.get_config_stack().set('push_strict', value)
 
706
        # set config var (any of bazaar.conf, locations.conf, branch.conf
 
707
        # should do)
 
708
        conf = self.tree.branch.get_config_stack()
 
709
        conf.set('push_strict', value)
734
710
 
735
711
    _default_command = ['push', '../to']
736
712
    _default_wd = 'local'
892
868
        target_branch = self.make_dummy_builder('dp').get_branch()
893
869
        source_tree = self.make_branch_and_tree("dc")
894
870
        output, error = self.run_bzr("push -d dc dp", retcode=3)
895
 
        self.assertEqual("", output)
896
 
        self.assertEqual(error, "bzr: ERROR: It is not possible to losslessly"
 
871
        self.assertEquals("", output)
 
872
        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
897
873
            " push to dummy. You may want to use dpush instead.\n")
898
874
 
899
875
 
919
895
            2>All changes applied successfully.
920
896
            2>Pushed up to revision 1.
921
897
            """)
922
 
 
923
 
    def test_push_with_revspec(self):
924
 
        self.run_script("""
925
 
            $ bzr init-repo .
926
 
            Shared repository with trees (format: 2a)
927
 
            Location:
928
 
              shared repository: .
929
 
            $ bzr init trunk
930
 
            Created a repository tree (format: 2a)
931
 
            Using shared repository...
932
 
            $ cd trunk
933
 
            $ bzr commit -m 'first rev' --unchanged
934
 
            2>Committing to:...trunk/
935
 
            2>Committed revision 1.
936
 
            $ echo foo > file
937
 
            $ bzr add
938
 
            adding file
939
 
            $ bzr commit -m 'we need some foo'
940
 
            2>Committing to:...trunk/
941
 
            2>added file
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)
946
 
            """)