38
38
# If forced, it should succeed, but this is not tested here.
39
39
self.run_bzr("init")
40
40
self.build_tree(['hello.txt'])
41
out,err = self.run_bzr("commit", "-m", "empty", retcode=3)
41
out,err = self.run_bzr('commit -m empty', retcode=3)
42
42
self.assertEqual('', out)
43
43
self.assertStartsWith(err, 'bzr: ERROR: no changes to commit.'
44
44
' use --unchanged to commit anyhow\n')
46
46
def test_commit_success(self):
47
47
"""Successful commit should not leave behind a bzr-commit-* file"""
48
48
self.run_bzr("init")
49
self.run_bzr("commit", "--unchanged", "-m", "message")
49
self.run_bzr('commit --unchanged -m message')
50
50
self.assertEqual('', self.run_bzr('unknowns')[0])
52
52
# same for unicode messages
53
self.run_bzr("commit", "--unchanged", "-m", u'foo\xb5')
53
self.run_bzr(["commit", "--unchanged", "-m", u'foo\xb5'])
54
54
self.assertEqual('', self.run_bzr('unknowns')[0])
56
56
def test_commit_with_path(self):
57
57
"""Commit tree with path of root specified"""
58
self.run_bzr('init', 'a')
58
self.run_bzr('init a')
59
59
self.build_tree(['a/a_file'])
60
self.run_bzr('add', 'a/a_file')
61
self.run_bzr('commit', '-m', 'first commit', 'a')
60
self.run_bzr('add a/a_file')
61
self.run_bzr('commit -m first-commit a')
63
self.run_bzr('branch', 'a', 'b')
63
self.run_bzr('branch a b')
64
64
self.build_tree_contents([('b/a_file', 'changes in b')])
65
self.run_bzr('commit', '-m', 'first commit in b', 'b')
65
self.run_bzr('commit -m first-commit-in-b b')
67
67
self.build_tree_contents([('a/a_file', 'new contents')])
68
self.run_bzr('commit', '-m', 'change in a', 'a')
68
self.run_bzr('commit -m change-in-a a')
71
self.run_bzr('merge', '../a', retcode=1) # will conflict
71
self.run_bzr('merge ../a', retcode=1) # will conflict
73
self.run_bzr('resolved', 'b/a_file')
74
self.run_bzr('commit', '-m', 'merge into b', 'b')
73
self.run_bzr('resolved b/a_file')
74
self.run_bzr('commit -m merge-into-b b')
77
77
def test_10_verbose_commit(self):
79
79
self.run_bzr("init")
80
80
self.build_tree(['hello.txt'])
81
81
self.run_bzr("add hello.txt")
82
out,err = self.run_bzr("commit", "-m", "added")
82
out,err = self.run_bzr('commit -m added')
83
83
self.assertEqual('', out)
84
84
self.assertEqual('added hello.txt\n'
85
85
'Committed revision 1.\n',
98
98
# Verbose commit of modified file should say so
99
99
wt = self.prepare_simple_history()
100
100
self.build_tree_contents([('hello.txt', 'new contents')])
101
out, err = self.run_bzr("commit", "-m", "modified")
101
out, err = self.run_bzr('commit -m modified')
102
102
self.assertEqual('', out)
103
103
self.assertEqual('modified hello.txt\n'
104
104
'Committed revision 2.\n',
108
108
# Verbose commit of renamed file should say so
109
109
wt = self.prepare_simple_history()
110
110
wt.rename_one('hello.txt', 'gutentag.txt')
111
out, err = self.run_bzr("commit", "-m", "renamed")
111
out, err = self.run_bzr('commit -m renamed')
112
112
self.assertEqual('', out)
113
113
self.assertEqual('renamed hello.txt => gutentag.txt\n'
114
114
'Committed revision 2.\n',
120
120
os.mkdir('subdir')
121
121
wt.add(['subdir'])
122
122
wt.rename_one('hello.txt', 'subdir/hello.txt')
123
out, err = self.run_bzr("commit", "-m", "renamed")
123
out, err = self.run_bzr('commit -m renamed')
124
124
self.assertEqual('', out)
125
125
self.assertEqualDiff('added subdir\n'
126
126
'renamed hello.txt => subdir/hello.txt\n'
133
133
wt = BzrDir.create_standalone_workingtree('.')
134
134
self.build_tree(['hello.txt', 'extra.txt'])
135
135
wt.add(['hello.txt'])
136
out,err = self.run_bzr("commit", "-m", "added")
136
out,err = self.run_bzr('commit -m added')
137
137
self.assertEqual('', out)
138
138
self.assertEqual('added hello.txt\n'
139
139
'Committed revision 1.\n',
146
146
self.run_bzr('add unchanged.txt')
147
147
self.run_bzr('commit -m unchanged unchanged.txt')
148
148
self.run_bzr("add hello.txt")
149
out,err = self.run_bzr("commit", "-m", "added")
149
out,err = self.run_bzr('commit -m added')
150
150
self.assertEqual('', out)
151
151
self.assertEqual('added hello.txt\n'
152
152
'Committed revision 2.\n',
202
202
other_tree.unlock()
203
203
this_tree.merge_from_branch(other_tree.branch)
205
out,err = self.run_bzr("commit", "-m", "added")
205
out,err = self.run_bzr('commit -m added')
207
207
self.assertEqual('', out)
208
208
self.assertEqualDiff(
264
264
def test_local_commit_unbound(self):
265
265
# a --local commit on an unbound branch is an error
266
266
self.make_branch_and_tree('.')
267
out, err = self.run_bzr('commit', '--local', retcode=3)
267
out, err = self.run_bzr('commit --local', retcode=3)
268
268
self.assertEqualDiff('', out)
269
269
self.assertEqualDiff('bzr: ERROR: Cannot perform local-only commits '
270
270
'on unbound branches.\n', err)
275
275
# past. This is a user story reported to fail in bug #43959 where
276
276
# a merge done in a checkout (using the update command) failed to
277
277
# commit correctly.
278
self.run_bzr('init', 'trunk')
278
self.run_bzr('init trunk')
280
self.run_bzr('checkout', 'trunk', 'u1')
280
self.run_bzr('checkout trunk u1')
281
281
self.build_tree_contents([('u1/hosts', 'initial contents')])
282
self.run_bzr('add', 'u1/hosts')
283
self.run_bzr('commit', '-m', 'add hosts', 'u1')
282
self.run_bzr('add u1/hosts')
283
self.run_bzr('commit -m add-hosts u1')
285
self.run_bzr('checkout', 'trunk', 'u2')
285
self.run_bzr('checkout trunk u2')
286
286
self.build_tree_contents([('u2/hosts', 'altered in u2')])
287
self.run_bzr('commit', '-m', 'checkin from u2', 'u2')
287
self.run_bzr('commit -m checkin-from-u2 u2')
289
289
# make an offline commits
290
290
self.build_tree_contents([('u1/hosts', 'first offline change in u1')])
291
self.run_bzr('commit', '-m', 'checkin offline', '--local', 'u1')
291
self.run_bzr('commit -m checkin-offline --local u1')
293
293
# now try to pull in online work from u2, and then commit our offline
294
294
# work as a merge
295
295
# retcode 1 as we expect a text conflict
296
self.run_bzr('update', 'u1', retcode=1)
297
self.run_bzr('resolved', 'u1/hosts')
296
self.run_bzr('update u1', retcode=1)
297
self.run_bzr('resolved u1/hosts')
298
298
# add a text change here to represent resolving the merge conflicts in
299
299
# favour of a new version of the file not identical to either the u1
300
300
# version or the u2 version.
301
301
self.build_tree_contents([('u1/hosts', 'merge resolution\n')])
302
self.run_bzr('commit', '-m', 'checkin merge of the offline work from u1', 'u1')
302
self.run_bzr('commit -m checkin-merge-of-the-offline-work-from-u1 u1')
304
304
def test_commit_respects_spec_for_removals(self):
305
305
"""Commit with a file spec should only commit removals that match"""
309
309
t.commit('Create')
310
310
t.remove(['file-a', 'dir-a/file-b'])
311
311
os.chdir('dir-a')
312
result = self.run_bzr('commit', '.', '-m' 'removed file-b')[1]
312
result = self.run_bzr('commit . -m removed-file-b')[1]
313
313
self.assertNotContainsRe(result, 'file-a')
314
314
result = self.run_bzr('status')[0]
315
315
self.assertContainsRe(result, 'removed:\n file-a')
321
321
self.build_tree(['tree/a'])
323
323
# A simple change should just work
324
self.run_bzr('commit', '--strict', '-m', 'adding a',
324
self.run_bzr('commit --strict -m adding-a',
325
325
working_dir='tree')
327
327
def test_strict_commit_no_changes(self):
334
334
# With no changes, it should just be 'no changes'
335
335
# Make sure that commit is failing because there is nothing to do
336
336
self.run_bzr_error(['no changes to commit'],
337
'commit', '--strict', '-m', 'no changes',
337
'commit --strict -m no-changes',
338
338
working_dir='tree')
340
340
# But --strict doesn't care if you supply --unchanged
341
self.run_bzr('commit', '--strict', '--unchanged', '-m', 'no changes',
341
self.run_bzr('commit --strict --unchanged -m no-changes',
342
342
working_dir='tree')
344
344
def test_strict_commit_unknown(self):
352
352
self.build_tree(['tree/b', 'tree/c'])
354
354
self.run_bzr_error(['Commit refused because there are unknown files'],
355
'commit', '--strict', '-m', 'add b',
355
'commit --strict -m add-b',
356
356
working_dir='tree')
358
358
# --no-strict overrides --strict
359
self.run_bzr('commit', '--strict', '-m', 'add b', '--no-strict',
359
self.run_bzr('commit --strict -m add-b --no-strict',
360
360
working_dir='tree')
362
362
def test_fixes_bug_output(self):
365
365
self.build_tree(['tree/hello.txt'])
366
366
tree.add('hello.txt')
367
367
output, err = self.run_bzr(
368
'commit', '-m', 'hello', '--fixes=lp:23452', 'tree/hello.txt')
368
'commit -m hello --fixes=lp:23452 tree/hello.txt')
369
369
self.assertEqual('', output)
370
370
self.assertEqual('added hello.txt\nCommitted revision 1.\n', err)
377
377
tree = self.make_branch_and_tree('tree')
378
378
self.build_tree(['tree/hello.txt'])
379
379
tree.add('hello.txt')
380
self.run_bzr( 'commit', '-m', 'hello', 'tree/hello.txt')
380
self.run_bzr( 'commit -m hello tree/hello.txt')
381
381
# Get the revision properties, ignoring the branch-nick property, which
382
382
# we don't care about for this test.
383
383
last_rev = tree.branch.repository.get_revision(tree.last_revision())
390
390
tree = self.make_branch_and_tree('tree')
391
391
self.build_tree(['tree/hello.txt'])
392
392
tree.add('hello.txt')
394
'commit', '-m', 'hello', '--fixes=lp:234', 'tree/hello.txt')
393
self.run_bzr('commit -m hello --fixes=lp:234 tree/hello.txt')
396
395
# Get the revision properties, ignoring the branch-nick property, which
397
396
# we don't care about for this test.
407
406
tree = self.make_branch_and_tree('tree')
408
407
self.build_tree(['tree/hello.txt'])
409
408
tree.add('hello.txt')
411
'commit', '-m', 'hello', '--fixes=lp:123', '--fixes=lp:235',
409
self.run_bzr('commit -m hello --fixes=lp:123 --fixes=lp:235'
414
412
# Get the revision properties, ignoring the branch-nick property, which
415
413
# we don't care about for this test.
431
429
'trac_twisted_url', 'http://twistedmatrix.com/trac')
432
430
self.build_tree(['tree/hello.txt'])
433
431
tree.add('hello.txt')
435
'commit', '-m', 'hello', '--fixes=lp:123',
436
'--fixes=twisted:235', 'tree/')
432
self.run_bzr('commit -m hello --fixes=lp:123 --fixes=twisted:235 tree/')
438
434
# Get the revision properties, ignoring the branch-nick property, which
439
435
# we don't care about for this test.
452
448
tree.add('hello.txt')
453
449
self.run_bzr_error(
454
450
["Unrecognized bug %s. Commit refused." % 'xxx:123'],
455
'commit', '-m', 'add b', '--fixes=xxx:123',
451
'commit -m add-b --fixes=xxx:123',
456
452
working_dir='tree')
458
454
def test_fixes_invalid_bug_number(self):
461
457
tree.add('hello.txt')
462
458
self.run_bzr_error(
463
459
["Invalid bug identifier for %s. Commit refused." % 'lp:orange'],
464
'commit', '-m', 'add b', '--fixes=lp:orange',
460
'commit -m add-b --fixes=lp:orange',
465
461
working_dir='tree')
467
463
def test_fixes_invalid_argument(self):