/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/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2009-03-16 05:33:31 UTC
  • mto: This revision was merged to the branch mainline in revision 4149.
  • Revision ID: robertc@robertcollins.net-20090316053331-84t8k9hv0xw7kak4
Prevent regression to overhead of lock_read on pack repositories.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1529
1529
        return [[final_rev_count, final_pack_list]]
1530
1530
 
1531
1531
    def ensure_loaded(self):
 
1532
        """Ensure we have read names from disk.
 
1533
 
 
1534
        :return: True if the disk names had not been previously read.
 
1535
        """
1532
1536
        # NB: if you see an assertion error here, its probably access against
1533
1537
        # an unlocked repo. Naughty.
1534
1538
        if not self.repo.is_locked():
1540
1544
                name = key[0]
1541
1545
                self._names[name] = self._parse_index_sizes(value)
1542
1546
                self._packs_at_load.add((key, value))
 
1547
            result = True
 
1548
        else:
 
1549
            result = False
1543
1550
        # populate all the metadata.
1544
1551
        self.all_packs()
 
1552
        return result
1545
1553
 
1546
1554
    def _parse_index_sizes(self, value):
1547
1555
        """Parse a string of index sizes."""
1840
1848
        This should be called when we find out that something we thought was
1841
1849
        present is now missing. This happens when another process re-packs the
1842
1850
        repository, etc.
 
1851
 
 
1852
        :return: True if the in-memory list of packs has been altered at all.
1843
1853
        """
1844
1854
        # The ensure_loaded call is to handle the case where the first call
1845
1855
        # made involving the collection was to reload_pack_names, where we 
1846
1856
        # don't have a view of disk contents. Its a bit of a bandaid, and
1847
1857
        # causes two reads of pack-names, but its a rare corner case not struck
1848
1858
        # with regular push/pull etc.
1849
 
        self.ensure_loaded()
1850
 
        # This is functionally similar to _save_pack_names, but we don't write
 
1859
        first_read = self.ensure_loaded()
 
1860
        if first_read:
 
1861
            return True
1851
1862
        # out the new value.
1852
1863
        disk_nodes, _, _ = self._diff_pack_names()
1853
1864
        self._packs_at_load = disk_nodes