~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_dirstate.py

  • Committer: Robert Collins
  • Date: 2008-09-25 01:54:42 UTC
  • mfrom: (3709.4.1 iter-changes.less-sha1)
  • mto: This revision was merged to the branch mainline in revision 3741.
  • Revision ID: robertc@robertcollins.net-20080925015442-p9mtzse65w5gy2uv
Integrate less aggressive sha logic with C iter-changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
563
563
        state.lock_read()
564
564
        try:
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',
576
 
                             sha1sum)
 
573
            # Change the file length
 
574
            self.build_tree_contents([('a-file', 'shorter')])
 
575
            sha1sum = dirstate.update_entry(state, entry, 'a-file',
 
576
                os.lstat('a-file'))
 
577
            # new file, no cached sha:
 
578
            self.assertEqual(None, sha1sum)
577
579
 
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)
582
584
 
592
594
        state.lock_read()
593
595
        try:
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])
596
598
        finally:
597
599
            state.unlock()
598
600
 
611
613
        state.lock_read()
612
614
        try:
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',
617
 
                             sha1sum)
 
616
            sha1sum = dirstate.update_entry(state, entry, 'a-file',
 
617
                os.lstat('a-file'))
 
618
            # No sha - too new
 
619
            self.assertEqual(None, sha1sum)
618
620
            self.assertEqual(dirstate.DirState.IN_MEMORY_MODIFIED,
619
621
                             state._dirblock_state)
620
622