221
223
wt.move(['hello'], 'a')
222
224
r2 = 'test@rev-2'
223
225
wt.commit('two', rev_id=r2, allow_pointless=False)
224
self.check_inventory_shape(wt.read_working_inventory(),
225
['a', 'a/hello', 'b'])
228
self.check_inventory_shape(wt.read_working_inventory(),
229
['a', 'a/hello', 'b'])
227
233
wt.move(['b'], 'a')
228
234
r3 = 'test@rev-3'
229
235
wt.commit('three', rev_id=r3, allow_pointless=False)
230
self.check_inventory_shape(wt.read_working_inventory(),
231
['a', 'a/hello', 'a/b'])
232
self.check_inventory_shape(b.repository.get_revision_inventory(r3),
233
['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'])
235
245
wt.move(['a/hello'], 'a/b')
236
246
r4 = 'test@rev-4'
237
247
wt.commit('four', rev_id=r4, allow_pointless=False)
238
self.check_inventory_shape(wt.read_working_inventory(),
239
['a', 'a/b/hello', 'a/b'])
250
self.check_inventory_shape(wt.read_working_inventory(),
251
['a', 'a/b/hello', 'a/b'])
241
255
inv = b.repository.get_revision_inventory(r4)
242
256
eq(inv['hello-id'].revision, r4)
243
257
eq(inv['a-id'].revision, r1)
244
258
eq(inv['b-id'].revision, r3)
246
260
def test_removed_commit(self):
247
261
"""Commit with a removed file"""
248
262
wt = self.make_branch_and_tree('.')
343
357
allow_pointless=True,
346
self.assertEqual(Testament.from_revision(branch.repository,
347
'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()),
348
364
branch.repository.get_signature_text('B'))
350
366
bzrlib.gpg.GPGStrategy = oldstrategy
525
541
tree.commit('added a, b')
526
542
tree.remove(['a', 'b'])
527
543
tree.commit('removed a', specific_files='a')
528
basis = tree.basis_tree().inventory
529
self.assertIs(None, basis.path2id('a'))
530
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)
532
552
def test_commit_saves_1ms_timestamp(self):
533
553
"""Passing in a timestamp is saved with 1ms resolution"""
552
572
timestamp_1ms = round(timestamp, 3)
553
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))
583
def test_commit_kind_changes(self):
584
if not osutils.has_symlinks():
585
raise tests.TestSkipped('Test requires symlink support')
586
tree = self.make_branch_and_tree('.')
587
os.symlink('target', 'name')
588
tree.add('name', 'a-file-id')
589
tree.commit('Added a symlink')
590
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
593
self.build_tree(['name'])
594
tree.commit('Changed symlink to file')
595
self.assertBasisTreeKind('file', tree, 'a-file-id')
598
os.symlink('target', 'name')
599
tree.commit('file to symlink')
600
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
604
tree.commit('symlink to directory')
605
self.assertBasisTreeKind('directory', tree, 'a-file-id')
608
os.symlink('target', 'name')
609
tree.commit('directory to symlink')
610
self.assertBasisTreeKind('symlink', tree, 'a-file-id')
612
# prepare for directory <-> file tests
615
tree.commit('symlink to directory')
616
self.assertBasisTreeKind('directory', tree, 'a-file-id')
619
self.build_tree(['name'])
620
tree.commit('Changed directory to file')
621
self.assertBasisTreeKind('file', tree, 'a-file-id')
625
tree.commit('file to directory')
626
self.assertBasisTreeKind('directory', tree, 'a-file-id')
555
628
def test_commit_unversioned_specified(self):
556
629
"""Commit should raise if specified files isn't in basis or worktree"""
557
630
tree = self.make_branch_and_tree('.')