~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2011-12-08 09:24:06 UTC
  • mto: This revision was merged to the branch mainline in revision 6351.
  • Revision ID: v.ladeuil+lp@free.fr-20111208092406-ueqyyoftzwk22bq4
Open 2.5b5 for bug fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012 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
33
33
    )
34
34
from bzrlib.repofmt import knitrepo
35
35
from bzrlib.tests import (
 
36
    blackbox,
36
37
    http_server,
37
38
    scenarios,
38
39
    script,
39
40
    test_foreign,
 
41
    test_server,
40
42
    )
41
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
42
43
from bzrlib.transport import memory
43
44
 
44
45
 
57
58
                           ['push', public_url],
58
59
                           working_dir='source')
59
60
 
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
 
 
80
61
    def test_push_remember(self):
81
62
        """Push changes from one branch to another and test push location."""
82
63
        transport = self.get_transport()
117
98
        self.assertEquals(out,
118
99
                ('','bzr: ERROR: These branches have diverged.  '
119
100
                 '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
101
        self.assertEquals(osutils.abspath(branch_a.get_push_location()),
123
102
                          osutils.abspath(branch_b.bzrdir.root_transport.base))
124
103
 
126
105
        uncommit.uncommit(branch=branch_b, tree=tree_b)
127
106
        transport.delete('branch_b/c')
128
107
        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
108
        path = branch_a.get_push_location()
132
109
        self.assertEqual(err,
133
110
                         'Using saved push location: %s\n'
138
115
                         branch_b.bzrdir.root_transport.base)
139
116
        # test explicit --remember
140
117
        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
118
        self.assertEquals(branch_a.get_push_location(),
144
119
                          branch_c.bzrdir.root_transport.base)
145
120
 
182
157
        t.add('file')
183
158
        t.commit('commit 1')
184
159
        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()
 
160
        path = t.branch.get_push_location()
187
161
        out, err = self.run_bzr('push', working_dir="tree")
188
162
        self.assertEqual('Using saved push location: %s\n'
189
163
                         'No new revisions or tags to push.\n' %
190
 
                         urlutils.local_path_from_url(push_loc), err)
 
164
                         urlutils.local_path_from_url(path), err)
191
165
        out, err = self.run_bzr('push -q', working_dir="tree")
192
166
        self.assertEqual('', out)
193
167
        self.assertEqual('', err)
275
249
        # become necessary for this use case. Please do not adjust this number
276
250
        # upwards without agreement from bzr's network support maintainers.
277
251
        self.assertLength(9, self.hpss_calls)
278
 
        self.assertLength(1, self.hpss_connections)
279
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
280
252
 
281
253
    def test_push_smart_stacked_streaming_acceptance(self):
282
254
        self.setup_smart_server_with_call_log()
292
264
        # being too low. If rpc_count increases, more network roundtrips have
293
265
        # become necessary for this use case. Please do not adjust this number
294
266
        # upwards without agreement from bzr's network support maintainers.
295
 
        self.assertLength(15, self.hpss_calls)
296
 
        self.assertLength(1, self.hpss_connections)
297
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
 
267
        self.assertLength(13, self.hpss_calls)
298
268
        remote = branch.Branch.open('public')
299
269
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
300
270
 
311
281
        # become necessary for this use case. Please do not adjust this number
312
282
        # upwards without agreement from bzr's network support maintainers.
313
283
        self.assertLength(11, self.hpss_calls)
314
 
        self.assertLength(1, self.hpss_connections)
315
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
316
284
 
317
285
    def test_push_smart_incremental_acceptance(self):
318
286
        self.setup_smart_server_with_call_log()
329
297
        # become necessary for this use case. Please do not adjust this number
330
298
        # upwards without agreement from bzr's network support maintainers.
331
299
        self.assertLength(11, self.hpss_calls)
332
 
        self.assertLength(1, self.hpss_connections)
333
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
334
300
 
335
301
    def test_push_smart_with_default_stacking_url_path_segment(self):
336
302
        # If the default stacked-on location is a path element then branches
513
479
        trunk_public = self.make_branch('public_trunk', format='1.9')
514
480
        trunk_public.pull(trunk_tree.branch)
515
481
        trunk_public_url = self.get_readonly_url('public_trunk')
516
 
        br = trunk_tree.branch
517
 
        br.set_public_branch(trunk_public_url)
 
482
        trunk_tree.branch.set_public_branch(trunk_public_url)
518
483
        # now we do a stacked push, which should determine the public location
519
484
        # for us.
520
485
        out, err = self.run_bzr(['push', '--stacked',
711
676
        self.tree.commit('modify file', rev_id='modified')
712
677
 
713
678
    def set_config_push_strict(self, value):
714
 
        br = branch.Branch.open('local')
715
 
        br.get_config_stack().set('push_strict', value)
 
679
        # set config var (any of bazaar.conf, locations.conf, branch.conf
 
680
        # should do)
 
681
        conf = self.tree.branch.get_config_stack()
 
682
        conf.set('push_strict', value)
716
683
 
717
684
    _default_command = ['push', '../to']
718
685
    _default_wd = 'local'