223
223
wt.move(['hello'], 'a')
224
224
r2 = 'test@rev-2'
225
225
wt.commit('two', rev_id=r2, allow_pointless=False)
226
self.check_inventory_shape(wt.read_working_inventory(),
227
['a', 'a/hello', 'b'])
228
self.check_inventory_shape(wt.read_working_inventory(),
229
['a', 'a/hello', 'b'])
229
233
wt.move(['b'], 'a')
230
234
r3 = 'test@rev-3'
231
235
wt.commit('three', rev_id=r3, allow_pointless=False)
232
self.check_inventory_shape(wt.read_working_inventory(),
233
['a', 'a/hello', 'a/b'])
234
self.check_inventory_shape(b.repository.get_revision_inventory(r3),
235
['a', 'a/hello', 'a/b'])
238
self.check_inventory_shape(wt.read_working_inventory(),
239
['a', 'a/hello', 'a/b'])
240
self.check_inventory_shape(b.repository.get_revision_inventory(r3),
241
['a', 'a/hello', 'a/b'])
237
245
wt.move(['a/hello'], 'a/b')
238
246
r4 = 'test@rev-4'
239
247
wt.commit('four', rev_id=r4, allow_pointless=False)
240
self.check_inventory_shape(wt.read_working_inventory(),
241
['a', 'a/b/hello', 'a/b'])
250
self.check_inventory_shape(wt.read_working_inventory(),
251
['a', 'a/b/hello', 'a/b'])
243
255
inv = b.repository.get_revision_inventory(r4)
244
256
eq(inv['hello-id'].revision, r4)
245
257
eq(inv['a-id'].revision, r1)
246
258
eq(inv['b-id'].revision, r3)
248
260
def test_removed_commit(self):
249
261
"""Commit with a removed file"""
250
262
wt = self.make_branch_and_tree('.')
527
539
tree.commit('added a, b')
528
540
tree.remove(['a', 'b'])
529
541
tree.commit('removed a', specific_files='a')
530
basis = tree.basis_tree().inventory
531
self.assertIs(None, basis.path2id('a'))
532
self.assertFalse(basis.path2id('b') is None)
542
basis = tree.basis_tree()
545
self.assertIs(None, basis.path2id('a'))
546
self.assertFalse(basis.path2id('b') is None)
534
550
def test_commit_saves_1ms_timestamp(self):
535
551
"""Passing in a timestamp is saved with 1ms resolution"""
554
570
timestamp_1ms = round(timestamp, 3)
555
571
self.assertEqual(timestamp_1ms, timestamp)
573
def assertBasisTreeKind(self, kind, tree, file_id):
574
basis = tree.basis_tree()
577
self.assertEqual(kind, basis.kind(file_id))
557
581
def test_commit_kind_changes(self):
558
582
if not osutils.has_symlinks():
559
583
raise tests.TestSkipped('Test requires symlink support')
561
585
os.symlink('target', 'name')
562
586
tree.add('name', 'a-file-id')
563
587
tree.commit('Added a symlink')
564
self.assertEqual('symlink', tree.basis_tree().kind('a-file-id'))
588
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
566
590
os.unlink('name')
567
591
self.build_tree(['name'])
568
592
tree.commit('Changed symlink to file')
569
self.assertEqual('file', tree.basis_tree().kind('a-file-id'))
593
self.assertBasisTreeKind('file', tree, 'a-file-id')
571
595
os.unlink('name')
572
596
os.symlink('target', 'name')
573
597
tree.commit('file to symlink')
574
self.assertEqual('symlink', tree.basis_tree().kind('a-file-id'))
598
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
576
600
os.unlink('name')
578
602
tree.commit('symlink to directory')
579
self.assertEqual('directory', tree.basis_tree().kind('a-file-id'))
603
self.assertBasisTreeKind('directory', tree, 'a-file-id')
582
606
os.symlink('target', 'name')
583
607
tree.commit('directory to symlink')
584
self.assertEqual('symlink', tree.basis_tree().kind('a-file-id'))
608
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
586
610
# prepare for directory <-> file tests
587
611
os.unlink('name')
589
613
tree.commit('symlink to directory')
590
self.assertEqual('directory', tree.basis_tree().kind('a-file-id'))
614
self.assertBasisTreeKind('directory', tree, 'a-file-id')
593
617
self.build_tree(['name'])
594
618
tree.commit('Changed directory to file')
595
self.assertEqual('file', tree.basis_tree().kind('a-file-id'))
619
self.assertBasisTreeKind('file', tree, 'a-file-id')
597
621
os.unlink('name')
599
623
tree.commit('file to directory')
600
self.assertEqual('directory', tree.basis_tree().kind('a-file-id'))
624
self.assertBasisTreeKind('directory', tree, 'a-file-id')
602
626
def test_commit_unversioned_specified(self):
603
627
"""Commit should raise if specified files isn't in basis or worktree"""