~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/reconcile.py

Merge in knit repository use of knits - still not a stable format, but can be experimented with.

Show diffs side-by-side

added added

removed removed

Lines of Context:
105
105
 
106
106
    def _reweave_inventory(self):
107
107
        """Regenerate the inventory weave for the repository from scratch."""
 
108
        # local because its really a wart we want to hide
 
109
        from bzrlib.weave import WeaveFile, Weave
 
110
        transaction = self.repo.get_transaction()
108
111
        self.pb.update('Reading inventory data.')
109
112
        self.inventory = self.repo.get_inventory_weave()
110
113
        # the total set of revisions to process
111
 
        self.pending = set([file_id for file_id in self.repo.revision_store])
 
114
        self.pending = set([rev_id for rev_id in self.repo._revision_store.all_revision_ids(transaction)])
112
115
 
113
116
        # mapping from revision_id to parents
114
117
        self._rev_graph = {}
124
127
            self.pb.note('Inventory ok.')
125
128
            return
126
129
        self.pb.update('Backing up inventory...', 0, 0)
127
 
        self.repo.control_weaves.put_weave('inventory.backup',
128
 
                                           self.inventory,
129
 
                                           self.repo.get_transaction())
 
130
        self.repo.control_weaves.copy(self.inventory, 'inventory.backup', self.repo.get_transaction())
130
131
        self.pb.note('Backup Inventory created.')
131
132
        # asking for '' should never return a non-empty weave
132
 
        new_inventory = self.repo.control_weaves.get_weave_or_empty('',
 
133
        new_inventory = self.repo.control_weaves.get_empty('inventory.new',
133
134
            self.repo.get_transaction())
134
135
 
135
136
        # we have topological order of revisions and non ghost parents ready.
142
143
            # this entry has all the non ghost parents in the inventory
143
144
            # file already.
144
145
            self._reweave_step('adding inventories')
145
 
            new_inventory.add(rev_id, parents, self.inventory.get(rev_id))
 
146
            # ugly but needed, weaves are just way tooooo slow else.
 
147
            if isinstance(new_inventory, WeaveFile):
 
148
                Weave.add_lines(new_inventory, rev_id, parents, self.inventory.get_lines(rev_id))
 
149
            else:
 
150
                new_inventory.add_lines(rev_id, parents, self.inventory.get_lines(rev_id))
146
151
 
 
152
        if isinstance(new_inventory, WeaveFile):
 
153
            new_inventory._save()
147
154
        # if this worked, the set of new_inventory.names should equal
148
155
        # self.pending
149
 
        assert set(new_inventory.names()) == self.pending
 
156
        assert set(new_inventory.versions()) == self.pending
150
157
        self.pb.update('Writing weave')
151
 
        self.repo.control_weaves.put_weave('inventory',
152
 
                                           new_inventory,
153
 
                                           self.repo.get_transaction())
 
158
        self.repo.control_weaves.copy(new_inventory, 'inventory', self.repo.get_transaction())
 
159
        self.repo.control_weaves.delete('inventory.new', self.repo.get_transaction())
154
160
        self.inventory = None
155
161
        self.pb.note('Inventory regenerated.')
156
162
 
173
179
            else:
174
180
                mutter('found ghost %s', parent)
175
181
        self._rev_graph[rev_id] = parents   
176
 
        if set(self.inventory.parent_names(rev_id)) != set(parents):
 
182
        if set(self.inventory.get_parents(rev_id)) != set(parents):
177
183
            self.inconsistent_parents += 1
178
184
            mutter('Inconsistent inventory parents: id {%s} '
179
185
                   'inventory claims %r, '
180
186
                   'available parents are %r, '
181
187
                   'unavailable parents are %r',
182
188
                   rev_id, 
183
 
                   set(self.inventory.parent_names(rev_id)),
 
189
                   set(self.inventory.get_parents(rev_id)),
184
190
                   set(parents),
185
191
                   set(rev.parent_ids).difference(set(parents)))
186
192
 
190
196
        We cant trust them because their pre-requisite file data may not
191
197
        be present - all we know is that their revision was not installed.
192
198
        """
193
 
        inventories = set(self.inventory.names())
 
199
        inventories = set(self.inventory.versions())
194
200
        revisions = set(self._rev_graph.keys())
195
201
        garbage = inventories.difference(revisions)
196
202
        self.garbage_inventories = len(garbage)