33
from bzrlib.repofmt import knitrepo
34
from bzrlib.tests import (
33
from breezy.bzr import (
36
from breezy.bzr import knitrepo
37
from breezy.tests import (
40
from bzrlib.transport import memory
43
def load_tests(standard_tests, module, loader):
44
"""Multiply tests for the push command."""
45
result = loader.suiteClass()
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,
54
dict(_changes_type= '_uncommitted_changes')),
56
dict(_changes_type= '_pending_merges')),
58
dict(_changes_type= '_out_of_sync_trees')),
60
tests.multiply_tests(changes_tests, changes_scenarios, result)
61
# No parametrization for the remaining tests
62
result.addTests(remaining_tests)
43
from breezy.tests.matchers import ContainsNoVfsCalls
44
from breezy.transport import memory
47
load_tests = scenarios.load_tests_apply_scenarios
67
50
class TestPush(tests.TestCaseWithTransport):
76
59
['push', public_url],
77
60
working_dir='source')
62
def test_push_suggests_parent_alias(self):
63
"""Push suggests using :parent if there is a known parent branch."""
64
tree_a = self.make_branch_and_tree('a')
65
tree_a.commit('this is a commit')
66
tree_b = self.make_branch_and_tree('b')
68
# If there is no parent location set, :parent isn't mentioned.
69
out = self.run_bzr('push', working_dir='a', retcode=3)
71
('', 'brz: ERROR: No push location known or specified.\n'))
73
# If there is a parent location set, the error suggests :parent.
74
tree_a.branch.set_parent(tree_b.branch.base)
75
out = self.run_bzr('push', working_dir='a', retcode=3)
77
('', 'brz: ERROR: No push location known or specified. '
78
'To push to the parent branch '
79
'(at %s), use \'brz push :parent\'.\n' %
80
urlutils.unescape_for_display(tree_b.branch.base, 'utf-8')))
79
82
def test_push_remember(self):
80
83
"""Push changes from one branch to another and test push location."""
81
84
transport = self.get_transport()
100
103
# test push for failure without push location set
101
104
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'))
105
self.assertEqual(out,
106
('', 'brz: ERROR: No push location known or specified.\n'))
105
108
# test not remembered if cannot actually push
106
109
self.run_bzr('push path/which/doesnt/exist',
107
110
working_dir='branch_a', retcode=3)
108
111
out = self.run_bzr('push', working_dir='branch_a', retcode=3)
110
('', 'bzr: ERROR: No push location known or specified.\n'),
113
('', 'brz: ERROR: No push location known or specified.\n'),
113
116
# test implicit --remember when no push location set, push fails
114
117
out = self.run_bzr('push ../branch_b',
115
118
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))
119
self.assertEqual(out,
120
('', 'brz: ERROR: These branches have diverged. '
121
'See "brz help diverged-branches" for more information.\n'))
122
# Refresh the branch as 'push' modified it
123
branch_a = branch_a.controldir.open_branch()
124
self.assertEqual(osutils.abspath(branch_a.get_push_location()),
125
osutils.abspath(branch_b.controldir.root_transport.base))
122
127
# test implicit --remember after resolving previous failure
123
128
uncommit.uncommit(branch=branch_b, tree=tree_b)
124
129
transport.delete('branch_b/c')
125
130
out, err = self.run_bzr('push', working_dir='branch_a')
131
# Refresh the branch as 'push' modified it
132
branch_a = branch_a.controldir.open_branch()
126
133
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
134
self.assertEqual(err,
135
'Using saved push location: %s\n'
131
136
'All changes applied successfully.\n'
132
'Pushed up to revision 2.\n')
137
'Pushed up to revision 2.\n'
138
% urlutils.local_path_from_url(path))
133
139
self.assertEqual(path,
134
branch_b.bzrdir.root_transport.base)
140
branch_b.controldir.root_transport.base)
135
141
# test explicit --remember
136
142
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)
143
# Refresh the branch as 'push' modified it
144
branch_a = branch_a.controldir.open_branch()
145
self.assertEqual(branch_a.get_push_location(),
146
branch_c.controldir.root_transport.base)
140
148
def test_push_without_tree(self):
141
# bzr push from a branch that does not have a checkout should work.
149
# brz push from a branch that does not have a checkout should work.
142
150
b = self.make_branch('.')
143
151
out, err = self.run_bzr('push pushed-location')
144
152
self.assertEqual('', out)
146
154
b2 = branch.Branch.open('pushed-location')
147
155
self.assertEndsWith(b2.base, 'pushed-location/')
157
def test_push_no_tree(self):
158
# brz push --no-tree of a branch with working trees
159
b = self.make_branch_and_tree('push-from')
160
self.build_tree(['push-from/file'])
163
out, err = self.run_bzr('push --no-tree -d push-from push-to')
164
self.assertEqual('', out)
165
self.assertEqual('Created new branch.\n', err)
166
self.assertPathDoesNotExist('push-to/file')
149
168
def test_push_new_branch_revision_count(self):
150
# bzr push of a branch with revisions to a new location
169
# brz push of a branch with revisions to a new location
151
170
# should print the number of revisions equal to the length of the
153
172
t = self.make_branch_and_tree('tree')
158
177
self.assertEqual('', out)
159
178
self.assertEqual('Created new branch.\n', err)
180
def test_push_quiet(self):
181
# test that using -q makes output quiet
182
t = self.make_branch_and_tree('tree')
183
self.build_tree(['tree/file'])
186
self.run_bzr('push -d tree pushed-to')
187
# Refresh the branch as 'push' modified it and get the push location
188
push_loc = t.branch.controldir.open_branch().get_push_location()
189
out, err = self.run_bzr('push', working_dir="tree")
190
self.assertEqual('Using saved push location: %s\n'
191
'No new revisions or tags to push.\n' %
192
urlutils.local_path_from_url(push_loc), err)
193
out, err = self.run_bzr('push -q', working_dir="tree")
194
self.assertEqual('', out)
195
self.assertEqual('', err)
161
197
def test_push_only_pushes_history(self):
162
198
# Knit branches should only push the history for the current revision.
163
199
format = bzrdir.BzrDirMetaFormat1()
166
202
shared_repo.set_make_working_trees(True)
168
204
def make_shared_tree(path):
169
shared_repo.bzrdir.root_transport.mkdir(path)
170
shared_repo.bzrdir.create_branch_convenience('repo/' + path)
205
shared_repo.controldir.root_transport.mkdir(path)
206
controldir.ControlDir.create_branch_convenience('repo/' + path)
171
207
return workingtree.WorkingTree.open('repo/' + path)
172
208
tree_a = make_shared_tree('a')
173
209
self.build_tree(['repo/a/file'])
174
210
tree_a.add('file')
175
tree_a.commit('commit a-1', rev_id='a-1')
211
tree_a.commit('commit a-1', rev_id=b'a-1')
176
212
f = open('repo/a/file', 'ab')
177
f.write('more stuff\n')
213
f.write(b'more stuff\n')
179
tree_a.commit('commit a-2', rev_id='a-2')
215
tree_a.commit('commit a-2', rev_id=b'a-2')
181
217
tree_b = make_shared_tree('b')
182
218
self.build_tree(['repo/b/file'])
183
219
tree_b.add('file')
184
tree_b.commit('commit b-1', rev_id='b-1')
220
tree_b.commit('commit b-1', rev_id=b'b-1')
186
self.assertTrue(shared_repo.has_revision('a-1'))
187
self.assertTrue(shared_repo.has_revision('a-2'))
188
self.assertTrue(shared_repo.has_revision('b-1'))
222
self.assertTrue(shared_repo.has_revision(b'a-1'))
223
self.assertTrue(shared_repo.has_revision(b'a-2'))
224
self.assertTrue(shared_repo.has_revision(b'b-1'))
190
226
# Now that we have a repository with shared files, make sure
191
227
# that things aren't copied out by a 'push'
192
228
self.run_bzr('push ../../push-b', working_dir='repo/b')
193
229
pushed_tree = workingtree.WorkingTree.open('push-b')
194
230
pushed_repo = pushed_tree.branch.repository
195
self.assertFalse(pushed_repo.has_revision('a-1'))
196
self.assertFalse(pushed_repo.has_revision('a-2'))
197
self.assertTrue(pushed_repo.has_revision('b-1'))
231
self.assertFalse(pushed_repo.has_revision(b'a-1'))
232
self.assertFalse(pushed_repo.has_revision(b'a-2'))
233
self.assertTrue(pushed_repo.has_revision(b'b-1'))
199
235
def test_push_funky_id(self):
200
236
t = self.make_branch_and_tree('tree')
201
237
self.build_tree(['tree/filename'])
202
t.add('filename', 'funky-chars<>%&;"\'')
238
t.add('filename', b'funky-chars<>%&;"\'')
203
239
t.commit('commit filename')
204
240
self.run_bzr('push -d tree new-tree')
206
242
def test_push_dash_d(self):
207
243
t = self.make_branch_and_tree('from')
208
244
t.commit(allow_pointless=True,
209
message='first commit')
245
message='first commit')
210
246
self.run_bzr('push -d from to-one')
211
self.failUnlessExists('to-one')
247
self.assertPathExists('to-one')
212
248
self.run_bzr('push -d %s %s'
213
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
214
self.failUnlessExists('to-two')
249
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
250
self.assertPathExists('to-two')
252
def test_push_repository_no_branch_doesnt_fetch_all_revs(self):
253
# See https://bugs.launchpad.net/bzr/+bug/465517
254
target_repo = self.make_repository('target')
255
source = self.make_branch_builder('source')
256
source.start_series()
257
source.build_snapshot(None, [
258
('add', ('', b'root-id', 'directory', None))],
260
source.build_snapshot([b'A'], [], revision_id=b'B')
261
source.build_snapshot([b'A'], [], revision_id=b'C')
262
source.finish_series()
263
self.run_bzr('push target -d source')
264
self.addCleanup(target_repo.lock_read().unlock)
265
# We should have pushed 'C', but not 'B', since it isn't in the
267
self.assertEqual([(b'A',), (b'C',)], sorted(
268
target_repo.revisions.keys()))
216
270
def test_push_smart_non_stacked_streaming_acceptance(self):
217
271
self.setup_smart_server_with_call_log()
225
279
# become necessary for this use case. Please do not adjust this number
226
280
# upwards without agreement from bzr's network support maintainers.
227
281
self.assertLength(9, self.hpss_calls)
282
self.assertLength(1, self.hpss_connections)
283
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
229
285
def test_push_smart_stacked_streaming_acceptance(self):
230
286
self.setup_smart_server_with_call_log()
231
287
parent = self.make_branch_and_tree('parent', format='1.9')
232
288
parent.commit(message='first commit')
233
local = parent.bzrdir.sprout('local').open_workingtree()
289
local = parent.controldir.sprout('local').open_workingtree()
234
290
local.commit(message='local commit')
235
291
self.reset_smart_call_log()
236
292
self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
237
self.get_url('public')], working_dir='local')
293
self.get_url('public')], working_dir='local')
238
294
# This figure represent the amount of work to perform this use case. It
239
295
# is entirely ok to reduce this number if a test fails due to rpc_count
240
296
# being too low. If rpc_count increases, more network roundtrips have
241
297
# become necessary for this use case. Please do not adjust this number
242
298
# upwards without agreement from bzr's network support maintainers.
243
self.assertLength(14, self.hpss_calls)
299
self.assertLength(15, self.hpss_calls)
300
self.assertLength(1, self.hpss_connections)
301
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
244
302
remote = branch.Branch.open('public')
245
303
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
302
364
def create_simple_tree(self):
303
365
tree = self.make_branch_and_tree('tree')
304
366
self.build_tree(['tree/a'])
305
tree.add(['a'], ['a-id'])
306
tree.commit('one', rev_id='r1')
367
tree.add(['a'], [b'a-id'])
368
tree.commit('one', rev_id=b'r1')
309
371
def test_push_create_prefix(self):
310
"""'bzr push --create-prefix' will create leading directories."""
372
"""'brz push --create-prefix' will create leading directories."""
311
373
tree = self.create_simple_tree()
313
375
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
317
379
working_dir='tree')
318
380
new_tree = workingtree.WorkingTree.open('new/tree')
319
381
self.assertEqual(tree.last_revision(), new_tree.last_revision())
320
self.failUnlessExists('new/tree/a')
382
self.assertPathExists('new/tree/a')
322
384
def test_push_use_existing(self):
323
"""'bzr push --use-existing-dir' can push into an existing dir.
385
"""'brz push --use-existing-dir' can push into an existing dir.
325
By default, 'bzr push' will not use an existing, non-versioned dir.
387
By default, 'brz push' will not use an existing, non-versioned dir.
327
389
tree = self.create_simple_tree()
328
390
self.build_tree(['target/'])
330
392
self.run_bzr_error(['Target directory ../target already exists',
331
393
'Supply --use-existing-dir',
333
395
'push ../target', working_dir='tree')
335
397
self.run_bzr('push --use-existing-dir ../target',
375
437
# TODO: jam 20070109 Maybe it would be better to create the repository
376
438
# if at this point
377
439
tree = self.create_simple_tree()
378
a_bzrdir = self.make_bzrdir('dir')
440
a_controldir = self.make_controldir('dir')
380
442
self.run_bzr_error(['At ../dir you have a valid .bzr control'],
384
446
def test_push_with_revisionspec(self):
385
447
"""We should be able to push a revision older than the tip."""
386
448
tree_from = self.make_branch_and_tree('from')
387
tree_from.commit("One.", rev_id="from-1")
388
tree_from.commit("Two.", rev_id="from-2")
449
tree_from.commit("One.", rev_id=b"from-1")
450
tree_from.commit("Two.", rev_id=b"from-2")
390
452
self.run_bzr('push -r1 ../to', working_dir='from')
392
454
tree_to = workingtree.WorkingTree.open('to')
393
455
repo_to = tree_to.branch.repository
394
self.assertTrue(repo_to.has_revision('from-1'))
395
self.assertFalse(repo_to.has_revision('from-2'))
396
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
456
self.assertTrue(repo_to.has_revision(b'from-1'))
457
self.assertFalse(repo_to.has_revision(b'from-2'))
458
self.assertEqual(tree_to.branch.last_revision_info()[1], b'from-1')
460
tree_to.changes_from(tree_to.basis_tree()).has_changed())
398
462
self.run_bzr_error(
399
['bzr: ERROR: bzr push --revision '
463
['brz: ERROR: brz push --revision '
400
464
'takes exactly one revision identifier\n'],
401
465
'push -r0..2 ../to', working_dir='from')
403
467
def create_trunk_and_feature_branch(self):
404
468
# We have a mainline
405
469
trunk_tree = self.make_branch_and_tree('target',
407
471
trunk_tree.commit('mainline')
408
472
# and a branch from it
409
473
branch_tree = self.make_branch_and_tree('branch',
411
475
branch_tree.pull(trunk_tree.branch)
412
476
branch_tree.branch.set_parent(trunk_tree.branch.base)
413
477
# with some work on it
427
491
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
428
492
# we publish branch_tree with a reference to the mainline.
429
493
out, err = self.run_bzr(['push', '--stacked-on', trunk_tree.branch.base,
430
self.get_url('published')], working_dir='branch')
494
self.get_url('published')], working_dir='branch')
431
495
self.assertEqual('', out)
432
496
self.assertEqual('Created new stacked branch referring to %s.\n' %
433
trunk_tree.branch.base, err)
497
trunk_tree.branch.base, err)
434
498
self.assertPublished(branch_tree.last_revision(),
435
trunk_tree.branch.base)
499
trunk_tree.branch.base)
437
501
def test_push_new_branch_stacked_uses_parent_when_no_public_url(self):
438
502
"""When the parent has no public url the parent is used as-is."""
440
504
# now we do a stacked push, which should determine the public location
442
506
out, err = self.run_bzr(['push', '--stacked',
443
self.get_url('published')], working_dir='branch')
507
self.get_url('published')], working_dir='branch')
444
508
self.assertEqual('', out)
445
509
self.assertEqual('Created new stacked branch referring to %s.\n' %
446
trunk_tree.branch.base, err)
510
trunk_tree.branch.base, err)
447
511
self.assertPublished(branch_tree.last_revision(),
448
512
trunk_tree.branch.base)
455
519
trunk_public = self.make_branch('public_trunk', format='1.9')
456
520
trunk_public.pull(trunk_tree.branch)
457
521
trunk_public_url = self.get_readonly_url('public_trunk')
458
trunk_tree.branch.set_public_branch(trunk_public_url)
522
br = trunk_tree.branch
523
br.set_public_branch(trunk_public_url)
459
524
# now we do a stacked push, which should determine the public location
461
526
out, err = self.run_bzr(['push', '--stacked',
462
self.get_url('published')], working_dir='branch')
527
self.get_url('published')], working_dir='branch')
463
528
self.assertEqual('', out)
464
529
self.assertEqual('Created new stacked branch referring to %s.\n' %
465
trunk_public_url, err)
530
trunk_public_url, err)
466
531
self.assertPublished(branch_tree.last_revision(), trunk_public_url)
468
533
def test_push_new_branch_stacked_no_parent(self):
472
537
# cannot be determined.
473
538
out, err = self.run_bzr_error(
474
539
['Could not determine branch to refer to\\.'], ['push', '--stacked',
475
self.get_url('published')], working_dir='branch')
540
self.get_url('published')], working_dir='branch')
476
541
self.assertEqual('', out)
477
542
self.assertFalse(self.get_transport('published').has('.'))
479
544
def test_push_notifies_default_stacking(self):
480
545
self.make_branch('stack_on', format='1.6')
481
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
546
self.make_controldir('.').get_config().set_default_stack_on('stack_on')
482
547
self.make_branch('from', format='1.6')
483
548
out, err = self.run_bzr('push -d from to')
484
549
self.assertContainsRe(err,
495
560
def test_push_does_not_change_format_with_default_if_target_cannot(self):
496
561
self.make_branch('stack_on', format='pack-0.92')
497
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
562
self.make_controldir('.').get_config().set_default_stack_on('stack_on')
498
563
self.make_branch('from', format='pack-0.92')
499
564
out, err = self.run_bzr('push -d from to')
500
565
b = branch.Branch.open('to')
501
self.assertRaises(errors.UnstackableBranchFormat, b.get_stacked_on_url)
566
self.assertRaises(branch.UnstackableBranchFormat, b.get_stacked_on_url)
503
568
def test_push_doesnt_create_broken_branch(self):
504
569
"""Pushing a new standalone branch works even when there's a default
511
576
self.make_repository('repo', shared=True, format='1.6')
512
577
builder = self.make_branch_builder('repo/local', format='pack-0.92')
513
578
builder.start_series()
514
builder.build_snapshot('rev-1', None, [
515
('add', ('', 'root-id', 'directory', '')),
516
('add', ('filename', 'f-id', 'file', 'content\n'))])
517
builder.build_snapshot('rev-2', ['rev-1'], [])
518
builder.build_snapshot('rev-3', ['rev-2'],
519
[('modify', ('f-id', 'new-content\n'))])
579
builder.build_snapshot(None, [
580
('add', ('', b'root-id', 'directory', '')),
581
('add', ('filename', b'f-id', 'file', b'content\n'))],
582
revision_id=b'rev-1')
583
builder.build_snapshot([b'rev-1'], [], revision_id=b'rev-2')
584
builder.build_snapshot([b'rev-2'],
585
[('modify', ('filename', b'new-content\n'))],
586
revision_id=b'rev-3')
520
587
builder.finish_series()
521
588
branch = builder.get_branch()
522
589
# Push rev-1 to "trunk", so that we can stack on it.
523
590
self.run_bzr('push -d repo/local trunk -r 1')
524
591
# Set a default stacking policy so that new branches will automatically
525
592
# stack on trunk.
526
self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
593
self.make_controldir('.').get_config().set_default_stack_on('trunk')
527
594
# Push rev-2 to a new branch "remote". It will be stacked on "trunk".
528
595
out, err = self.run_bzr('push -d repo/local remote -r 2')
529
596
self.assertContainsRe(
548
615
def test_push_from_subdir(self):
549
616
t = self.make_branch_and_tree('tree')
550
617
self.build_tree(['tree/dir/', 'tree/dir/file'])
551
t.add('dir', 'dir/file')
618
t.add(['dir', 'dir/file'])
553
620
out, err = self.run_bzr('push ../../pushloc', working_dir='tree/dir')
554
621
self.assertEqual('', out)
555
622
self.assertEqual('Created new branch.\n', err)
624
def test_overwrite_tags(self):
625
"""--overwrite-tags only overwrites tags, not revisions."""
626
from_tree = self.make_branch_and_tree('from')
627
from_tree.branch.tags.set_tag("mytag", b"somerevid")
628
to_tree = self.make_branch_and_tree('to')
629
to_tree.branch.tags.set_tag("mytag", b"anotherrevid")
630
revid1 = to_tree.commit('my commit')
631
out = self.run_bzr(['push', '-d', 'from', 'to'])
632
self.assertEqual(out,
633
('Conflicting tags:\n mytag\n', 'No new revisions to push.\n'))
634
out = self.run_bzr(['push', '-d', 'from', '--overwrite-tags', 'to'])
635
self.assertEqual(out, ('', '1 tag updated.\n'))
636
self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
638
self.assertEqual(to_tree.branch.last_revision(), revid1)
558
641
class RedirectingMemoryTransport(memory.MemoryTransport):
646
729
def make_local_branch_and_tree(self):
647
730
self.tree = self.make_branch_and_tree('local')
648
self.build_tree_contents([('local/file', 'initial')])
731
self.build_tree_contents([('local/file', b'initial')])
649
732
self.tree.add('file')
650
self.tree.commit('adding file', rev_id='added')
651
self.build_tree_contents([('local/file', 'modified')])
652
self.tree.commit('modify file', rev_id='modified')
733
self.tree.commit('adding file', rev_id=b'added')
734
self.build_tree_contents([('local/file', b'modified')])
735
self.tree.commit('modify file', rev_id=b'modified')
654
737
def set_config_push_strict(self, value):
655
# set config var (any of bazaar.conf, locations.conf, branch.conf
657
conf = self.tree.branch.get_config()
658
conf.set_user_option('push_strict', value)
738
br = branch.Branch.open('local')
739
br.get_config_stack().set('push_strict', value)
660
741
_default_command = ['push', '../to']
661
742
_default_wd = 'local'
662
743
_default_errors = ['Working tree ".*/local/" has uncommitted '
663
'changes \(See bzr status\)\.',]
744
'changes \\(See brz status\\)\\.', ]
664
745
_default_additional_error = 'Use --no-strict to force the push.\n'
665
746
_default_additional_warning = 'Uncommitted changes will not be pushed.'
668
748
def assertPushFails(self, args):
669
749
out, err = self.run_bzr_error(self._default_errors,
670
750
self._default_command + args,
732
822
def _uncommitted_changes(self):
733
823
self.make_local_branch_and_tree()
734
824
# Make a change without committing it
735
self.build_tree_contents([('local/file', 'in progress')])
825
self.build_tree_contents([('local/file', b'in progress')])
737
827
def _pending_merges(self):
738
828
self.make_local_branch_and_tree()
739
829
# Create 'other' branch containing a new file
740
other_bzrdir = self.tree.bzrdir.sprout('other')
830
other_bzrdir = self.tree.controldir.sprout('other')
741
831
other_tree = other_bzrdir.open_workingtree()
742
self.build_tree_contents([('other/other-file', 'other')])
832
self.build_tree_contents([('other/other-file', b'other')])
743
833
other_tree.add('other-file')
744
other_tree.commit('other commit', rev_id='other')
834
other_tree.commit('other commit', rev_id=b'other')
745
835
# Merge and revert, leaving a pending merge
746
836
self.tree.merge_from_branch(other_tree.branch)
747
837
self.tree.revert(filenames=['other-file'], backups=False)
750
840
self.make_local_branch_and_tree()
751
841
self.run_bzr(['checkout', '--lightweight', 'local', 'checkout'])
752
842
# Make a change and commit it
753
self.build_tree_contents([('local/file', 'modified in local')])
754
self.tree.commit('modify file', rev_id='modified-in-local')
843
self.build_tree_contents([('local/file', b'modified in local')])
844
self.tree.commit('modify file', rev_id=b'modified-in-local')
755
845
# Exercise commands from the checkout directory
756
846
self._default_wd = 'checkout'
757
847
self._default_errors = ["Working tree is out of date, please run"
848
" 'brz update'\\.", ]
760
850
def test_push_default(self):
761
851
self.assertPushSucceeds([], with_warning=True)
763
853
def test_push_with_revision(self):
764
self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push='added')
854
self.assertPushSucceeds(['-r', 'revid:added'], revid_to_push=b'added')
766
856
def test_push_no_strict(self):
767
857
self.assertPushSucceeds(['--no-strict'])
797
887
def make_dummy_builder(self, relpath):
798
888
builder = self.make_branch_builder(
799
889
relpath, format=test_foreign.DummyForeignVcsDirFormat())
800
builder.build_snapshot('revid', None,
801
[('add', ('', 'TREE_ROOT', 'directory', None)),
802
('add', ('foo', 'fooid', 'file', 'bar'))])
890
builder.build_snapshot(None,
891
[('add', ('', b'TREE_ROOT', 'directory', None)),
892
('add', ('foo', b'fooid', 'file', b'bar'))],
893
revision_id=b'revid')
805
896
def test_no_roundtripping(self):
806
897
target_branch = self.make_dummy_builder('dp').get_branch()
807
898
source_tree = self.make_branch_and_tree("dc")
808
899
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"
811
" push to dummy. You may want to use dpush instead.\n")
900
self.assertEqual("", output)
903
"brz: ERROR: It is not possible to losslessly"
904
" push to dummy. You may want to use --lossy.\n")
907
class TestPushOutput(script.TestCaseWithTransportAndScript):
909
def test_push_log_format(self):
912
Created a standalone tree (format: 2a)
917
$ brz commit -m 'we need some foo'
918
2>Committing to:...trunk/
920
2>Committed revision 1.
921
$ brz init ../feature
922
Created a standalone tree (format: 2a)
923
$ brz push -v ../feature -Olog_format=line
925
1: jrandom@example.com ...we need some foo
926
2>All changes applied successfully.
927
2>Pushed up to revision 1.
930
def test_push_with_revspec(self):
933
Shared repository with trees (format: 2a)
937
Created a repository tree (format: 2a)
938
Using shared repository...
940
$ brz commit -m 'first rev' --unchanged
941
2>Committing to:...trunk/
942
2>Committed revision 1.
946
$ brz commit -m 'we need some foo'
947
2>Committing to:...trunk/
949
2>Committed revision 2.
950
$ brz push -r 1 ../other
951
2>Created new branch.
952
$ brz st ../other # checking that file is not created (#484516)