1
1
# Copyright (C) 2005, 2006 by Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
436
436
# do a merge into the bound branch from other, and then change the
437
437
# content file locally to force a new revision (rather than using the
438
438
# revision from other). This forces extra processing in commit.
439
self.merge(other_tree.branch, bound_tree)
439
bound_tree.merge_from_branch(other_tree.branch)
440
440
self.build_tree_contents([('bound/content_file', 'change in bound\n')])
442
442
# before #34959 was fixed, this failed with 'revision not present in
490
490
other_tree.commit('modify all sample files and dirs.')
492
492
other_tree.unlock()
493
self.merge(other_tree.branch, this_tree)
493
this_tree.merge_from_branch(other_tree.branch)
494
494
reporter = CapturingReporter()
495
495
this_tree.commit('do the commit', reporter=reporter)
496
496
self.assertEqual([
497
('change', 'unchanged', ''),
497
498
('change', 'unchanged', 'dirtoleave'),
498
499
('change', 'unchanged', 'filetoleave'),
499
500
('change', 'modified', 'filetomodify'),
507
508
('deleted', 'filetoremove'),
512
def test_commit_removals_respects_filespec(self):
513
"""Commit respects the specified_files for removals."""
514
tree = self.make_branch_and_tree('.')
515
self.build_tree(['a', 'b'])
517
tree.commit('added a, b')
518
tree.remove(['a', 'b'])
519
tree.commit('removed a', specific_files='a')
520
basis = tree.basis_tree().inventory
521
self.assertIs(None, basis.path2id('a'))
522
self.assertFalse(basis.path2id('b') is None)
524
def test_commit_saves_1ms_timestamp(self):
525
"""Passing in a timestamp is saved with 1ms resolution"""
526
tree = self.make_branch_and_tree('.')
527
self.build_tree(['a'])
529
tree.commit('added a', timestamp=1153248633.4186721, timezone=0,
532
rev = tree.branch.repository.get_revision('a1')
533
self.assertEqual(1153248633.419, rev.timestamp)
535
def test_commit_has_1ms_resolution(self):
536
"""Allowing commit to generate the timestamp also has 1ms resolution"""
537
tree = self.make_branch_and_tree('.')
538
self.build_tree(['a'])
540
tree.commit('added a', rev_id='a1')
542
rev = tree.branch.repository.get_revision('a1')
543
timestamp = rev.timestamp
544
timestamp_1ms = round(timestamp, 3)
545
self.assertEqual(timestamp_1ms, timestamp)