392
412
self.assertRaises(LockContention, wt.commit, 'silly')
394
414
master_branch.unlock()
416
def test_commit_bound_merge(self):
417
# see bug #43959; commit of a merge in a bound branch fails to push
418
# the new commit into the master
419
master_branch = self.make_branch('master')
420
bound_tree = self.make_branch_and_tree('bound')
421
bound_tree.branch.bind(master_branch)
423
self.build_tree_contents([('bound/content_file', 'initial contents\n')])
424
bound_tree.add(['content_file'])
425
bound_tree.commit(message='woo!')
427
other_bzrdir = master_branch.bzrdir.sprout('other')
428
other_tree = other_bzrdir.open_workingtree()
430
# do a commit to the the other branch changing the content file so
431
# that our commit after merging will have a merged revision in the
432
# content file history.
433
self.build_tree_contents([('other/content_file', 'change in other\n')])
434
other_tree.commit('change in other')
436
# do a merge into the bound branch from other, and then change the
437
# content file locally to force a new revision (rather than using the
438
# revision from other). This forces extra processing in commit.
439
self.merge(other_tree.branch, bound_tree)
440
self.build_tree_contents([('bound/content_file', 'change in bound\n')])
442
# before #34959 was fixed, this failed with 'revision not present in
443
# weave' when trying to implicitly push from the bound branch to the master
444
bound_tree.commit(message='commit of merge in bound tree')
446
def test_commit_reporting_after_merge(self):
447
# when doing a commit of a merge, the reporter needs to still
448
# be called for each item that is added/removed/deleted.
449
this_tree = self.make_branch_and_tree('this')
450
# we need a bunch of files and dirs, to perform one action on each.
453
'this/dirtoreparent/',
456
'this/filetoreparent',
473
this_tree.commit('create_files')
474
other_dir = this_tree.bzrdir.sprout('other')
475
other_tree = other_dir.open_workingtree()
476
other_tree.lock_write()
477
# perform the needed actions on the files and dirs.
479
other_tree.rename_one('dirtorename', 'renameddir')
480
other_tree.rename_one('dirtoreparent', 'renameddir/reparenteddir')
481
other_tree.rename_one('filetorename', 'renamedfile')
482
other_tree.rename_one('filetoreparent', 'renameddir/reparentedfile')
483
other_tree.remove(['dirtoremove', 'filetoremove'])
484
self.build_tree_contents([
486
('other/filetomodify', 'new content'),
487
('other/newfile', 'new file content')])
488
other_tree.add('newfile')
489
other_tree.add('newdir/')
490
other_tree.commit('modify all sample files and dirs.')
493
self.merge(other_tree.branch, this_tree)
494
reporter = CapturingReporter()
495
this_tree.commit('do the commit', reporter=reporter)
497
('change', 'unchanged', 'dirtoleave'),
498
('change', 'unchanged', 'filetoleave'),
499
('change', 'modified', 'filetomodify'),
500
('change', 'added', 'newdir'),
501
('change', 'added', 'newfile'),
502
('renamed', 'renamed', 'dirtorename', 'renameddir'),
503
('renamed', 'renamed', 'dirtoreparent', 'renameddir/reparenteddir'),
504
('renamed', 'renamed', 'filetoreparent', 'renameddir/reparentedfile'),
505
('renamed', 'renamed', 'filetorename', 'renamedfile'),
506
('deleted', 'dirtoremove'),
507
('deleted', 'filetoremove'),
511
def test_commit_removals_respects_filespec(self):
512
"""Commit respects the specified_files for removals."""
513
tree = self.make_branch_and_tree('.')
514
self.build_tree(['a', 'b'])
516
tree.commit('added a, b')
517
tree.remove(['a', 'b'])
518
tree.commit('removed a', specific_files='a')
519
basis = tree.basis_tree().inventory
520
self.assertIs(None, basis.path2id('a'))
521
self.assertFalse(basis.path2id('b') is None)
523
def test_commit_saves_1ms_timestamp(self):
524
"""Passing in a timestamp is saved with 1ms resolution"""
525
tree = self.make_branch_and_tree('.')
526
self.build_tree(['a'])
528
tree.commit('added a', timestamp=1153248633.4186721, timezone=0,
531
rev = tree.branch.repository.get_revision('a1')
532
self.assertEqual(1153248633.419, rev.timestamp)
534
def test_commit_has_1ms_resolution(self):
535
"""Allowing commit to generate the timestamp also has 1ms resolution"""
536
tree = self.make_branch_and_tree('.')
537
self.build_tree(['a'])
539
tree.commit('added a', rev_id='a1')
541
rev = tree.branch.repository.get_revision('a1')
542
timestamp = rev.timestamp
543
timestamp_1ms = round(timestamp, 3)
544
self.assertEqual(timestamp_1ms, timestamp)