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):
72
55
self.transport_readonly_server = http_server.HttpServer
73
56
self.make_branch('source')
74
57
public_url = self.get_readonly_url('target')
75
self.run_bzr_error(['http does not support mkdir'],
58
self.run_bzr_error([b'http does not support mkdir'],
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
(b'', b'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
(b'', b'brz: ERROR: No push location known or specified. '
78
b'To push to the parent branch '
79
b'(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
self.assertEqual('', out)
145
self.assertEqual('Created new branch.\n', err)
152
self.assertEqual(b'', out)
153
self.assertEqual(b'Created new branch.\n', err)
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(b'', out)
165
self.assertEqual(b'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')
156
175
t.commit('commit 1')
157
176
out, err = self.run_bzr('push -d tree pushed-to')
158
self.assertEqual('', out)
159
self.assertEqual('Created new branch.\n', err)
177
self.assertEqual(b'', out)
178
self.assertEqual(b'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(b'', out)
195
self.assertEqual(b'', err)
161
197
def test_push_only_pushes_history(self):
162
198
# Knit branches should only push the history for the current revision.
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')
208
244
t.commit(allow_pointless=True,
209
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
249
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
214
self.failUnlessExists('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(target_repo.revisions.keys()))
216
269
def test_push_smart_non_stacked_streaming_acceptance(self):
217
270
self.setup_smart_server_with_call_log()
225
278
# become necessary for this use case. Please do not adjust this number
226
279
# upwards without agreement from bzr's network support maintainers.
227
280
self.assertLength(9, self.hpss_calls)
281
self.assertLength(1, self.hpss_connections)
282
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
229
284
def test_push_smart_stacked_streaming_acceptance(self):
230
285
self.setup_smart_server_with_call_log()
231
286
parent = self.make_branch_and_tree('parent', format='1.9')
232
287
parent.commit(message='first commit')
233
local = parent.bzrdir.sprout('local').open_workingtree()
288
local = parent.controldir.sprout('local').open_workingtree()
234
289
local.commit(message='local commit')
235
290
self.reset_smart_call_log()
236
291
self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
302
363
def create_simple_tree(self):
303
364
tree = self.make_branch_and_tree('tree')
304
365
self.build_tree(['tree/a'])
305
tree.add(['a'], ['a-id'])
306
tree.commit('one', rev_id='r1')
366
tree.add(['a'], [b'a-id'])
367
tree.commit('one', rev_id=b'r1')
309
370
def test_push_create_prefix(self):
310
"""'bzr push --create-prefix' will create leading directories."""
371
"""'brz push --create-prefix' will create leading directories."""
311
372
tree = self.create_simple_tree()
313
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
374
self.run_bzr_error([b'Parent directory of ../new/tree does not exist'],
314
375
'push ../new/tree',
315
376
working_dir='tree')
316
377
self.run_bzr('push ../new/tree --create-prefix',
317
378
working_dir='tree')
318
379
new_tree = workingtree.WorkingTree.open('new/tree')
319
380
self.assertEqual(tree.last_revision(), new_tree.last_revision())
320
self.failUnlessExists('new/tree/a')
381
self.assertPathExists('new/tree/a')
322
383
def test_push_use_existing(self):
323
"""'bzr push --use-existing-dir' can push into an existing dir.
384
"""'brz push --use-existing-dir' can push into an existing dir.
325
By default, 'bzr push' will not use an existing, non-versioned dir.
386
By default, 'brz push' will not use an existing, non-versioned dir.
327
388
tree = self.create_simple_tree()
328
389
self.build_tree(['target/'])
330
self.run_bzr_error(['Target directory ../target already exists',
331
'Supply --use-existing-dir',
391
self.run_bzr_error([b'Target directory ../target already exists',
392
b'Supply --use-existing-dir',
333
394
'push ../target', working_dir='tree')
375
436
# TODO: jam 20070109 Maybe it would be better to create the repository
376
437
# if at this point
377
438
tree = self.create_simple_tree()
378
a_bzrdir = self.make_bzrdir('dir')
439
a_controldir = self.make_controldir('dir')
380
self.run_bzr_error(['At ../dir you have a valid .bzr control'],
441
self.run_bzr_error([b'At ../dir you have a valid .bzr control'],
382
443
working_dir='tree')
384
445
def test_push_with_revisionspec(self):
385
446
"""We should be able to push a revision older than the tip."""
386
447
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")
448
tree_from.commit("One.", rev_id=b"from-1")
449
tree_from.commit("Two.", rev_id=b"from-2")
390
451
self.run_bzr('push -r1 ../to', working_dir='from')
392
453
tree_to = workingtree.WorkingTree.open('to')
393
454
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')
455
self.assertTrue(repo_to.has_revision(b'from-1'))
456
self.assertFalse(repo_to.has_revision(b'from-2'))
457
self.assertEqual(tree_to.branch.last_revision_info()[1], b'from-1')
459
tree_to.changes_from(tree_to.basis_tree()).has_changed())
398
461
self.run_bzr_error(
399
['bzr: ERROR: bzr push --revision '
462
['brz: ERROR: brz push --revision '
400
463
'takes exactly one revision identifier\n'],
401
464
'push -r0..2 ../to', working_dir='from')
455
518
trunk_public = self.make_branch('public_trunk', format='1.9')
456
519
trunk_public.pull(trunk_tree.branch)
457
520
trunk_public_url = self.get_readonly_url('public_trunk')
458
trunk_tree.branch.set_public_branch(trunk_public_url)
521
br = trunk_tree.branch
522
br.set_public_branch(trunk_public_url)
459
523
# now we do a stacked push, which should determine the public location
461
525
out, err = self.run_bzr(['push', '--stacked',
462
526
self.get_url('published')], working_dir='branch')
463
self.assertEqual('', out)
464
self.assertEqual('Created new stacked branch referring to %s.\n' %
527
self.assertEqual(b'', out)
528
self.assertEqual(b'Created new stacked branch referring to %s.\n' %
465
529
trunk_public_url, err)
466
530
self.assertPublished(branch_tree.last_revision(), trunk_public_url)
473
537
out, err = self.run_bzr_error(
474
538
['Could not determine branch to refer to\\.'], ['push', '--stacked',
475
539
self.get_url('published')], working_dir='branch')
476
self.assertEqual('', out)
540
self.assertEqual(b'', out)
477
541
self.assertFalse(self.get_transport('published').has('.'))
479
543
def test_push_notifies_default_stacking(self):
480
544
self.make_branch('stack_on', format='1.6')
481
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
545
self.make_controldir('.').get_config().set_default_stack_on('stack_on')
482
546
self.make_branch('from', format='1.6')
483
547
out, err = self.run_bzr('push -d from to')
484
548
self.assertContainsRe(err,
485
'Using default stacking branch stack_on at .*')
549
b'Using default stacking branch stack_on at .*')
487
551
def test_push_stacks_with_default_stacking_if_target_is_stackable(self):
488
552
self.make_branch('stack_on', format='1.6')
489
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
553
self.make_controldir('.').get_config().set_default_stack_on('stack_on')
490
554
self.make_branch('from', format='pack-0.92')
491
555
out, err = self.run_bzr('push -d from to')
492
556
b = branch.Branch.open('to')
511
575
self.make_repository('repo', shared=True, format='1.6')
512
576
builder = self.make_branch_builder('repo/local', format='pack-0.92')
513
577
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'))])
578
builder.build_snapshot(None, [
579
('add', ('', b'root-id', 'directory', '')),
580
('add', ('filename', b'f-id', 'file', 'content\n'))],
581
revision_id=b'rev-1')
582
builder.build_snapshot([b'rev-1'], [], revision_id=b'rev-2')
583
builder.build_snapshot([b'rev-2'],
584
[('modify', ('filename', b'new-content\n'))],
585
revision_id=b'rev-3')
520
586
builder.finish_series()
521
587
branch = builder.get_branch()
522
588
# Push rev-1 to "trunk", so that we can stack on it.
523
589
self.run_bzr('push -d repo/local trunk -r 1')
524
590
# Set a default stacking policy so that new branches will automatically
525
591
# stack on trunk.
526
self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
592
self.make_controldir('.').get_config().set_default_stack_on('trunk')
527
593
# Push rev-2 to a new branch "remote". It will be stacked on "trunk".
528
594
out, err = self.run_bzr('push -d repo/local remote -r 2')
529
595
self.assertContainsRe(
530
err, 'Using default stacking branch trunk at .*')
596
err, b'Using default stacking branch trunk at .*')
531
597
# Push rev-3 onto "remote". If "remote" not stacked and is missing the
532
598
# fulltext record for f-id @ rev-1, then this will fail.
533
599
out, err = self.run_bzr('push -d repo/local remote -r 3')
537
603
tree.commit('rev1')
538
604
out, err = self.run_bzr('push -v -d source target')
539
605
# initial push contains log
540
self.assertContainsRe(out, 'rev1')
606
self.assertContainsRe(out, b'rev1')
541
607
tree.commit('rev2')
542
608
out, err = self.run_bzr('push -v -d source target')
543
609
# subsequent push contains log
544
self.assertContainsRe(out, 'rev2')
610
self.assertContainsRe(out, b'rev2')
545
611
# subsequent log is accurate
546
self.assertNotContainsRe(out, 'rev1')
612
self.assertNotContainsRe(out, b'rev1')
548
614
def test_push_from_subdir(self):
549
615
t = self.make_branch_and_tree('tree')
550
616
self.build_tree(['tree/dir/', 'tree/dir/file'])
551
t.add('dir', 'dir/file')
617
t.add(['dir', 'dir/file'])
553
619
out, err = self.run_bzr('push ../../pushloc', working_dir='tree/dir')
554
self.assertEqual('', out)
555
self.assertEqual('Created new branch.\n', err)
620
self.assertEqual(b'', out)
621
self.assertEqual(b'Created new branch.\n', err)
623
def test_overwrite_tags(self):
624
"""--overwrite-tags only overwrites tags, not revisions."""
625
from_tree = self.make_branch_and_tree('from')
626
from_tree.branch.tags.set_tag("mytag", "somerevid")
627
to_tree = self.make_branch_and_tree('to')
628
to_tree.branch.tags.set_tag("mytag", "anotherrevid")
629
revid1 = to_tree.commit('my commit')
630
out = self.run_bzr(['push', '-d', 'from', 'to'])
631
self.assertEqual(out,
632
('Conflicting tags:\n mytag\n', 'No new revisions to push.\n'))
633
out = self.run_bzr(['push', '-d', 'from', '--overwrite-tags', 'to'])
634
self.assertEqual(out, ('', '1 tag updated.\n'))
635
self.assertEqual(to_tree.branch.tags.lookup_tag('mytag'),
637
self.assertEqual(to_tree.branch.last_revision(), revid1)
558
640
class RedirectingMemoryTransport(memory.MemoryTransport):
638
720
['Too many redirections trying to make %s\\.\n'
639
721
% re.escape(destination_url)],
640
722
['push', '-d', 'tree', destination_url], retcode=3)
641
self.assertEqual('', out)
723
self.assertEqual(b'', out)
644
726
class TestPushStrictMixin(object):
646
728
def make_local_branch_and_tree(self):
647
729
self.tree = self.make_branch_and_tree('local')
648
self.build_tree_contents([('local/file', 'initial')])
730
self.build_tree_contents([('local/file', b'initial')])
649
731
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')
732
self.tree.commit('adding file', rev_id=b'added')
733
self.build_tree_contents([('local/file', b'modified')])
734
self.tree.commit('modify file', rev_id=b'modified')
654
736
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)
737
br = branch.Branch.open('local')
738
br.get_config_stack().set('push_strict', value)
660
740
_default_command = ['push', '../to']
661
741
_default_wd = 'local'
662
_default_errors = ['Working tree ".*/local/" has uncommitted '
663
'changes \(See bzr status\)\.',]
664
_default_additional_error = 'Use --no-strict to force the push.\n'
665
_default_additional_warning = 'Uncommitted changes will not be pushed.'
742
_default_errors = [b'Working tree ".*/local/" has uncommitted '
743
b'changes \\(See brz status\\)\\.',]
744
_default_additional_error = b'Use --no-strict to force the push.\n'
745
_default_additional_warning = b'Uncommitted changes will not be pushed.'
668
748
def assertPushFails(self, args):
732
823
def _uncommitted_changes(self):
733
824
self.make_local_branch_and_tree()
734
825
# Make a change without committing it
735
self.build_tree_contents([('local/file', 'in progress')])
826
self.build_tree_contents([('local/file', b'in progress')])
737
828
def _pending_merges(self):
738
829
self.make_local_branch_and_tree()
739
830
# Create 'other' branch containing a new file
740
other_bzrdir = self.tree.bzrdir.sprout('other')
831
other_bzrdir = self.tree.controldir.sprout('other')
741
832
other_tree = other_bzrdir.open_workingtree()
742
self.build_tree_contents([('other/other-file', 'other')])
833
self.build_tree_contents([('other/other-file', b'other')])
743
834
other_tree.add('other-file')
744
other_tree.commit('other commit', rev_id='other')
835
other_tree.commit('other commit', rev_id=b'other')
745
836
# Merge and revert, leaving a pending merge
746
837
self.tree.merge_from_branch(other_tree.branch)
747
838
self.tree.revert(filenames=['other-file'], backups=False)
750
841
self.make_local_branch_and_tree()
751
842
self.run_bzr(['checkout', '--lightweight', 'local', 'checkout'])
752
843
# 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')
844
self.build_tree_contents([('local/file', b'modified in local')])
845
self.tree.commit('modify file', rev_id=b'modified-in-local')
755
846
# Exercise commands from the checkout directory
756
847
self._default_wd = 'checkout'
757
848
self._default_errors = ["Working tree is out of date, please run"
760
851
def test_push_default(self):
761
852
self.assertPushSucceeds([], with_warning=True)
797
888
def make_dummy_builder(self, relpath):
798
889
builder = self.make_branch_builder(
799
890
relpath, format=test_foreign.DummyForeignVcsDirFormat())
800
builder.build_snapshot('revid', None,
801
[('add', ('', 'TREE_ROOT', 'directory', None)),
802
('add', ('foo', 'fooid', 'file', 'bar'))])
891
builder.build_snapshot(None,
892
[('add', ('', b'TREE_ROOT', 'directory', None)),
893
('add', ('foo', b'fooid', 'file', 'bar'))],
894
revision_id=b'revid')
805
897
def test_no_roundtripping(self):
806
898
target_branch = self.make_dummy_builder('dp').get_branch()
807
899
source_tree = self.make_branch_and_tree("dc")
808
900
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"
901
self.assertEqual("", output)
902
self.assertEqual(error, "brz: ERROR: It is not possible to losslessly"
811
903
" push to dummy. You may want to use dpush instead.\n")
906
class TestPushOutput(script.TestCaseWithTransportAndScript):
908
def test_push_log_format(self):
911
Created a standalone tree (format: 2a)
916
$ brz commit -m 'we need some foo'
917
2>Committing to:...trunk/
919
2>Committed revision 1.
920
$ brz init ../feature
921
Created a standalone tree (format: 2a)
922
$ brz push -v ../feature -Olog_format=line
924
1: jrandom@example.com ...we need some foo
925
2>All changes applied successfully.
926
2>Pushed up to revision 1.
929
def test_push_with_revspec(self):
932
Shared repository with trees (format: 2a)
936
Created a repository tree (format: 2a)
937
Using shared repository...
939
$ brz commit -m 'first rev' --unchanged
940
2>Committing to:...trunk/
941
2>Committed revision 1.
945
$ brz commit -m 'we need some foo'
946
2>Committing to:...trunk/
948
2>Committed revision 2.
949
$ brz push -r 1 ../other
950
2>Created new branch.
951
$ brz st ../other # checking that file is not created (#484516)