~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

  • Committer: Robert Collins
  • Date: 2006-02-25 00:32:59 UTC
  • mto: (1587.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 1588.
  • Revision ID: robertc@robertcollins.net-20060225003259-eafe402b13b8b16e
Only reconcile if doing so will perform gc or correct ancestry.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
    Currently this is limited to a inventory 'reweave'.
32
32
 
33
 
    This is a convenience method, and the public api, for using a 
34
 
    Reconciler object.
 
33
    This is a convenience method, for using a Reconciler object.
 
34
 
 
35
    Directly using Reconciler is recommended for library users that
 
36
    desire fine grained control or analysis of the found issues.
35
37
    """
36
38
    reconciler = Reconciler(dir)
37
39
    reconciler.reconcile()
48
50
        self.bzrdir = dir
49
51
 
50
52
    def reconcile(self):
51
 
        """Actually perform the reconciliation."""
 
53
        """Perform reconciliation.
 
54
        
 
55
        After reconciliation the following attributes document found issues:
 
56
        inconsistent_parents: The number of revisions in the repository whose
 
57
                              ancestry was being reported incorrectly.
 
58
        garbage_inventories: The number of inventory objects without revisions
 
59
                             that were garbage collected.
 
60
        """
52
61
        self.pb = ui.ui_factory.progress_bar()
53
62
        self.repo = self.bzrdir.open_repository()
54
63
        self.repo.lock_write()
64
73
        """Regenerate the inventory weave for the repository from scratch."""
65
74
        self.pb.update('Reading inventory data.')
66
75
        self.inventory = self.repo.get_inventory_weave()
67
 
        self.repo.control_weaves.put_weave('inventory.backup',
68
 
                                           self.inventory,
69
 
                                           self.repo.get_transaction())
70
 
        self.pb.note('Backup Inventory created.')
71
 
        # asking for '' should never return a non-empty weave
72
 
        new_inventory = self.repo.control_weaves.get_weave_or_empty('',
73
 
            self.repo.get_transaction())
74
 
 
75
76
        # the total set of revisions to process
76
77
        self.pending = set([file_id for file_id in self.repo.revision_store])
77
78
 
81
82
 
82
83
        # mapping from revision_id to parents
83
84
        self._rev_graph = {}
 
85
        # errors that we detect
 
86
        self.inconsistent_parents = 0
84
87
        # we need the revision id of each revision and its available parents list
85
88
        for rev_id in self.pending:
86
89
            # put a revision into the graph.
87
90
            self._graph_revision(rev_id)
 
91
        # we gc unreferenced inventories too
 
92
        self.garbage_inventories = len(self.inventory.names()) \
 
93
                                   - len(self._rev_graph)
 
94
 
 
95
        if not self.inconsistent_parents and not self.garbage_inventories:
 
96
            self.pb.note('Inventory ok.')
 
97
            return
 
98
        self.repo.control_weaves.put_weave('inventory.backup',
 
99
                                           self.inventory,
 
100
                                           self.repo.get_transaction())
 
101
        self.pb.note('Backup Inventory created.')
 
102
        # asking for '' should never return a non-empty weave
 
103
        new_inventory = self.repo.control_weaves.get_weave_or_empty('',
 
104
            self.repo.get_transaction())
88
105
 
89
106
        # we have topological order of revisions and non ghost parents ready.
90
107
        for rev_id in TopoSorter(self._rev_graph.items()).iter_topo_order():
121
138
            else:
122
139
                mutter('found ghost %s', parent)
123
140
        self._rev_graph[rev_id] = parents   
 
141
        if set(self.inventory.parent_names(rev_id)) != set(parents):
 
142
            self.inconsistent_parents += 1
124
143
 
125
144
    def _reweave_step(self, message):
126
145
        """Mark a single step of regeneration complete."""