/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/dirstate.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-10-24 07:28:00 UTC
  • mfrom: (2929.1.2 workingtree)
  • Revision ID: pqm@pqm.ubuntu.com-20071024072800-p2qtv2632xrbrs02
(robertc) Use a dictionary to obtain stat caches rather than digging into the dirstate on every path. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
337
337
        self._lock_token = None
338
338
        self._lock_state = None
339
339
        self._id_index = None
 
340
        # a map from packed_stat to sha's.
 
341
        self._packed_stat_index = None
340
342
        self._end_of_header = None
341
343
        self._cutoff_time = None
342
344
        self._split_path_cache = {}
1641
1643
        assert num_entries_line.startswith('num_entries: '), 'missing num_entries line'
1642
1644
        self._num_entries = int(num_entries_line[len('num_entries: '):-1])
1643
1645
 
 
1646
    def sha1_from_stat(self, path, stat_result, _pack_stat=pack_stat):
 
1647
        """Find a sha1 given a stat lookup."""
 
1648
        return self._get_packed_stat_index().get(_pack_stat(stat_result), None)
 
1649
 
 
1650
    def _get_packed_stat_index(self):
 
1651
        """Get a packed_stat index of self._dirblocks."""
 
1652
        if self._packed_stat_index is None:
 
1653
            index = {}
 
1654
            for key, tree_details in self._iter_entries():
 
1655
                if tree_details[0][0] == 'f':
 
1656
                    index[tree_details[0][4]] = tree_details[0][1]
 
1657
            self._packed_stat_index = index
 
1658
        return self._packed_stat_index
 
1659
 
1644
1660
    def save(self):
1645
1661
        """Save any pending changes created during this session.
1646
1662
 
1702
1718
        self._dirblock_state = DirState.IN_MEMORY_MODIFIED
1703
1719
        self._parents = list(parent_ids)
1704
1720
        self._id_index = None
 
1721
        self._packed_stat_index = None
1705
1722
 
1706
1723
    def set_path_id(self, path, new_id):
1707
1724
        """Change the id of path to new_id in the current working tree.
1987
2004
                current_old = advance(old_iterator)
1988
2005
        self._dirblock_state = DirState.IN_MEMORY_MODIFIED
1989
2006
        self._id_index = None
 
2007
        self._packed_stat_index = None
1990
2008
 
1991
2009
    def _make_absent(self, current_old):
1992
2010
        """Mark current_old - an entry - as absent for tree 0.
2295
2313
        self._ghosts = []
2296
2314
        self._dirblocks = []
2297
2315
        self._id_index = None
 
2316
        self._packed_stat_index = None
2298
2317
        self._end_of_header = None
2299
2318
        self._cutoff_time = None
2300
2319
        self._split_path_cache = {}