~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Robert Collins
  • Date: 2007-03-01 08:01:14 UTC
  • mto: (2255.11.3 dirstate)
  • mto: This revision was merged to the branch mainline in revision 2322.
  • Revision ID: robertc@robertcollins.net-20070301080114-dt6xpp7v0envbati
Fix test_inv - make setting WorkingTree4._dirty use a helper to reduce code duplication, and reset the inventory when we dont manually update it, if it exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
            # - on the first access it will be gathered, and we can
179
179
            # always change this once tests are all passing.
180
180
            state.add(f, file_id, kind, None, '')
 
181
        self._make_dirty(reset_inventory=True)
 
182
 
 
183
    def _make_dirty(self, reset_inventory):
 
184
        """Make the tree state dirty.
 
185
 
 
186
        :param reset_inventory: True if the cached inventory should be removed
 
187
            (presuming there is one).
 
188
        """
181
189
        self._dirty = True
 
190
        if reset_inventory and self._inventory is not None:
 
191
            self._inventory = None
182
192
 
183
193
    def break_lock(self):
184
194
        """Break a lock if one is present from another instance.
655
665
                raise
656
666
            result.append((from_rel, to_rel))
657
667
            state._dirblock_state = dirstate.DirState.IN_MEMORY_MODIFIED
658
 
            self._dirty = True
 
668
            self._make_dirty(reset_inventory=False)
659
669
 
660
670
        return result
661
671
 
906
916
                    self.branch.repository.revision_tree(None)))
907
917
                ghosts.append(rev_id)
908
918
        dirstate.set_parent_trees(real_trees, ghosts=ghosts)
909
 
        self._dirty = True
 
919
        self._make_dirty(reset_inventory=False)
910
920
 
911
921
    def _set_root_id(self, file_id):
912
922
        """See WorkingTree.set_root_id."""
913
923
        state = self.current_dirstate()
914
924
        state.set_path_id('', file_id)
915
 
        self._dirty = state._dirblock_state == dirstate.DirState.IN_MEMORY_MODIFIED
 
925
        if state._dirblock_state == dirstate.DirState.IN_MEMORY_MODIFIED:
 
926
            self._make_dirty(reset_inventory=True)
916
927
 
917
928
    def unlock(self):
918
929
        """Unlock in format 4 trees needs to write the entire dirstate."""
1008
1019
            block_index += 1
1009
1020
        if ids_to_unversion:
1010
1021
            raise errors.NoSuchId(self, iter(ids_to_unversion).next())
1011
 
        self._dirty = True
 
1022
        self._make_dirty(reset_inventory=False)
1012
1023
        # have to change the legacy inventory too.
1013
1024
        if self._inventory is not None:
1014
1025
            for file_id in file_ids:
1019
1030
        """Write inventory as the current inventory."""
1020
1031
        assert not self._dirty, "attempting to write an inventory when the dirstate is dirty will cause data loss"
1021
1032
        self.current_dirstate().set_state_from_inventory(inv)
1022
 
        self._dirty = True
 
1033
        self._make_dirty(reset_inventory=False)
 
1034
        if self._inventory is not None:
 
1035
            self._inventory = inv
1023
1036
        self.flush()
1024
1037
 
1025
1038
 
 
1039
 
1026
1040
class WorkingTreeFormat4(WorkingTreeFormat3):
1027
1041
    """The first consolidated dirstate working tree format.
1028
1042