/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2017-06-10 01:35:53 UTC
  • mto: (6670.4.8 move-bzr)
  • mto: This revision was merged to the branch mainline in revision 6681.
  • Revision ID: jelmer@jelmer.uk-20170610013553-560y7mn3su4pp763
Fix remaining tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2012, 2016 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
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
 
"""Black-box tests for bzr push."""
 
18
"""Black-box tests for brz push."""
19
19
 
20
20
import re
21
21
 
22
 
from bzrlib import (
 
22
from breezy import (
23
23
    branch,
24
24
    bzrdir,
 
25
    controldir,
25
26
    errors,
26
27
    osutils,
27
28
    tests,
30
31
    urlutils,
31
32
    workingtree
32
33
    )
33
 
from bzrlib.repofmt import knitrepo
34
 
from bzrlib.tests import (
35
 
    blackbox,
 
34
from breezy.repofmt import knitrepo
 
35
from breezy.tests import (
36
36
    http_server,
 
37
    scenarios,
 
38
    script,
37
39
    test_foreign,
38
 
    test_server,
39
40
    )
40
 
from bzrlib.transport import memory
41
 
 
42
 
 
43
 
def load_tests(standard_tests, module, loader):
44
 
    """Multiply tests for the push command."""
45
 
    result = loader.suiteClass()
46
 
 
47
 
    # one for each king of change
48
 
    changes_tests, remaining_tests = tests.split_suite_by_condition(
49
 
        standard_tests, tests.condition_isinstance((
50
 
                TestPushStrictWithChanges,
51
 
                )))
52
 
    changes_scenarios = [
53
 
        ('uncommitted',
54
 
         dict(_changes_type= '_uncommitted_changes')),
55
 
        ('pending-merges',
56
 
         dict(_changes_type= '_pending_merges')),
57
 
        ('out-of-sync-trees',
58
 
         dict(_changes_type= '_out_of_sync_trees')),
59
 
        ]
60
 
    tests.multiply_tests(changes_tests, changes_scenarios, result)
61
 
    # No parametrization for the remaining tests
62
 
    result.addTests(remaining_tests)
63
 
 
64
 
    return result
 
41
from breezy.tests.matchers import ContainsNoVfsCalls
 
42
from breezy.transport import memory
 
43
 
 
44
 
 
45
load_tests = scenarios.load_tests_apply_scenarios
65
46
 
66
47
 
67
48
class TestPush(tests.TestCaseWithTransport):
76
57
                           ['push', public_url],
77
58
                           working_dir='source')
78
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.assertEqual(out,
 
69
                ('','brz: 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.assertEqual(out,
 
75
            ('','brz: ERROR: No push location known or specified. '
 
76
                'To push to the parent branch '
 
77
                '(at %s), use \'brz push :parent\'.\n' %
 
78
                urlutils.unescape_for_display(tree_b.branch.base, 'utf-8')))
 
79
 
79
80
    def test_push_remember(self):
80
81
        """Push changes from one branch to another and test push location."""
81
82
        transport = self.get_transport()
84
85
        self.build_tree(['branch_a/a'])
85
86
        tree_a.add('a')
86
87
        tree_a.commit('commit a')
87
 
        tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()
 
88
        tree_b = branch_a.controldir.sprout('branch_b').open_workingtree()
88
89
        branch_b = tree_b.branch
89
 
        tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()
 
90
        tree_c = branch_a.controldir.sprout('branch_c').open_workingtree()
90
91
        branch_c = tree_c.branch
91
92
        self.build_tree(['branch_a/b'])
92
93
        tree_a.add('b')
99
100
 
100
101
        # test push for failure without push location set
101
102
        out = self.run_bzr('push', working_dir='branch_a', retcode=3)
102
 
        self.assertEquals(out,
103
 
                ('','bzr: ERROR: No push location known or specified.\n'))
 
103
        self.assertEqual(out,
 
104
                ('','brz: ERROR: No push location known or specified.\n'))
104
105
 
105
106
        # test not remembered if cannot actually push
106
107
        self.run_bzr('push path/which/doesnt/exist',
107
108
                     working_dir='branch_a', retcode=3)
108
109
        out = self.run_bzr('push', working_dir='branch_a', retcode=3)
109
 
        self.assertEquals(
110
 
                ('', 'bzr: ERROR: No push location known or specified.\n'),
 
110
        self.assertEqual(
 
111
                ('', 'brz: ERROR: No push location known or specified.\n'),
111
112
                out)
112
113
 
113
114
        # test implicit --remember when no push location set, push fails
114
115
        out = self.run_bzr('push ../branch_b',
115
116
                           working_dir='branch_a', retcode=3)
116
 
        self.assertEquals(out,
117
 
                ('','bzr: ERROR: These branches have diverged.  '
118
 
                 'See "bzr help diverged-branches" for more information.\n'))
119
 
        self.assertEquals(osutils.abspath(branch_a.get_push_location()),
120
 
                          osutils.abspath(branch_b.bzrdir.root_transport.base))
 
117
        self.assertEqual(out,
 
118
                ('','brz: ERROR: These branches have diverged.  '
 
119
                 'See "brz help diverged-branches" for more information.\n'))
 
120
        # Refresh the branch as 'push' modified it
 
121
        branch_a = branch_a.controldir.open_branch()
 
122
        self.assertEqual(osutils.abspath(branch_a.get_push_location()),
 
123
                          osutils.abspath(branch_b.controldir.root_transport.base))
121
124
 
122
125
        # test implicit --remember after resolving previous failure
123
126
        uncommit.uncommit(branch=branch_b, tree=tree_b)
124
127
        transport.delete('branch_b/c')
125
128
        out, err = self.run_bzr('push', working_dir='branch_a')
 
129
        # Refresh the branch as 'push' modified it
 
130
        branch_a = branch_a.controldir.open_branch()
126
131
        path = branch_a.get_push_location()
127
 
        self.assertEquals(out,
128
 
                          'Using saved push location: %s\n'
129
 
                          % urlutils.local_path_from_url(path))
130
132
        self.assertEqual(err,
 
133
                         'Using saved push location: %s\n'
131
134
                         'All changes applied successfully.\n'
132
 
                         'Pushed up to revision 2.\n')
 
135
                         'Pushed up to revision 2.\n'
 
136
                         % urlutils.local_path_from_url(path))
133
137
        self.assertEqual(path,
134
 
                         branch_b.bzrdir.root_transport.base)
 
138
                         branch_b.controldir.root_transport.base)
135
139
        # test explicit --remember
136
140
        self.run_bzr('push ../branch_c --remember', working_dir='branch_a')
137
 
        self.assertEquals(branch_a.get_push_location(),
138
 
                          branch_c.bzrdir.root_transport.base)
 
141
        # Refresh the branch as 'push' modified it
 
142
        branch_a = branch_a.controldir.open_branch()
 
143
        self.assertEqual(branch_a.get_push_location(),
 
144
                          branch_c.controldir.root_transport.base)
139
145
 
140
146
    def test_push_without_tree(self):
141
 
        # 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.
142
148
        b = self.make_branch('.')
143
149
        out, err = self.run_bzr('push pushed-location')
144
150
        self.assertEqual('', out)
146
152
        b2 = branch.Branch.open('pushed-location')
147
153
        self.assertEndsWith(b2.base, 'pushed-location/')
148
154
 
 
155
    def test_push_no_tree(self):
 
156
        # brz push --no-tree of a branch with working trees
 
157
        b = self.make_branch_and_tree('push-from')
 
158
        self.build_tree(['push-from/file'])
 
159
        b.add('file')
 
160
        b.commit('commit 1')
 
161
        out, err = self.run_bzr('push --no-tree -d push-from push-to')
 
162
        self.assertEqual('', out)
 
163
        self.assertEqual('Created new branch.\n', err)
 
164
        self.assertPathDoesNotExist('push-to/file')
 
165
 
149
166
    def test_push_new_branch_revision_count(self):
150
 
        # bzr push of a branch with revisions to a new location
 
167
        # brz push of a branch with revisions to a new location
151
168
        # should print the number of revisions equal to the length of the
152
169
        # local branch.
153
170
        t = self.make_branch_and_tree('tree')
158
175
        self.assertEqual('', out)
159
176
        self.assertEqual('Created new branch.\n', err)
160
177
 
 
178
    def test_push_quiet(self):
 
179
        # test that using -q makes output quiet
 
180
        t = self.make_branch_and_tree('tree')
 
181
        self.build_tree(['tree/file'])
 
182
        t.add('file')
 
183
        t.commit('commit 1')
 
184
        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.controldir.open_branch().get_push_location()
 
187
        out, err = self.run_bzr('push', working_dir="tree")
 
188
        self.assertEqual('Using saved push location: %s\n'
 
189
                         'No new revisions or tags to push.\n' %
 
190
                         urlutils.local_path_from_url(push_loc), err)
 
191
        out, err = self.run_bzr('push -q', working_dir="tree")
 
192
        self.assertEqual('', out)
 
193
        self.assertEqual('', err)
 
194
 
161
195
    def test_push_only_pushes_history(self):
162
196
        # Knit branches should only push the history for the current revision.
163
197
        format = bzrdir.BzrDirMetaFormat1()
166
200
        shared_repo.set_make_working_trees(True)
167
201
 
168
202
        def make_shared_tree(path):
169
 
            shared_repo.bzrdir.root_transport.mkdir(path)
170
 
            shared_repo.bzrdir.create_branch_convenience('repo/' + path)
 
203
            shared_repo.controldir.root_transport.mkdir(path)
 
204
            controldir.ControlDir.create_branch_convenience('repo/' + path)
171
205
            return workingtree.WorkingTree.open('repo/' + path)
172
206
        tree_a = make_shared_tree('a')
173
207
        self.build_tree(['repo/a/file'])
208
242
        t.commit(allow_pointless=True,
209
243
                message='first commit')
210
244
        self.run_bzr('push -d from to-one')
211
 
        self.failUnlessExists('to-one')
 
245
        self.assertPathExists('to-one')
212
246
        self.run_bzr('push -d %s %s'
213
247
            % tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
214
 
        self.failUnlessExists('to-two')
 
248
        self.assertPathExists('to-two')
 
249
 
 
250
    def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
 
251
        # See https://bugs.launchpad.net/bzr/+bug/465517
 
252
        target_repo = self.make_repository('target')
 
253
        source = self.make_branch_builder('source')
 
254
        source.start_series()
 
255
        source.build_snapshot('A', None, [
 
256
            ('add', ('', 'root-id', 'directory', None))])
 
257
        source.build_snapshot('B', ['A'], [])
 
258
        source.build_snapshot('C', ['A'], [])
 
259
        source.finish_series()
 
260
        self.run_bzr('push target -d source')
 
261
        self.addCleanup(target_repo.lock_read().unlock)
 
262
        # We should have pushed 'C', but not 'B', since it isn't in the
 
263
        # ancestry
 
264
        self.assertEqual([('A',), ('C',)], sorted(target_repo.revisions.keys()))
215
265
 
216
266
    def test_push_smart_non_stacked_streaming_acceptance(self):
217
267
        self.setup_smart_server_with_call_log()
225
275
        # become necessary for this use case. Please do not adjust this number
226
276
        # upwards without agreement from bzr's network support maintainers.
227
277
        self.assertLength(9, self.hpss_calls)
 
278
        self.assertLength(1, self.hpss_connections)
 
279
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
228
280
 
229
281
    def test_push_smart_stacked_streaming_acceptance(self):
230
282
        self.setup_smart_server_with_call_log()
231
283
        parent = self.make_branch_and_tree('parent', format='1.9')
232
284
        parent.commit(message='first commit')
233
 
        local = parent.bzrdir.sprout('local').open_workingtree()
 
285
        local = parent.controldir.sprout('local').open_workingtree()
234
286
        local.commit(message='local commit')
235
287
        self.reset_smart_call_log()
236
288
        self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
240
292
        # being too low. If rpc_count increases, more network roundtrips have
241
293
        # become necessary for this use case. Please do not adjust this number
242
294
        # upwards without agreement from bzr's network support maintainers.
243
 
        self.assertLength(14, self.hpss_calls)
 
295
        self.assertLength(15, self.hpss_calls)
 
296
        self.assertLength(1, self.hpss_connections)
 
297
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
244
298
        remote = branch.Branch.open('public')
245
299
        self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
246
300
 
257
311
        # become necessary for this use case. Please do not adjust this number
258
312
        # upwards without agreement from bzr's network support maintainers.
259
313
        self.assertLength(11, self.hpss_calls)
 
314
        self.assertLength(1, self.hpss_connections)
 
315
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
260
316
 
261
317
    def test_push_smart_incremental_acceptance(self):
262
318
        self.setup_smart_server_with_call_log()
273
329
        # become necessary for this use case. Please do not adjust this number
274
330
        # upwards without agreement from bzr's network support maintainers.
275
331
        self.assertLength(11, self.hpss_calls)
 
332
        self.assertLength(1, self.hpss_connections)
 
333
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
276
334
 
277
335
    def test_push_smart_with_default_stacking_url_path_segment(self):
278
336
        # If the default stacked-on location is a path element then branches
280
338
        # stacked_on_url is that exact path segment. Added to nail bug 385132.
281
339
        self.setup_smart_server_with_call_log()
282
340
        self.make_branch('stack-on', format='1.9')
283
 
        self.make_bzrdir('.').get_config().set_default_stack_on(
 
341
        self.make_controldir('.').get_config().set_default_stack_on(
284
342
            '/stack-on')
285
343
        self.make_branch('from', format='1.9')
286
344
        out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')])
293
351
        # stacked_on_url is a relative path. Added to nail bug 385132.
294
352
        self.setup_smart_server_with_call_log()
295
353
        self.make_branch('stack-on', format='1.9')
296
 
        self.make_bzrdir('.').get_config().set_default_stack_on('stack-on')
 
354
        self.make_controldir('.').get_config().set_default_stack_on('stack-on')
297
355
        self.make_branch('from', format='1.9')
298
356
        out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')])
299
357
        b = branch.Branch.open(self.get_url('to'))
307
365
        return tree
308
366
 
309
367
    def test_push_create_prefix(self):
310
 
        """'bzr push --create-prefix' will create leading directories."""
 
368
        """'brz push --create-prefix' will create leading directories."""
311
369
        tree = self.create_simple_tree()
312
370
 
313
371
        self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
317
375
                     working_dir='tree')
318
376
        new_tree = workingtree.WorkingTree.open('new/tree')
319
377
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
320
 
        self.failUnlessExists('new/tree/a')
 
378
        self.assertPathExists('new/tree/a')
321
379
 
322
380
    def test_push_use_existing(self):
323
 
        """'bzr push --use-existing-dir' can push into an existing dir.
 
381
        """'brz push --use-existing-dir' can push into an existing dir.
324
382
 
325
 
        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.
326
384
        """
327
385
        tree = self.create_simple_tree()
328
386
        self.build_tree(['target/'])
338
396
        new_tree = workingtree.WorkingTree.open('target')
339
397
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
340
398
        # The push should have created target/a
341
 
        self.failUnlessExists('target/a')
 
399
        self.assertPathExists('target/a')
342
400
 
343
401
    def test_push_use_existing_into_empty_bzrdir(self):
344
 
        """'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
345
403
        fails.
346
404
        """
347
405
        tree = self.create_simple_tree()
352
410
            'push ../target --use-existing-dir', working_dir='tree')
353
411
 
354
412
    def test_push_onto_repo(self):
355
 
        """We should be able to 'bzr push' into an existing bzrdir."""
 
413
        """We should be able to 'brz push' into an existing bzrdir."""
356
414
        tree = self.create_simple_tree()
357
415
        repo = self.make_repository('repo', shared=True)
358
416
 
375
433
        # TODO: jam 20070109 Maybe it would be better to create the repository
376
434
        #       if at this point
377
435
        tree = self.create_simple_tree()
378
 
        a_bzrdir = self.make_bzrdir('dir')
 
436
        a_controldir = self.make_controldir('dir')
379
437
 
380
438
        self.run_bzr_error(['At ../dir you have a valid .bzr control'],
381
439
                'push ../dir',
394
452
        self.assertTrue(repo_to.has_revision('from-1'))
395
453
        self.assertFalse(repo_to.has_revision('from-2'))
396
454
        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())
397
457
 
398
458
        self.run_bzr_error(
399
 
            ['bzr: ERROR: bzr push --revision '
 
459
            ['brz: ERROR: brz push --revision '
400
460
             'takes exactly one revision identifier\n'],
401
461
            'push -r0..2 ../to', working_dir='from')
402
462
 
455
515
        trunk_public = self.make_branch('public_trunk', format='1.9')
456
516
        trunk_public.pull(trunk_tree.branch)
457
517
        trunk_public_url = self.get_readonly_url('public_trunk')
458
 
        trunk_tree.branch.set_public_branch(trunk_public_url)
 
518
        br = trunk_tree.branch
 
519
        br.set_public_branch(trunk_public_url)
459
520
        # now we do a stacked push, which should determine the public location
460
521
        # for us.
461
522
        out, err = self.run_bzr(['push', '--stacked',
478
539
 
479
540
    def test_push_notifies_default_stacking(self):
480
541
        self.make_branch('stack_on', format='1.6')
481
 
        self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
 
542
        self.make_controldir('.').get_config().set_default_stack_on('stack_on')
482
543
        self.make_branch('from', format='1.6')
483
544
        out, err = self.run_bzr('push -d from to')
484
545
        self.assertContainsRe(err,
486
547
 
487
548
    def test_push_stacks_with_default_stacking_if_target_is_stackable(self):
488
549
        self.make_branch('stack_on', format='1.6')
489
 
        self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
 
550
        self.make_controldir('.').get_config().set_default_stack_on('stack_on')
490
551
        self.make_branch('from', format='pack-0.92')
491
552
        out, err = self.run_bzr('push -d from to')
492
553
        b = branch.Branch.open('to')
494
555
 
495
556
    def test_push_does_not_change_format_with_default_if_target_cannot(self):
496
557
        self.make_branch('stack_on', format='pack-0.92')
497
 
        self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
 
558
        self.make_controldir('.').get_config().set_default_stack_on('stack_on')
498
559
        self.make_branch('from', format='pack-0.92')
499
560
        out, err = self.run_bzr('push -d from to')
500
561
        b = branch.Branch.open('to')
523
584
        self.run_bzr('push -d repo/local trunk -r 1')
524
585
        # Set a default stacking policy so that new branches will automatically
525
586
        # stack on trunk.
526
 
        self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
 
587
        self.make_controldir('.').get_config().set_default_stack_on('trunk')
527
588
        # Push rev-2 to a new branch "remote".  It will be stacked on "trunk".
528
589
        out, err = self.run_bzr('push -d repo/local remote -r 2')
529
590
        self.assertContainsRe(
554
615
        self.assertEqual('', out)
555
616
        self.assertEqual('Created new branch.\n', err)
556
617
 
 
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
 
557
634
 
558
635
class RedirectingMemoryTransport(memory.MemoryTransport):
559
636
 
606
683
class TestPushRedirect(tests.TestCaseWithTransport):
607
684
 
608
685
    def setUp(self):
609
 
        tests.TestCaseWithTransport.setUp(self)
 
686
        super(TestPushRedirect, self).setUp()
610
687
        self.memory_server = RedirectingMemoryServer()
611
688
        self.start_server(self.memory_server)
612
689
        # Make the branch and tree that we'll be pushing.
652
729
        self.tree.commit('modify file', rev_id='modified')
653
730
 
654
731
    def set_config_push_strict(self, value):
655
 
        # set config var (any of bazaar.conf, locations.conf, branch.conf
656
 
        # should do)
657
 
        conf = self.tree.branch.get_config()
658
 
        conf.set_user_option('push_strict', value)
 
732
        br = branch.Branch.open('local')
 
733
        br.get_config_stack().set('push_strict', value)
659
734
 
660
735
    _default_command = ['push', '../to']
661
736
    _default_wd = 'local'
662
737
    _default_errors = ['Working tree ".*/local/" has uncommitted '
663
 
                       'changes \(See bzr status\)\.',]
 
738
                       'changes \(See brz status\)\.',]
664
739
    _default_additional_error = 'Use --no-strict to force the push.\n'
665
740
    _default_additional_warning = 'Uncommitted changes will not be pushed.'
666
741
 
718
793
        self.assertPushSucceeds([])
719
794
 
720
795
 
 
796
strict_push_change_scenarios = [
 
797
    ('uncommitted',
 
798
        dict(_changes_type= '_uncommitted_changes')),
 
799
    ('pending-merges',
 
800
        dict(_changes_type= '_pending_merges')),
 
801
    ('out-of-sync-trees',
 
802
        dict(_changes_type= '_out_of_sync_trees')),
 
803
    ]
 
804
 
 
805
 
721
806
class TestPushStrictWithChanges(tests.TestCaseWithTransport,
722
807
                                TestPushStrictMixin):
723
808
 
 
809
    scenarios = strict_push_change_scenarios 
724
810
    _changes_type = None # Set by load_tests
725
811
 
726
812
    def setUp(self):
737
823
    def _pending_merges(self):
738
824
        self.make_local_branch_and_tree()
739
825
        # Create 'other' branch containing a new file
740
 
        other_bzrdir = self.tree.bzrdir.sprout('other')
 
826
        other_bzrdir = self.tree.controldir.sprout('other')
741
827
        other_tree = other_bzrdir.open_workingtree()
742
828
        self.build_tree_contents([('other/other-file', 'other')])
743
829
        other_tree.add('other-file')
755
841
        # Exercise commands from the checkout directory
756
842
        self._default_wd = 'checkout'
757
843
        self._default_errors = ["Working tree is out of date, please run"
758
 
                                " 'bzr update'\.",]
 
844
                                " 'brz update'\.",]
759
845
 
760
846
    def test_push_default(self):
761
847
        self.assertPushSucceeds([], with_warning=True)
788
874
        self.assertPushSucceeds([])
789
875
 
790
876
 
791
 
class TestPushForeign(blackbox.ExternalBase):
 
877
class TestPushForeign(tests.TestCaseWithTransport):
792
878
 
793
879
    def setUp(self):
794
880
        super(TestPushForeign, self).setUp()
806
892
        target_branch = self.make_dummy_builder('dp').get_branch()
807
893
        source_tree = self.make_branch_and_tree("dc")
808
894
        output, error = self.run_bzr("push -d dc dp", retcode=3)
809
 
        self.assertEquals("", output)
810
 
        self.assertEquals(error, "bzr: ERROR: It is not possible to losslessly"
 
895
        self.assertEqual("", output)
 
896
        self.assertEqual(error, "brz: ERROR: It is not possible to losslessly"
811
897
            " push to dummy. You may want to use dpush instead.\n")
 
898
 
 
899
 
 
900
class TestPushOutput(script.TestCaseWithTransportAndScript):
 
901
 
 
902
    def test_push_log_format(self):
 
903
        self.run_script("""
 
904
            $ brz init trunk
 
905
            Created a standalone tree (format: 2a)
 
906
            $ cd trunk
 
907
            $ echo foo > file
 
908
            $ brz add
 
909
            adding file
 
910
            $ brz commit -m 'we need some foo'
 
911
            2>Committing to:...trunk/
 
912
            2>added file
 
913
            2>Committed revision 1.
 
914
            $ brz init ../feature
 
915
            Created a standalone tree (format: 2a)
 
916
            $ brz push -v ../feature -Olog_format=line
 
917
            Added Revisions:
 
918
            1: jrandom@example.com ...we need some foo
 
919
            2>All changes applied successfully.
 
920
            2>Pushed up to revision 1.
 
921
            """)
 
922
 
 
923
    def test_push_with_revspec(self):
 
924
        self.run_script("""
 
925
            $ brz init-repo .
 
926
            Shared repository with trees (format: 2a)
 
927
            Location:
 
928
              shared repository: .
 
929
            $ brz init trunk
 
930
            Created a repository tree (format: 2a)
 
931
            Using shared repository...
 
932
            $ cd trunk
 
933
            $ brz commit -m 'first rev' --unchanged
 
934
            2>Committing to:...trunk/
 
935
            2>Committed revision 1.
 
936
            $ echo foo > file
 
937
            $ brz add
 
938
            adding file
 
939
            $ brz commit -m 'we need some foo'
 
940
            2>Committing to:...trunk/
 
941
            2>added file
 
942
            2>Committed revision 2.
 
943
            $ brz push -r 1 ../other
 
944
            2>Created new branch.
 
945
            $ brz st ../other # checking that file is not created (#484516)
 
946
            """)