~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

Dirstate - truncate state file fixing bug in saving a smaller file, get more tree_implementation tests passing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
parent_details = WHOLE NUMBER, NULL, NL; XXX: complete this line
31
31
ghost_details = WHOLE NUMBER, NULL, {GHOST_ID NULL}*, NL;
32
32
rows = dirname, NULL, basename, NULL, MINIKIND, NULL, fileid_utf8, NULL,
33
 
    WHOLE NUMBER (* size *), NULL, packed stat, NULL, symlink value, 
 
33
    WHOLE NUMBER (* size *), NULL, packed stat, NULL, sha1|symlink target, 
34
34
    {PARENT ROW}
35
35
PARENT ROW = NULL, revision_utf8, NULL, MINIKIND, NULL, dirname, NULL,
36
36
    basename, NULL, WHOLE NUMBER (* size *), NULL, "y" | "n", NULL,
476
476
            assert field_count - cur == expected_field_count, \
477
477
                'field count incorrect %s != %s, entry_size=%s, '\
478
478
                'num_entries=%s fields=%r' % (
479
 
                    expected_field_count, field_count, entry_size,
 
479
                    field_count - cur, expected_field_count, entry_size,
480
480
                    self._num_entries, fields)
481
481
 
482
482
            # Fast path the case where there are 1 or 2 parents
612
612
            self._state_file.seek(0)
613
613
            self._state_file.writelines(self.get_lines())
614
614
            self._state_file.flush()
 
615
            self._state_file.truncate()
615
616
            self._header_state = DirState.IN_MEMORY_UNMODIFIED
616
617
            self._dirblock_state = DirState.IN_MEMORY_UNMODIFIED
617
618
 
644
645
            be encoded to utf8. In future this will be deprecated: avoid using
645
646
            unicode ids if possible.
646
647
        """
 
648
        self._read_header_if_needed()
647
649
        if len(path) or len(self._parents):
648
650
            # logic not written
649
651
            raise NotImplementedError(self.set_path_id)
 
652
        self._read_dirblocks_if_needed()
650
653
        if new_id.__class__ == unicode:
651
654
            new_id = new_id.encode('utf8')
652
655
        root_info, root_parents = self._root_row
653
656
        self._root_row = (root_info[0:3] + (new_id, ) + root_info[4:7]), root_parents
 
657
        self._dirblock_state = DirState.IN_MEMORY_MODIFIED
654
658
 
655
659
    def set_parent_trees(self, trees, ghosts):
656
660
        """Set the parent trees for the dirstate.