~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(gz) Remove bzrlib/util/elementtree/ package (Martin Packman)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    branch,
24
24
    bzrdir,
 
25
    controldir,
25
26
    errors,
26
27
    osutils,
27
28
    tests,
32
33
    )
33
34
from bzrlib.repofmt import knitrepo
34
35
from bzrlib.tests import (
35
 
    blackbox,
36
36
    http_server,
37
37
    scenarios,
 
38
    script,
38
39
    test_foreign,
39
 
    test_server,
40
40
    )
 
41
from bzrlib.tests.matchers import ContainsNoVfsCalls
41
42
from bzrlib.transport import memory
42
43
 
43
44
 
56
57
                           ['push', public_url],
57
58
                           working_dir='source')
58
59
 
 
60
    def test_push_suggests_parent_alias(self):
 
61
        """Push suggests using :parent if there is a known parent branch."""
 
62
        tree_a = self.make_branch_and_tree('a')
 
63
        tree_a.commit('this is a commit')
 
64
        tree_b = self.make_branch_and_tree('b')
 
65
 
 
66
        # If there is no parent location set, :parent isn't mentioned.
 
67
        out = self.run_bzr('push', working_dir='a', retcode=3)
 
68
        self.assertEquals(out,
 
69
                ('','bzr: ERROR: No push location known or specified.\n'))
 
70
 
 
71
        # If there is a parent location set, the error suggests :parent.
 
72
        tree_a.branch.set_parent(tree_b.branch.base)
 
73
        out = self.run_bzr('push', working_dir='a', retcode=3)
 
74
        self.assertEquals(out,
 
75
            ('','bzr: ERROR: No push location known or specified. '
 
76
                'To push to the parent branch '
 
77
                '(at %s), use \'bzr push :parent\'.\n' %
 
78
                urlutils.unescape_for_display(tree_b.branch.base, 'utf-8')))
 
79
 
59
80
    def test_push_remember(self):
60
81
        """Push changes from one branch to another and test push location."""
61
82
        transport = self.get_transport()
104
125
        transport.delete('branch_b/c')
105
126
        out, err = self.run_bzr('push', working_dir='branch_a')
106
127
        path = branch_a.get_push_location()
107
 
        self.assertEquals(out,
108
 
                          'Using saved push location: %s\n'
109
 
                          % urlutils.local_path_from_url(path))
110
128
        self.assertEqual(err,
 
129
                         'Using saved push location: %s\n'
111
130
                         'All changes applied successfully.\n'
112
 
                         'Pushed up to revision 2.\n')
 
131
                         'Pushed up to revision 2.\n'
 
132
                         % urlutils.local_path_from_url(path))
113
133
        self.assertEqual(path,
114
134
                         branch_b.bzrdir.root_transport.base)
115
135
        # test explicit --remember
149
169
        self.assertEqual('', out)
150
170
        self.assertEqual('Created new branch.\n', err)
151
171
 
 
172
    def test_push_quiet(self):
 
173
        # test that using -q makes output quiet
 
174
        t = self.make_branch_and_tree('tree')
 
175
        self.build_tree(['tree/file'])
 
176
        t.add('file')
 
177
        t.commit('commit 1')
 
178
        self.run_bzr('push -d tree pushed-to')
 
179
        path = t.branch.get_push_location()
 
180
        out, err = self.run_bzr('push', working_dir="tree")
 
181
        self.assertEqual('Using saved push location: %s\n'
 
182
                         'No new revisions or tags to push.\n' %
 
183
                         urlutils.local_path_from_url(path), err)
 
184
        out, err = self.run_bzr('push -q', working_dir="tree")
 
185
        self.assertEqual('', out)
 
186
        self.assertEqual('', err)
 
187
 
152
188
    def test_push_only_pushes_history(self):
153
189
        # Knit branches should only push the history for the current revision.
154
190
        format = bzrdir.BzrDirMetaFormat1()
158
194
 
159
195
        def make_shared_tree(path):
160
196
            shared_repo.bzrdir.root_transport.mkdir(path)
161
 
            shared_repo.bzrdir.create_branch_convenience('repo/' + path)
 
197
            controldir.ControlDir.create_branch_convenience('repo/' + path)
162
198
            return workingtree.WorkingTree.open('repo/' + path)
163
199
        tree_a = make_shared_tree('a')
164
200
        self.build_tree(['repo/a/file'])
232
268
        # become necessary for this use case. Please do not adjust this number
233
269
        # upwards without agreement from bzr's network support maintainers.
234
270
        self.assertLength(9, self.hpss_calls)
 
271
        self.assertLength(1, self.hpss_connections)
 
272
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
235
273
 
236
274
    def test_push_smart_stacked_streaming_acceptance(self):
237
275
        self.setup_smart_server_with_call_log()
247
285
        # being too low. If rpc_count increases, more network roundtrips have
248
286
        # become necessary for this use case. Please do not adjust this number
249
287
        # upwards without agreement from bzr's network support maintainers.
250
 
        self.assertLength(13, self.hpss_calls)
 
288
        self.assertLength(14, self.hpss_calls)
 
289
        self.assertLength(1, self.hpss_connections)
 
290
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
251
291
        remote = branch.Branch.open('public')
252
292
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
253
293
 
264
304
        # become necessary for this use case. Please do not adjust this number
265
305
        # upwards without agreement from bzr's network support maintainers.
266
306
        self.assertLength(11, self.hpss_calls)
 
307
        self.assertLength(1, self.hpss_connections)
 
308
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
267
309
 
268
310
    def test_push_smart_incremental_acceptance(self):
269
311
        self.setup_smart_server_with_call_log()
280
322
        # become necessary for this use case. Please do not adjust this number
281
323
        # upwards without agreement from bzr's network support maintainers.
282
324
        self.assertLength(11, self.hpss_calls)
 
325
        self.assertLength(1, self.hpss_connections)
 
326
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
283
327
 
284
328
    def test_push_smart_with_default_stacking_url_path_segment(self):
285
329
        # If the default stacked-on location is a path element then branches
661
705
    def set_config_push_strict(self, value):
662
706
        # set config var (any of bazaar.conf, locations.conf, branch.conf
663
707
        # should do)
664
 
        conf = self.tree.branch.get_config()
665
 
        conf.set_user_option('push_strict', value)
 
708
        conf = self.tree.branch.get_config_stack()
 
709
        conf.set('push_strict', value)
666
710
 
667
711
    _default_command = ['push', '../to']
668
712
    _default_wd = 'local'
827
871
        self.assertEquals("", output)
828
872
        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
829
873
            " push to dummy. You may want to use dpush instead.\n")
 
874
 
 
875
 
 
876
class TestPushOutput(script.TestCaseWithTransportAndScript):
 
877
 
 
878
    def test_push_log_format(self):
 
879
        self.run_script("""
 
880
            $ bzr init trunk
 
881
            Created a standalone tree (format: 2a)
 
882
            $ cd trunk
 
883
            $ echo foo > file
 
884
            $ bzr add
 
885
            adding file
 
886
            $ bzr commit -m 'we need some foo'
 
887
            2>Committing to:...trunk/
 
888
            2>added file
 
889
            2>Committed revision 1.
 
890
            $ bzr init ../feature
 
891
            Created a standalone tree (format: 2a)
 
892
            $ bzr push -v ../feature -Olog_format=line
 
893
            Added Revisions:
 
894
            1: jrandom@example.com ...we need some foo
 
895
            2>All changes applied successfully.
 
896
            2>Pushed up to revision 1.
 
897
            """)