/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/reconcile.py

Partial support for native reconcile with packs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    errors,
31
31
    ui,
32
32
    repository,
 
33
    repofmt,
33
34
    )
34
35
from bzrlib.trace import mutter, note
35
36
from bzrlib.tsort import TopoSorter
469
470
        """Perform the steps to reconcile this repository."""
470
471
        if not self.thorough:
471
472
            return
472
 
        self.repo.lock_write()
 
473
        collection = self.repo._pack_collection
 
474
        collection.ensure_loaded()
 
475
        collection.lock_names()
473
476
        try:
474
 
            self.repo._pack_collection.ensure_loaded()
475
 
            self.repo._pack_collection.lock_names()
476
 
            try:
477
 
                self.repo.start_write_group()
478
 
                try:
479
 
                    self._new_pack = self.repo._pack_collection._new_pack
480
 
                    self._copy_revisions()
481
 
                except:
482
 
                    self.repo.abort_write_group()
483
 
                    raise
484
 
                else:
485
 
                    self.repo.commit_write_group()
486
 
            finally:
487
 
                self.repo._pack_collection._unlock_names()
 
477
            packs = collection.all_packs()
 
478
            all_revisions = self.repo.all_revision_ids()
 
479
            total_inventories = len(list(
 
480
                collection.inventory_index.combined_index.iter_all_entries()))
 
481
            if len(all_revisions):
 
482
                self._packer = repofmt.pack_repo.ReconcilePacker(
 
483
                    collection, packs, ".reconcile", all_revisions)
 
484
                new_pack = self._packer.pack(pb=self.pb)
 
485
                if new_pack is not None:
 
486
                    self._discard_packs(packs)
 
487
            else:
 
488
                # only make a new pack when there is data to copy.
 
489
                self._discard_packs(packs)
 
490
            self.garbage_inventories = total_inventories - len(list(
 
491
                collection.inventory_index.combined_index.iter_all_entries()))
488
492
        finally:
489
 
            self.repo.unlock()
490
 
 
491
 
    def _copy_revisions(self):
492
 
        """Copy revisions, regenerating the index as we go."""
493
 
 
494
 
    def _pack_correcting_data(self):
495
 
        """Perform a total pack, regenerating as much data as possible."""
496
 
        revisions = self.repo.all_revision_ids()
 
493
            collection._unlock_names()
 
494
 
 
495
    def _discard_packs(self, packs):
 
496
        """Discard some packs from the repository.
 
497
 
 
498
        This removes them from the memory index and renames them into the
 
499
        obsolete packs directory.
 
500
        :param packs: The packs to discard.
 
501
        """
 
502
        for pack in packs:
 
503
            self.repo._pack_collection._remove_pack_from_memory(pack)
 
504
        self.repo._pack_collection._save_pack_names()
 
505
        self.repo._pack_collection._obsolete_packs(packs)