~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: Martin
  • Date: 2010-04-14 00:11:32 UTC
  • mto: This revision was merged to the branch mainline in revision 5164.
  • Revision ID: gzlist@googlemail.com-20100414001132-6m1ru11mbfu87x6m
Fix os.utime test failures, three on FAT filesystems and one with readonly files

Show diffs side-by-side

added added

removed removed

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