563
563
state.lock_read()
565
565
entry = state._get_entry(0, path_utf8='a-file')
566
# The current sha1 sum should be empty
567
self.assertEqual('', entry[1][0][1])
566
# The current size should be 0 (default)
567
self.assertEqual(0, entry[1][0][2])
568
568
# We should have a real entry.
569
569
self.assertNotEqual((None, None), entry)
570
570
# Make sure everything is old enough
571
571
state._sha_cutoff_time()
572
572
state._cutoff_time += 10
573
sha1sum = dirstate.update_entry(state, entry, 'a-file', os.lstat('a-file'))
574
# We should have gotten a real sha1
575
self.assertEqual('ecc5374e9ed82ad3ea3b4d452ea995a5fd3e70e3',
573
# Change the file length
574
self.build_tree_contents([('a-file', 'shorter')])
575
sha1sum = dirstate.update_entry(state, entry, 'a-file',
577
# new file, no cached sha:
578
self.assertEqual(None, sha1sum)
578
580
# The dirblock has been updated
579
self.assertEqual(sha1sum, entry[1][0][1])
581
self.assertEqual(7, entry[1][0][2])
580
582
self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
581
583
state._dirblock_state)
592
594
state.lock_read()
594
596
entry = state._get_entry(0, path_utf8='a-file')
595
self.assertEqual(sha1sum, entry[1][0][1])
597
self.assertEqual(7, entry[1][0][2])
611
613
state.lock_read()
613
615
entry = state._get_entry(0, path_utf8='a-file')
614
sha1sum = dirstate.update_entry(state, entry, 'a-file', os.lstat('a-file'))
615
# We should have gotten a real sha1
616
self.assertEqual('ecc5374e9ed82ad3ea3b4d452ea995a5fd3e70e3',
616
sha1sum = dirstate.update_entry(state, entry, 'a-file',
619
self.assertEqual(None, sha1sum)
618
620
self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
619
621
state._dirblock_state)