57
93
self.assertEqual(None, branch_b.get_push_location())
59
95
# test push for failure without push location set
61
out = self.runbzr('push', retcode=3)
96
out = self.run_bzr('push', working_dir='branch_a', retcode=3)
62
97
self.assertEquals(out,
63
98
('','bzr: ERROR: No push location known or specified.\n'))
65
100
# test not remembered if cannot actually push
66
self.run_bzr('push', '../path/which/doesnt/exist', retcode=3)
67
out = self.run_bzr('push', retcode=3)
101
self.run_bzr('push path/which/doesnt/exist',
102
working_dir='branch_a', retcode=3)
103
out = self.run_bzr('push', working_dir='branch_a', retcode=3)
68
104
self.assertEquals(
69
105
('', 'bzr: ERROR: No push location known or specified.\n'),
72
108
# test implicit --remember when no push location set, push fails
73
out = self.run_bzr('push', '../branch_b', retcode=3)
109
out = self.run_bzr('push ../branch_b',
110
working_dir='branch_a', retcode=3)
74
111
self.assertEquals(out,
75
112
('','bzr: ERROR: These branches have diverged. '
76
'Try using "merge" and then "push".\n'))
77
self.assertEquals(abspath(branch_a.get_push_location()),
78
abspath(branch_b.bzrdir.root_transport.base))
113
'See "bzr help diverged-branches" for more information.\n'))
114
self.assertEquals(osutils.abspath(branch_a.get_push_location()),
115
osutils.abspath(branch_b.bzrdir.root_transport.base))
80
117
# test implicit --remember after resolving previous failure
81
uncommit(branch=branch_b, tree=tree_b)
118
uncommit.uncommit(branch=branch_b, tree=tree_b)
82
119
transport.delete('branch_b/c')
83
out, err = self.run_bzr('push')
120
out, err = self.run_bzr('push', working_dir='branch_a')
84
121
path = branch_a.get_push_location()
85
122
self.assertEquals(out,
86
'Using saved location: %s\n'
87
'Pushed up to revision 2.\n'
88
% local_path_from_url(path))
123
'Using saved push location: %s\n'
124
% urlutils.local_path_from_url(path))
89
125
self.assertEqual(err,
90
'All changes applied successfully.\n')
126
'All changes applied successfully.\n'
127
'Pushed up to revision 2.\n')
91
128
self.assertEqual(path,
92
129
branch_b.bzrdir.root_transport.base)
93
130
# test explicit --remember
94
self.run_bzr('push', '../branch_c', '--remember')
131
self.run_bzr('push ../branch_c --remember', working_dir='branch_a')
95
132
self.assertEquals(branch_a.get_push_location(),
96
133
branch_c.bzrdir.root_transport.base)
98
135
def test_push_without_tree(self):
99
136
# bzr push from a branch that does not have a checkout should work.
137
self.thisFailsStrictLockCheck()
100
138
b = self.make_branch('.')
101
out, err = self.run_bzr('push', 'pushed-location')
139
out, err = self.run_bzr('push pushed-location')
102
140
self.assertEqual('', out)
103
141
self.assertEqual('Created new branch.\n', err)
104
b2 = Branch.open('pushed-location')
142
b2 = branch.Branch.open('pushed-location')
105
143
self.assertEndsWith(b2.base, 'pushed-location/')
107
145
def test_push_new_branch_revision_count(self):
108
# bzr push of a branch with revisions to a new location
109
# should print the number of revisions equal to the length of the
146
# bzr push of a branch with revisions to a new location
147
# should print the number of revisions equal to the length of the
149
self.thisFailsStrictLockCheck()
111
150
t = self.make_branch_and_tree('tree')
112
151
self.build_tree(['tree/file'])
114
153
t.commit('commit 1')
116
out, err = self.run_bzr('push', 'pushed-to')
154
out, err = self.run_bzr('push -d tree pushed-to')
118
155
self.assertEqual('', out)
119
156
self.assertEqual('Created new branch.\n', err)
121
158
def test_push_only_pushes_history(self):
122
159
# Knit branches should only push the history for the current revision.
123
format = BzrDirMetaFormat1()
124
format.repository_format = RepositoryFormatKnit1()
160
self.thisFailsStrictLockCheck()
161
format = bzrdir.BzrDirMetaFormat1()
162
format.repository_format = knitrepo.RepositoryFormatKnit1()
125
163
shared_repo = self.make_repository('repo', format=format, shared=True)
126
164
shared_repo.set_make_working_trees(True)
128
166
def make_shared_tree(path):
129
167
shared_repo.bzrdir.root_transport.mkdir(path)
130
168
shared_repo.bzrdir.create_branch_convenience('repo/' + path)
131
return WorkingTree.open('repo/' + path)
169
return workingtree.WorkingTree.open('repo/' + path)
132
170
tree_a = make_shared_tree('a')
133
171
self.build_tree(['repo/a/file'])
134
172
tree_a.add('file')
150
188
# Now that we have a repository with shared files, make sure
151
189
# that things aren't copied out by a 'push'
153
self.run_bzr('push', '../../push-b')
154
pushed_tree = WorkingTree.open('../../push-b')
190
self.run_bzr('push ../../push-b', working_dir='repo/b')
191
pushed_tree = workingtree.WorkingTree.open('push-b')
155
192
pushed_repo = pushed_tree.branch.repository
156
193
self.assertFalse(pushed_repo.has_revision('a-1'))
157
194
self.assertFalse(pushed_repo.has_revision('a-2'))
158
195
self.assertTrue(pushed_repo.has_revision('b-1'))
160
197
def test_push_funky_id(self):
198
self.thisFailsStrictLockCheck()
161
199
t = self.make_branch_and_tree('tree')
163
self.build_tree(['filename'])
200
self.build_tree(['tree/filename'])
164
201
t.add('filename', 'funky-chars<>%&;"\'')
165
202
t.commit('commit filename')
166
self.run_bzr('push', '../new-tree')
203
self.run_bzr('push -d tree new-tree')
168
205
def test_push_dash_d(self):
206
self.thisFailsStrictLockCheck()
169
207
t = self.make_branch_and_tree('from')
170
208
t.commit(allow_pointless=True,
171
209
message='first commit')
172
self.runbzr('push -d from to-one')
210
self.run_bzr('push -d from to-one')
173
211
self.failUnlessExists('to-one')
174
self.runbzr('push -d %s %s'
212
self.run_bzr('push -d %s %s'
175
213
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
176
214
self.failUnlessExists('to-two')
216
def test_push_smart_non_stacked_streaming_acceptance(self):
217
self.setup_smart_server_with_call_log()
218
t = self.make_branch_and_tree('from')
219
t.commit(allow_pointless=True, message='first commit')
220
self.reset_smart_call_log()
221
self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
222
# This figure represent the amount of work to perform this use case. It
223
# is entirely ok to reduce this number if a test fails due to rpc_count
224
# being too low. If rpc_count increases, more network roundtrips have
225
# become necessary for this use case. Please do not adjust this number
226
# upwards without agreement from bzr's network support maintainers.
227
self.assertLength(9, self.hpss_calls)
229
def test_push_smart_stacked_streaming_acceptance(self):
230
self.setup_smart_server_with_call_log()
231
parent = self.make_branch_and_tree('parent', format='1.9')
232
parent.commit(message='first commit')
233
local = parent.bzrdir.sprout('local').open_workingtree()
234
local.commit(message='local commit')
235
self.reset_smart_call_log()
236
self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
237
self.get_url('public')], working_dir='local')
238
# This figure represent the amount of work to perform this use case. It
239
# is entirely ok to reduce this number if a test fails due to rpc_count
240
# being too low. If rpc_count increases, more network roundtrips have
241
# become necessary for this use case. Please do not adjust this number
242
# upwards without agreement from bzr's network support maintainers.
243
self.assertLength(14, self.hpss_calls)
244
remote = branch.Branch.open('public')
245
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
247
def test_push_smart_tags_streaming_acceptance(self):
248
self.setup_smart_server_with_call_log()
249
t = self.make_branch_and_tree('from')
250
rev_id = t.commit(allow_pointless=True, message='first commit')
251
t.branch.tags.set_tag('new-tag', rev_id)
252
self.reset_smart_call_log()
253
self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
254
# This figure represent the amount of work to perform this use case. It
255
# is entirely ok to reduce this number if a test fails due to rpc_count
256
# being too low. If rpc_count increases, more network roundtrips have
257
# become necessary for this use case. Please do not adjust this number
258
# upwards without agreement from bzr's network support maintainers.
259
self.assertLength(11, self.hpss_calls)
261
def test_push_smart_with_default_stacking_url_path_segment(self):
262
# If the default stacked-on location is a path element then branches
263
# we push there over the smart server are stacked and their
264
# stacked_on_url is that exact path segment. Added to nail bug 385132.
265
self.setup_smart_server_with_call_log()
266
self.make_branch('stack-on', format='1.9')
267
self.make_bzrdir('.').get_config().set_default_stack_on(
269
self.make_branch('from', format='1.9')
270
out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')])
271
b = branch.Branch.open(self.get_url('to'))
272
self.assertEqual('/extra/stack-on', b.get_stacked_on_url())
274
def test_push_smart_with_default_stacking_relative_path(self):
275
# If the default stacked-on location is a relative path then branches
276
# we push there over the smart server are stacked and their
277
# stacked_on_url is a relative path. Added to nail bug 385132.
278
self.setup_smart_server_with_call_log()
279
self.make_branch('stack-on', format='1.9')
280
self.make_bzrdir('.').get_config().set_default_stack_on('stack-on')
281
self.make_branch('from', format='1.9')
282
out, err = self.run_bzr(['push', '-d', 'from', self.get_url('to')])
283
b = branch.Branch.open(self.get_url('to'))
284
self.assertEqual('../stack-on', b.get_stacked_on_url())
178
286
def create_simple_tree(self):
179
287
tree = self.make_branch_and_tree('tree')
180
288
self.build_tree(['tree/a'])
242
353
a_bzrdir = self.make_bzrdir('dir')
244
355
self.run_bzr_error(['At ../dir you have a valid .bzr control'],
246
357
working_dir='tree')
359
def test_push_with_revisionspec(self):
360
"""We should be able to push a revision older than the tip."""
361
self.thisFailsStrictLockCheck()
362
tree_from = self.make_branch_and_tree('from')
363
tree_from.commit("One.", rev_id="from-1")
364
tree_from.commit("Two.", rev_id="from-2")
366
self.run_bzr('push -r1 ../to', working_dir='from')
368
tree_to = workingtree.WorkingTree.open('to')
369
repo_to = tree_to.branch.repository
370
self.assertTrue(repo_to.has_revision('from-1'))
371
self.assertFalse(repo_to.has_revision('from-2'))
372
self.assertEqual(tree_to.branch.last_revision_info()[1], 'from-1')
375
['bzr: ERROR: bzr push --revision '
376
'takes exactly one revision identifier\n'],
377
'push -r0..2 ../to', working_dir='from')
379
def create_trunk_and_feature_branch(self):
381
trunk_tree = self.make_branch_and_tree('target',
383
trunk_tree.commit('mainline')
384
# and a branch from it
385
branch_tree = self.make_branch_and_tree('branch',
387
branch_tree.pull(trunk_tree.branch)
388
branch_tree.branch.set_parent(trunk_tree.branch.base)
389
# with some work on it
390
branch_tree.commit('moar work plz')
391
return trunk_tree, branch_tree
393
def assertPublished(self, branch_revid, stacked_on):
394
"""Assert that the branch 'published' has been published correctly."""
395
published_branch = branch.Branch.open('published')
396
# The published branch refers to the mainline
397
self.assertEqual(stacked_on, published_branch.get_stacked_on_url())
398
# and the branch's work was pushed
399
self.assertTrue(published_branch.repository.has_revision(branch_revid))
401
def test_push_new_branch_stacked_on(self):
402
"""Pushing a new branch with --stacked-on creates a stacked branch."""
403
self.thisFailsStrictLockCheck()
404
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
405
# we publish branch_tree with a reference to the mainline.
406
out, err = self.run_bzr(['push', '--stacked-on', trunk_tree.branch.base,
407
self.get_url('published')], working_dir='branch')
408
self.assertEqual('', out)
409
self.assertEqual('Created new stacked branch referring to %s.\n' %
410
trunk_tree.branch.base, err)
411
self.assertPublished(branch_tree.last_revision(),
412
trunk_tree.branch.base)
414
def test_push_new_branch_stacked_uses_parent_when_no_public_url(self):
415
"""When the parent has no public url the parent is used as-is."""
416
self.thisFailsStrictLockCheck()
417
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
418
# now we do a stacked push, which should determine the public location
420
out, err = self.run_bzr(['push', '--stacked',
421
self.get_url('published')], working_dir='branch')
422
self.assertEqual('', out)
423
self.assertEqual('Created new stacked branch referring to %s.\n' %
424
trunk_tree.branch.base, err)
425
self.assertPublished(branch_tree.last_revision(),
426
trunk_tree.branch.base)
428
def test_push_new_branch_stacked_uses_parent_public(self):
429
"""Pushing a new branch with --stacked creates a stacked branch."""
430
self.thisFailsStrictLockCheck()
431
trunk_tree, branch_tree = self.create_trunk_and_feature_branch()
432
# the trunk is published on a web server
433
self.transport_readonly_server = http_server.HttpServer
434
trunk_public = self.make_branch('public_trunk', format='1.9')
435
trunk_public.pull(trunk_tree.branch)
436
trunk_public_url = self.get_readonly_url('public_trunk')
437
trunk_tree.branch.set_public_branch(trunk_public_url)
438
# now we do a stacked push, which should determine the public location
440
out, err = self.run_bzr(['push', '--stacked',
441
self.get_url('published')], working_dir='branch')
442
self.assertEqual('', out)
443
self.assertEqual('Created new stacked branch referring to %s.\n' %
444
trunk_public_url, err)
445
self.assertPublished(branch_tree.last_revision(), trunk_public_url)
447
def test_push_new_branch_stacked_no_parent(self):
448
"""Pushing with --stacked and no parent branch errors."""
449
branch = self.make_branch_and_tree('branch', format='1.9')
450
# now we do a stacked push, which should fail as the place to refer too
451
# cannot be determined.
452
out, err = self.run_bzr_error(
453
['Could not determine branch to refer to\\.'], ['push', '--stacked',
454
self.get_url('published')], working_dir='branch')
455
self.assertEqual('', out)
456
self.assertFalse(self.get_transport('published').has('.'))
458
def test_push_notifies_default_stacking(self):
459
self.make_branch('stack_on', format='1.6')
460
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
461
self.make_branch('from', format='1.6')
462
out, err = self.run_bzr('push -d from to')
463
self.assertContainsRe(err,
464
'Using default stacking branch stack_on at .*')
466
def test_push_stacks_with_default_stacking_if_target_is_stackable(self):
467
self.make_branch('stack_on', format='1.6')
468
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
469
self.make_branch('from', format='pack-0.92')
470
out, err = self.run_bzr('push -d from to')
471
b = branch.Branch.open('to')
472
self.assertEqual('../stack_on', b.get_stacked_on_url())
474
def test_push_does_not_change_format_with_default_if_target_cannot(self):
475
self.make_branch('stack_on', format='pack-0.92')
476
self.make_bzrdir('.').get_config().set_default_stack_on('stack_on')
477
self.make_branch('from', format='pack-0.92')
478
out, err = self.run_bzr('push -d from to')
479
b = branch.Branch.open('to')
480
self.assertRaises(errors.UnstackableBranchFormat, b.get_stacked_on_url)
482
def test_push_doesnt_create_broken_branch(self):
483
"""Pushing a new standalone branch works even when there's a default
484
stacking policy at the destination.
486
The new branch will preserve the repo format (even if it isn't the
487
default for the branch), and will be stacked when the repo format
488
allows (which means that the branch format isn't necessarly preserved).
490
self.make_repository('repo', shared=True, format='1.6')
491
builder = self.make_branch_builder('repo/local', format='pack-0.92')
492
builder.start_series()
493
builder.build_snapshot('rev-1', None, [
494
('add', ('', 'root-id', 'directory', '')),
495
('add', ('filename', 'f-id', 'file', 'content\n'))])
496
builder.build_snapshot('rev-2', ['rev-1'], [])
497
builder.build_snapshot('rev-3', ['rev-2'],
498
[('modify', ('f-id', 'new-content\n'))])
499
builder.finish_series()
500
branch = builder.get_branch()
501
# Push rev-1 to "trunk", so that we can stack on it.
502
self.run_bzr('push -d repo/local trunk -r 1')
503
# Set a default stacking policy so that new branches will automatically
505
self.make_bzrdir('.').get_config().set_default_stack_on('trunk')
506
# Push rev-2 to a new branch "remote". It will be stacked on "trunk".
507
out, err = self.run_bzr('push -d repo/local remote -r 2')
508
self.assertContainsRe(
509
err, 'Using default stacking branch trunk at .*')
510
# Push rev-3 onto "remote". If "remote" not stacked and is missing the
511
# fulltext record for f-id @ rev-1, then this will fail.
512
out, err = self.run_bzr('push -d repo/local remote -r 3')
514
def test_push_verbose_shows_log(self):
515
self.thisFailsStrictLockCheck()
516
tree = self.make_branch_and_tree('source')
518
out, err = self.run_bzr('push -v -d source target')
519
# initial push contains log
520
self.assertContainsRe(out, 'rev1')
522
out, err = self.run_bzr('push -v -d source target')
523
# subsequent push contains log
524
self.assertContainsRe(out, 'rev2')
525
# subsequent log is accurate
526
self.assertNotContainsRe(out, 'rev1')
528
def test_push_from_subdir(self):
529
self.thisFailsStrictLockCheck()
530
t = self.make_branch_and_tree('tree')
531
self.build_tree(['tree/dir/', 'tree/dir/file'])
532
t.add('dir', 'dir/file')
534
out, err = self.run_bzr('push ../../pushloc', working_dir='tree/dir')
535
self.assertEqual('', out)
536
self.assertEqual('Created new branch.\n', err)
539
class RedirectingMemoryTransport(memory.MemoryTransport):
541
def mkdir(self, relpath, mode=None):
542
if self._cwd == '/source/':
543
raise errors.RedirectRequested(self.abspath(relpath),
544
self.abspath('../target'),
546
elif self._cwd == '/infinite-loop/':
547
raise errors.RedirectRequested(self.abspath(relpath),
548
self.abspath('../infinite-loop'),
551
return super(RedirectingMemoryTransport, self).mkdir(
554
def get(self, relpath):
555
if self.clone(relpath)._cwd == '/infinite-loop/':
556
raise errors.RedirectRequested(self.abspath(relpath),
557
self.abspath('../infinite-loop'),
560
return super(RedirectingMemoryTransport, self).get(relpath)
562
def _redirected_to(self, source, target):
563
# We do accept redirections
564
return transport.get_transport(target)
567
class RedirectingMemoryServer(memory.MemoryServer):
570
self._dirs = {'/': None}
573
self._scheme = 'redirecting-memory+%s:///' % id(self)
574
transport.register_transport(self._scheme, self._memory_factory)
576
def _memory_factory(self, url):
577
result = RedirectingMemoryTransport(url)
578
result._dirs = self._dirs
579
result._files = self._files
580
result._locks = self._locks
584
transport.unregister_transport(self._scheme, self._memory_factory)
587
class TestPushRedirect(tests.TestCaseWithTransport):
590
tests.TestCaseWithTransport.setUp(self)
591
self.memory_server = RedirectingMemoryServer()
592
self.memory_server.setUp()
593
self.addCleanup(self.memory_server.tearDown)
595
# Make the branch and tree that we'll be pushing.
596
t = self.make_branch_and_tree('tree')
597
self.build_tree(['tree/file'])
601
def test_push_redirects_on_mkdir(self):
602
"""If the push requires a mkdir, push respects redirect requests.
604
This is added primarily to handle lp:/ URI support, so that users can
605
push to new branches by specifying lp:/ URIs.
607
destination_url = self.memory_server.get_url() + 'source'
608
self.run_bzr(['push', '-d', 'tree', destination_url])
610
local_revision = branch.Branch.open('tree').last_revision()
611
remote_revision = branch.Branch.open(
612
self.memory_server.get_url() + 'target').last_revision()
613
self.assertEqual(remote_revision, local_revision)
615
def test_push_gracefully_handles_too_many_redirects(self):
616
"""Push fails gracefully if the mkdir generates a large number of
619
destination_url = self.memory_server.get_url() + 'infinite-loop'
620
out, err = self.run_bzr_error(
621
['Too many redirections trying to make %s\\.\n'
622
% re.escape(destination_url)],
623
['push', '-d', 'tree', destination_url], retcode=3)
624
self.assertEqual('', out)
627
class TestPushStrictMixin(object):
629
def make_local_branch_and_tree(self):
630
self.tree = self.make_branch_and_tree('local')
631
self.build_tree_contents([('local/file', 'initial')])
632
self.tree.add('file')
633
self.tree.commit('adding file', rev_id='added')
634
self.build_tree_contents([('local/file', 'modified')])
635
self.tree.commit('modify file', rev_id='modified')
637
def set_config_push_strict(self, value):
638
# set config var (any of bazaar.conf, locations.conf, branch.conf
640
conf = self.tree.branch.get_config()
641
conf.set_user_option('push_strict', value)
643
_default_command = ['push', '../to']
644
_default_wd = 'local'
645
_default_errors = ['Working tree ".*/local/" has uncommitted '
646
'changes \(See bzr status\)\.',]
647
_default_pushed_revid = 'modified'
649
def assertPushFails(self, args):
650
self.run_bzr_error(self._default_errors, self._default_command + args,
651
working_dir=self._default_wd, retcode=3)
653
def assertPushSucceeds(self, args, pushed_revid=None):
654
self.run_bzr(self._default_command + args,
655
working_dir=self._default_wd)
656
if pushed_revid is None:
657
pushed_revid = self._default_pushed_revid
658
tree_to = workingtree.WorkingTree.open('to')
659
repo_to = tree_to.branch.repository
660
self.assertTrue(repo_to.has_revision(pushed_revid))
661
self.assertEqual(tree_to.branch.last_revision_info()[1], pushed_revid)
665
class TestPushStrictWithoutChanges(tests.TestCaseWithTransport,
666
TestPushStrictMixin):
669
super(TestPushStrictWithoutChanges, self).setUp()
670
self.make_local_branch_and_tree()
672
def test_push_default(self):
673
self.thisFailsStrictLockCheck()
674
self.assertPushSucceeds([])
676
def test_push_strict(self):
677
self.thisFailsStrictLockCheck()
678
self.assertPushSucceeds(['--strict'])
680
def test_push_no_strict(self):
681
self.thisFailsStrictLockCheck()
682
self.assertPushSucceeds(['--no-strict'])
684
def test_push_config_var_strict(self):
685
self.thisFailsStrictLockCheck()
686
self.set_config_push_strict('true')
687
self.assertPushSucceeds([])
689
def test_push_config_var_no_strict(self):
690
self.thisFailsStrictLockCheck()
691
self.set_config_push_strict('false')
692
self.assertPushSucceeds([])
695
class TestPushStrictWithChanges(tests.TestCaseWithTransport,
696
TestPushStrictMixin):
698
_changes_type = None # Set by load_tests
701
super(TestPushStrictWithChanges, self).setUp()
702
getattr(self, self._changes_type)()
704
def _uncommitted_changes(self):
705
self.make_local_branch_and_tree()
706
# Make a change without committing it
707
self.build_tree_contents([('local/file', 'in progress')])
709
def _pending_merges(self):
710
self.make_local_branch_and_tree()
711
# Create 'other' branch containing a new file
712
other_bzrdir = self.tree.bzrdir.sprout('other')
713
other_tree = other_bzrdir.open_workingtree()
714
self.build_tree_contents([('other/other-file', 'other')])
715
other_tree.add('other-file')
716
other_tree.commit('other commit', rev_id='other')
717
# Merge and revert, leaving a pending merge
718
self.tree.merge_from_branch(other_tree.branch)
719
self.tree.revert(filenames=['other-file'], backups=False)
721
def _out_of_sync_trees(self):
722
self.make_local_branch_and_tree()
723
self.run_bzr(['checkout', '--lightweight', 'local', 'checkout'])
724
# Make a change and commit it
725
self.build_tree_contents([('local/file', 'modified in local')])
726
self.tree.commit('modify file', rev_id='modified-in-local')
727
# Exercise commands from the checkout directory
728
self._default_wd = 'checkout'
729
self._default_errors = ["Working tree is out of date, please run"
731
self._default_pushed_revid = 'modified-in-local'
733
def test_push_default(self):
734
self.assertPushFails([])
736
def test_push_with_revision(self):
737
self.thisFailsStrictLockCheck()
738
self.assertPushSucceeds(['-r', 'revid:added'], pushed_revid='added')
740
def test_push_no_strict(self):
741
self.thisFailsStrictLockCheck()
742
self.assertPushSucceeds(['--no-strict'])
744
def test_push_strict_with_changes(self):
745
self.assertPushFails(['--strict'])
747
def test_push_respect_config_var_strict(self):
748
self.set_config_push_strict('true')
749
self.assertPushFails([])
751
def test_push_bogus_config_var_ignored(self):
752
self.set_config_push_strict("I don't want you to be strict")
753
self.assertPushFails([])
755
def test_push_no_strict_command_line_override_config(self):
756
self.thisFailsStrictLockCheck()
757
self.set_config_push_strict('yES')
758
self.assertPushFails([])
759
self.assertPushSucceeds(['--no-strict'])
761
def test_push_strict_command_line_override_config(self):
762
self.thisFailsStrictLockCheck()
763
self.set_config_push_strict('oFF')
764
self.assertPushFails(['--strict'])
765
self.assertPushSucceeds([])