/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: 2010-02-28 10:08:29 UTC
  • mto: This revision was merged to the branch mainline in revision 5062.
  • Revision ID: robertc@robertcollins.net-20100228100829-nroa3qp8zi8jwxke
* bzr now has a ``.testr.conf`` file in its source tree configured
  appropriately for running tests with Testrepository
  (``https://launchpad.net/testrepository``). (Robert Collins)

* Documentation about testing with ``subunit`` has been tweaked.
  (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
    CommitBuilder,
70
70
    MetaDirRepositoryFormat,
71
71
    RepositoryFormat,
72
 
    RepositoryWriteLockResult,
73
72
    RootCommitBuilder,
74
73
    StreamSource,
75
74
    )
588
587
                                             flush_func=flush_func)
589
588
        self.add_callback = None
590
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
 
591
610
    def add_index(self, index, pack):
592
611
        """Add index to the aggregate, which is an index for Pack pack.
593
612
 
600
619
        # expose it to the index map
601
620
        self.index_to_pack[index] = pack.access_tuple()
602
621
        # put it at the front of the linear index list
603
 
        self.combined_index.insert_index(0, index, pack.name)
 
622
        self.combined_index.insert_index(0, index)
604
623
 
605
624
    def add_writable_index(self, index, pack):
606
625
        """Add an index which is able to have data added to it.
626
645
        self.data_access.set_writer(None, None, (None, None))
627
646
        self.index_to_pack.clear()
628
647
        del self.combined_index._indices[:]
629
 
        del self.combined_index._index_names[:]
630
648
        self.add_callback = None
631
649
 
632
650
    def remove_index(self, index):
635
653
        :param index: An index from the pack parameter.
636
654
        """
637
655
        del self.index_to_pack[index]
638
 
        pos = self.combined_index._indices.index(index)
639
 
        del self.combined_index._indices[pos]
640
 
        del self.combined_index._index_names[pos]
 
656
        self.combined_index._indices.remove(index)
641
657
        if (self.add_callback is not None and
642
658
            getattr(index, 'add_nodes', None) == self.add_callback):
643
659
            self.add_callback = None
1399
1415
        self.inventory_index = AggregateIndex(self.reload_pack_names, flush)
1400
1416
        self.text_index = AggregateIndex(self.reload_pack_names, flush)
1401
1417
        self.signature_index = AggregateIndex(self.reload_pack_names, flush)
1402
 
        all_indices = [self.revision_index, self.inventory_index,
1403
 
                self.text_index, self.signature_index]
1404
1418
        if use_chk_index:
1405
1419
            self.chk_index = AggregateIndex(self.reload_pack_names, flush)
1406
 
            all_indices.append(self.chk_index)
1407
1420
        else:
1408
1421
            # used to determine if we're using a chk_index elsewhere.
1409
1422
            self.chk_index = None
1410
 
        # Tell all the CombinedGraphIndex objects about each other, so they can
1411
 
        # share hints about which pack names to search first.
1412
 
        all_combined = [agg_idx.combined_index for agg_idx in all_indices]
1413
 
        for combined_idx in all_combined:
1414
 
            combined_idx.set_sibling_indices(
1415
 
                set(all_combined).difference([combined_idx]))
1416
1423
        # resumed packs
1417
1424
        self._resumed_packs = []
1418
1425
 
1561
1568
        """Is the collection already packed?"""
1562
1569
        return not (self.repo._format.pack_compresses or (len(self._names) > 1))
1563
1570
 
1564
 
    def pack(self, hint=None, clean_obsolete_packs=False):
 
1571
    def pack(self, hint=None):
1565
1572
        """Pack the pack collection totally."""
1566
1573
        self.ensure_loaded()
1567
1574
        total_packs = len(self._names)
1583
1590
                pack_operations[-1][1].append(pack)
1584
1591
        self._execute_pack_operations(pack_operations, OptimisingPacker)
1585
1592
 
1586
 
        if clean_obsolete_packs:
1587
 
            self._clear_obsolete_packs()
1588
 
 
1589
1593
    def plan_autopack_combinations(self, existing_packs, pack_distribution):
1590
1594
        """Plan a pack operation.
1591
1595
 
2355
2359
                # Writes don't affect fallback repos
2356
2360
                repo.lock_read()
2357
2361
            self._refresh_data()
2358
 
        return RepositoryWriteLockResult(self.unlock, None)
2359
2362
 
2360
2363
    def lock_read(self):
2361
2364
        locked = self.is_locked()
2370
2373
            for repo in self._fallback_repositories:
2371
2374
                repo.lock_read()
2372
2375
            self._refresh_data()
2373
 
        return self
2374
2376
 
2375
2377
    def leave_lock_in_place(self):
2376
2378
        # not supported - raise an error
2381
2383
        raise NotImplementedError(self.dont_leave_lock_in_place)
2382
2384
 
2383
2385
    @needs_write_lock
2384
 
    def pack(self, hint=None, clean_obsolete_packs=False):
 
2386
    def pack(self, hint=None):
2385
2387
        """Compress the data within the repository.
2386
2388
 
2387
2389
        This will pack all the data to a single pack. In future it may
2388
2390
        recompress deltas or do other such expensive operations.
2389
2391
        """
2390
 
        self._pack_collection.pack(hint=hint, clean_obsolete_packs=clean_obsolete_packs)
 
2392
        self._pack_collection.pack(hint=hint)
2391
2393
 
2392
2394
    @needs_write_lock
2393
2395
    def reconcile(self, other=None, thorough=False):
2549
2551
        utf8_files = [('format', self.get_format_string())]
2550
2552
 
2551
2553
        self._upload_blank_content(a_bzrdir, dirs, files, utf8_files, shared)
2552
 
        repository = self.open(a_bzrdir=a_bzrdir, _found=True)
2553
 
        self._run_post_repo_init_hooks(repository, a_bzrdir, shared)
2554
 
        return repository
 
2554
        return self.open(a_bzrdir=a_bzrdir, _found=True)
2555
2555
 
2556
2556
    def open(self, a_bzrdir, _found=False, _override_transport=None):
2557
2557
        """See RepositoryFormat.open().