~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repofmt/pack_repo.py

  • Committer: Robert Collins
  • Date: 2009-03-27 04:10:25 UTC
  • mfrom: (4208 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4216.
  • Revision ID: robertc@robertcollins.net-20090327041025-rgutx4q03xo4pq6l
Resolve NEWS conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import re
18
18
import sys
532
532
    # XXX: Probably 'can be written to' could/should be separated from 'acts
533
533
    # like a knit index' -- mbp 20071024
534
534
 
535
 
    def __init__(self, reload_func=None):
 
535
    def __init__(self, reload_func=None, flush_func=None):
536
536
        """Create an AggregateIndex.
537
537
 
538
538
        :param reload_func: A function to call if we find we are missing an
543
543
        self.index_to_pack = {}
544
544
        self.combined_index = CombinedGraphIndex([], reload_func=reload_func)
545
545
        self.data_access = _DirectPackAccess(self.index_to_pack,
546
 
                                             reload_func=reload_func)
 
546
                                             reload_func=reload_func,
 
547
                                             flush_func=flush_func)
547
548
        self.add_callback = None
548
549
 
549
550
    def replace_indices(self, index_to_pack, indices):
725
726
 
726
727
    def open_pack(self):
727
728
        """Open a pack for the pack we are creating."""
728
 
        return NewPack(self._pack_collection, upload_suffix=self.suffix,
 
729
        new_pack = NewPack(self._pack_collection, upload_suffix=self.suffix,
729
730
                file_mode=self._pack_collection.repo.bzrdir._get_file_mode())
 
731
        # We know that we will process all nodes in order, and don't need to
 
732
        # query, so don't combine any indices spilled to disk until we are done
 
733
        new_pack.revision_index.set_optimize(combine_backing_indices=False)
 
734
        new_pack.inventory_index.set_optimize(combine_backing_indices=False)
 
735
        new_pack.text_index.set_optimize(combine_backing_indices=False)
 
736
        new_pack.signature_index.set_optimize(combine_backing_indices=False)
 
737
        return new_pack
730
738
 
731
739
    def _update_pack_order(self, entries, index_to_pack_map):
732
740
        """Determine how we want our packs to be ordered.
1315
1323
        # when a pack is being created by this object, the state of that pack.
1316
1324
        self._new_pack = None
1317
1325
        # aggregated revision index data
1318
 
        self.revision_index = AggregateIndex(self.reload_pack_names)
1319
 
        self.inventory_index = AggregateIndex(self.reload_pack_names)
1320
 
        self.text_index = AggregateIndex(self.reload_pack_names)
1321
 
        self.signature_index = AggregateIndex(self.reload_pack_names)
 
1326
        flush = self._flush_new_pack
 
1327
        self.revision_index = AggregateIndex(self.reload_pack_names, flush)
 
1328
        self.inventory_index = AggregateIndex(self.reload_pack_names, flush)
 
1329
        self.text_index = AggregateIndex(self.reload_pack_names, flush)
 
1330
        self.signature_index = AggregateIndex(self.reload_pack_names, flush)
1322
1331
        # resumed packs
1323
1332
        self._resumed_packs = []
1324
1333
 
1445
1454
        for revision_count, packs in pack_operations:
1446
1455
            self._obsolete_packs(packs)
1447
1456
 
 
1457
    def _flush_new_pack(self):
 
1458
        if self._new_pack is not None:
 
1459
            self._new_pack.flush()
 
1460
 
1448
1461
    def lock_names(self):
1449
1462
        """Acquire the mutex around the pack-names index.
1450
1463
 
2124
2137
            pb.finished()
2125
2138
        return result
2126
2139
 
2127
 
    @symbol_versioning.deprecated_method(symbol_versioning.one_one)
2128
 
    def get_parents(self, revision_ids):
2129
 
        """See graph._StackedParentsProvider.get_parents."""
2130
 
        parent_map = self.get_parent_map(revision_ids)
2131
 
        return [parent_map.get(r, None) for r in revision_ids]
2132
 
 
2133
2140
    def _make_parents_provider(self):
2134
2141
        return graph.CachingParentsProvider(self)
2135
2142