~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-09-29 22:03:03 UTC
  • mfrom: (5416.2.6 jam-integration)
  • Revision ID: pqm@pqm.ubuntu.com-20100929220303-cr95h8iwtggco721
(mbp) Add 'break-lock --force'

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    cleanup,
31
31
    errors,
32
32
    ui,
33
 
    repository,
34
33
    )
35
34
from bzrlib.trace import mutter
36
35
from bzrlib.tsort import topo_sort
37
36
from bzrlib.versionedfile import AdapterFactory, FulltextContentFactory
38
37
 
39
38
 
40
 
def reconcile(dir, other=None):
 
39
def reconcile(dir, canonicalize_chks=False):
41
40
    """Reconcile the data in dir.
42
41
 
43
42
    Currently this is limited to a inventory 'reweave'.
47
46
    Directly using Reconciler is recommended for library users that
48
47
    desire fine grained control or analysis of the found issues.
49
48
 
50
 
    :param other: another bzrdir to reconcile against.
 
49
    :param canonicalize_chks: Make sure CHKs are in canonical form.
51
50
    """
52
 
    reconciler = Reconciler(dir, other=other)
 
51
    reconciler = Reconciler(dir, canonicalize_chks=canonicalize_chks)
53
52
    reconciler.reconcile()
54
53
 
55
54
 
56
55
class Reconciler(object):
57
56
    """Reconcilers are used to reconcile existing data."""
58
57
 
59
 
    def __init__(self, dir, other=None):
 
58
    def __init__(self, dir, other=None, canonicalize_chks=False):
60
59
        """Create a Reconciler."""
61
60
        self.bzrdir = dir
 
61
        self.canonicalize_chks = canonicalize_chks
62
62
 
63
63
    def reconcile(self):
64
64
        """Perform reconciliation.
97
97
    def _reconcile_repository(self):
98
98
        self.repo = self.bzrdir.find_repository()
99
99
        ui.ui_factory.note('Reconciling repository %s' %
100
 
            self.repo.bzrdir.root_transport.base)
 
100
            self.repo.user_url)
101
101
        self.pb.update("Reconciling repository", 0, 1)
102
 
        repo_reconciler = self.repo.reconcile(thorough=True)
 
102
        if self.canonicalize_chks:
 
103
            try:
 
104
                self.repo.reconcile_canonicalize_chks
 
105
            except AttributeError:
 
106
                raise errors.BzrError(
 
107
                    "%s cannot canonicalize CHKs." % (self.repo,))
 
108
            repo_reconciler = self.repo.reconcile_canonicalize_chks()
 
109
        else:
 
110
            repo_reconciler = self.repo.reconcile(thorough=True)
103
111
        self.inconsistent_parents = repo_reconciler.inconsistent_parents
104
112
        self.garbage_inventories = repo_reconciler.garbage_inventories
105
113
        if repo_reconciler.aborted:
495
503
    #  - lock the names list
496
504
    #  - perform a customised pack() that regenerates data as needed
497
505
    #  - unlock the names list
498
 
    # https://bugs.edge.launchpad.net/bzr/+bug/154173
 
506
    # https://bugs.launchpad.net/bzr/+bug/154173
 
507
 
 
508
    def __init__(self, repo, other=None, thorough=False,
 
509
            canonicalize_chks=False):
 
510
        super(PackReconciler, self).__init__(repo, other=other,
 
511
            thorough=thorough)
 
512
        self.canonicalize_chks = canonicalize_chks
499
513
 
500
514
    def _reconcile_steps(self):
501
515
        """Perform the steps to reconcile this repository."""
510
524
        total_inventories = len(list(
511
525
            collection.inventory_index.combined_index.iter_all_entries()))
512
526
        if len(all_revisions):
513
 
            new_pack =  self.repo._reconcile_pack(collection, packs,
514
 
                ".reconcile", all_revisions, self.pb)
 
527
            if self.canonicalize_chks:
 
528
                reconcile_meth = self.repo._canonicalize_chks_pack
 
529
            else:
 
530
                reconcile_meth = self.repo._reconcile_pack
 
531
            new_pack = reconcile_meth(collection, packs, ".reconcile",
 
532
                all_revisions, self.pb)
515
533
            if new_pack is not None:
516
534
                self._discard_and_save(packs)
517
535
        else: