~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
27
27
 
28
28
 
29
29
from bzrlib import (
 
30
    cleanup,
30
31
    errors,
31
32
    ui,
32
33
    repository,
33
 
    repofmt,
34
34
    )
35
 
from bzrlib.trace import mutter, note
 
35
from bzrlib.trace import mutter
36
36
from bzrlib.tsort import topo_sort
37
37
from bzrlib.versionedfile import AdapterFactory, FulltextContentFactory
38
38
 
120
120
        self.branch = a_branch
121
121
 
122
122
    def reconcile(self):
 
123
        operation = cleanup.OperationWithCleanups(self._reconcile)
 
124
        self.add_cleanup = operation.add_cleanup
 
125
        operation.run_simple()
 
126
 
 
127
    def _reconcile(self):
123
128
        self.branch.lock_write()
124
 
        try:
125
 
            self.pb = ui.ui_factory.nested_progress_bar()
126
 
            try:
127
 
                self._reconcile_steps()
128
 
            finally:
129
 
                self.pb.finished()
130
 
        finally:
131
 
            self.branch.unlock()
 
129
        self.add_cleanup(self.branch.unlock)
 
130
        self.pb = ui.ui_factory.nested_progress_bar()
 
131
        self.add_cleanup(self.pb.finished)
 
132
        self._reconcile_steps()
132
133
 
133
134
    def _reconcile_steps(self):
134
135
        self._reconcile_revision_history()
192
193
        garbage_inventories: The number of inventory objects without revisions
193
194
                             that were garbage collected.
194
195
        """
 
196
        operation = cleanup.OperationWithCleanups(self._reconcile)
 
197
        self.add_cleanup = operation.add_cleanup
 
198
        operation.run_simple()
 
199
 
 
200
    def _reconcile(self):
195
201
        self.repo.lock_write()
196
 
        try:
197
 
            self.pb = ui.ui_factory.nested_progress_bar()
198
 
            try:
199
 
                self._reconcile_steps()
200
 
            finally:
201
 
                self.pb.finished()
202
 
        finally:
203
 
            self.repo.unlock()
 
202
        self.add_cleanup(self.repo.unlock)
 
203
        self.pb = ui.ui_factory.nested_progress_bar()
 
204
        self.add_cleanup(self.pb.finished)
 
205
        self._reconcile_steps()
204
206
 
205
207
    def _reconcile_steps(self):
206
208
        """Perform the steps to reconcile this repository."""
502
504
        collection = self.repo._pack_collection
503
505
        collection.ensure_loaded()
504
506
        collection.lock_names()
505
 
        try:
506
 
            packs = collection.all_packs()
507
 
            all_revisions = self.repo.all_revision_ids()
508
 
            total_inventories = len(list(
509
 
                collection.inventory_index.combined_index.iter_all_entries()))
510
 
            if len(all_revisions):
511
 
                new_pack =  self.repo._reconcile_pack(collection, packs,
512
 
                    ".reconcile", all_revisions, self.pb)
513
 
                if new_pack is not None:
514
 
                    self._discard_and_save(packs)
515
 
            else:
516
 
                # only make a new pack when there is data to copy.
 
507
        self.add_cleanup(collection._unlock_names)
 
508
        packs = collection.all_packs()
 
509
        all_revisions = self.repo.all_revision_ids()
 
510
        total_inventories = len(list(
 
511
            collection.inventory_index.combined_index.iter_all_entries()))
 
512
        if len(all_revisions):
 
513
            new_pack =  self.repo._reconcile_pack(collection, packs,
 
514
                ".reconcile", all_revisions, self.pb)
 
515
            if new_pack is not None:
517
516
                self._discard_and_save(packs)
518
 
            self.garbage_inventories = total_inventories - len(list(
519
 
                collection.inventory_index.combined_index.iter_all_entries()))
520
 
        finally:
521
 
            collection._unlock_names()
 
517
        else:
 
518
            # only make a new pack when there is data to copy.
 
519
            self._discard_and_save(packs)
 
520
        self.garbage_inventories = total_inventories - len(list(
 
521
            collection.inventory_index.combined_index.iter_all_entries()))
522
522
 
523
523
    def _discard_and_save(self, packs):
524
524
        """Discard some packs from the repository.