/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: Jelmer Vernooij
  • Date: 2010-04-30 11:35:43 UTC
  • mfrom: (5195 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5197.
  • Revision ID: jelmer@samba.org-20100430113543-tiqqhmqa3d8no4iu
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
587
587
                                             flush_func=flush_func)
588
588
        self.add_callback = None
589
589
 
590
 
    def replace_indices(self, index_to_pack, indices):
591
 
        """Replace the current mappings with fresh ones.
592
 
 
593
 
        This should probably not be used eventually, rather incremental add and
594
 
        removal of indices. It has been added during refactoring of existing
595
 
        code.
596
 
 
597
 
        :param index_to_pack: A mapping from index objects to
598
 
            (transport, name) tuples for the pack file data.
599
 
        :param indices: A list of indices.
600
 
        """
601
 
        # refresh the revision pack map dict without replacing the instance.
602
 
        self.index_to_pack.clear()
603
 
        self.index_to_pack.update(index_to_pack)
604
 
        # XXX: API break - clearly a 'replace' method would be good?
605
 
        self.combined_index._indices[:] = indices
606
 
        # the current add nodes callback for the current writable index if
607
 
        # there is one.
608
 
        self.add_callback = None
609
 
 
610
590
    def add_index(self, index, pack):
611
591
        """Add index to the aggregate, which is an index for Pack pack.
612
592
 
619
599
        # expose it to the index map
620
600
        self.index_to_pack[index] = pack.access_tuple()
621
601
        # put it at the front of the linear index list
622
 
        self.combined_index.insert_index(0, index)
 
602
        self.combined_index.insert_index(0, index, pack.name)
623
603
 
624
604
    def add_writable_index(self, index, pack):
625
605
        """Add an index which is able to have data added to it.
645
625
        self.data_access.set_writer(None, None, (None, None))
646
626
        self.index_to_pack.clear()
647
627
        del self.combined_index._indices[:]
 
628
        del self.combined_index._index_names[:]
648
629
        self.add_callback = None
649
630
 
650
631
    def remove_index(self, index):
653
634
        :param index: An index from the pack parameter.
654
635
        """
655
636
        del self.index_to_pack[index]
656
 
        self.combined_index._indices.remove(index)
 
637
        pos = self.combined_index._indices.index(index)
 
638
        del self.combined_index._indices[pos]
 
639
        del self.combined_index._index_names[pos]
657
640
        if (self.add_callback is not None and
658
641
            getattr(index, 'add_nodes', None) == self.add_callback):
659
642
            self.add_callback = None
1415
1398
        self.inventory_index = AggregateIndex(self.reload_pack_names, flush)
1416
1399
        self.text_index = AggregateIndex(self.reload_pack_names, flush)
1417
1400
        self.signature_index = AggregateIndex(self.reload_pack_names, flush)
 
1401
        all_indices = [self.revision_index, self.inventory_index,
 
1402
                self.text_index, self.signature_index]
1418
1403
        if use_chk_index:
1419
1404
            self.chk_index = AggregateIndex(self.reload_pack_names, flush)
 
1405
            all_indices.append(self.chk_index)
1420
1406
        else:
1421
1407
            # used to determine if we're using a chk_index elsewhere.
1422
1408
            self.chk_index = None
 
1409
        # Tell all the CombinedGraphIndex objects about each other, so they can
 
1410
        # share hints about which pack names to search first.
 
1411
        all_combined = [agg_idx.combined_index for agg_idx in all_indices]
 
1412
        for combined_idx in all_combined:
 
1413
            combined_idx.set_sibling_indices(
 
1414
                set(all_combined).difference([combined_idx]))
1423
1415
        # resumed packs
1424
1416
        self._resumed_packs = []
1425
1417
 
1568
1560
        """Is the collection already packed?"""
1569
1561
        return not (self.repo._format.pack_compresses or (len(self._names) > 1))
1570
1562
 
1571
 
    def pack(self, hint=None):
 
1563
    def pack(self, hint=None, clean_obsolete_packs=False):
1572
1564
        """Pack the pack collection totally."""
1573
1565
        self.ensure_loaded()
1574
1566
        total_packs = len(self._names)
1590
1582
                pack_operations[-1][1].append(pack)
1591
1583
        self._execute_pack_operations(pack_operations, OptimisingPacker)
1592
1584
 
 
1585
        if clean_obsolete_packs:
 
1586
            self._clear_obsolete_packs()
 
1587
 
1593
1588
    def plan_autopack_combinations(self, existing_packs, pack_distribution):
1594
1589
        """Plan a pack operation.
1595
1590
 
2383
2378
        raise NotImplementedError(self.dont_leave_lock_in_place)
2384
2379
 
2385
2380
    @needs_write_lock
2386
 
    def pack(self, hint=None):
 
2381
    def pack(self, hint=None, clean_obsolete_packs=False):
2387
2382
        """Compress the data within the repository.
2388
2383
 
2389
2384
        This will pack all the data to a single pack. In future it may
2390
2385
        recompress deltas or do other such expensive operations.
2391
2386
        """
2392
 
        self._pack_collection.pack(hint=hint)
 
2387
        self._pack_collection.pack(hint=hint, clean_obsolete_packs=clean_obsolete_packs)
2393
2388
 
2394
2389
    @needs_write_lock
2395
2390
    def reconcile(self, other=None, thorough=False):
2551
2546
        utf8_files = [('format', self.get_format_string())]
2552
2547
 
2553
2548
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
2554
 
        return self.open(a_bzrdir=a_bzrdir, _found=True)
 
2549
        repository = self.open(a_bzrdir=a_bzrdir, _found=True)
 
2550
        self._run_post_repo_init_hooks(repository, a_bzrdir, shared)
 
2551
        return repository
2555
2552
 
2556
2553
    def open(self, a_bzrdir, _found=False, _override_transport=None):
2557
2554
        """See RepositoryFormat.open().