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('.')
345
357
allow_pointless=True,
348
self.assertEqual(Testament.from_revision(branch.repository,
349
'B').as_short_text(),
361
return bzrlib.gpg.LoopbackGPGStrategy(None).sign(text)
362
self.assertEqual(sign(Testament.from_revision(branch.repository,
363
'B').as_short_text()),
350
364
branch.repository.get_signature_text('B'))
352
366
bzrlib.gpg.GPGStrategy = oldstrategy
527
541
tree.commit('added a, b')
528
542
tree.remove(['a', 'b'])
529
543
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)
544
basis = tree.basis_tree()
547
self.assertIs(None, basis.path2id('a'))
548
self.assertFalse(basis.path2id('b') is None)
534
552
def test_commit_saves_1ms_timestamp(self):
535
553
"""Passing in a timestamp is saved with 1ms resolution"""
554
572
timestamp_1ms = round(timestamp, 3)
555
573
self.assertEqual(timestamp_1ms, timestamp)
575
def assertBasisTreeKind(self, kind, tree, file_id):
576
basis = tree.basis_tree()
579
self.assertEqual(kind, basis.kind(file_id))
557
583
def test_commit_kind_changes(self):
558
584
if not osutils.has_symlinks():
559
585
raise tests.TestSkipped('Test requires symlink support')
561
587
os.symlink('target', 'name')
562
588
tree.add('name', 'a-file-id')
563
589
tree.commit('Added a symlink')
564
self.assertEqual('symlink', tree.basis_tree().kind('a-file-id'))
590
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
566
592
os.unlink('name')
567
593
self.build_tree(['name'])
568
594
tree.commit('Changed symlink to file')
569
self.assertEqual('file', tree.basis_tree().kind('a-file-id'))
595
self.assertBasisTreeKind('file', tree, 'a-file-id')
571
597
os.unlink('name')
572
598
os.symlink('target', 'name')
573
599
tree.commit('file to symlink')
574
self.assertEqual('symlink', tree.basis_tree().kind('a-file-id'))
600
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
576
602
os.unlink('name')
578
604
tree.commit('symlink to directory')
579
self.assertEqual('directory', tree.basis_tree().kind('a-file-id'))
605
self.assertBasisTreeKind('directory', tree, 'a-file-id')
582
608
os.symlink('target', 'name')
583
609
tree.commit('directory to symlink')
584
self.assertEqual('symlink', tree.basis_tree().kind('a-file-id'))
610
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
586
612
# prepare for directory <-> file tests
587
613
os.unlink('name')
589
615
tree.commit('symlink to directory')
590
self.assertEqual('directory', tree.basis_tree().kind('a-file-id'))
616
self.assertBasisTreeKind('directory', tree, 'a-file-id')
593
619
self.build_tree(['name'])
594
620
tree.commit('Changed directory to file')
595
self.assertEqual('file', tree.basis_tree().kind('a-file-id'))
621
self.assertBasisTreeKind('file', tree, 'a-file-id')
597
623
os.unlink('name')
599
625
tree.commit('file to directory')
600
self.assertEqual('directory', tree.basis_tree().kind('a-file-id'))
626
self.assertBasisTreeKind('directory', tree, 'a-file-id')
602
628
def test_commit_unversioned_specified(self):
603
629
"""Commit should raise if specified files isn't in basis or worktree"""