~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to tools/history2weaves.py

  • Committer: Martin Pool
  • Date: 2005-09-19 08:34:19 UTC
  • Revision ID: mbp@sourcefrog.net-20050919083418-31607ebe37d28bec
- upgrade format of inventories as they're converted

- fix storage of inventories into weave

- remove lots of dead code

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
 
181
181
    def _import_one_rev(self, rev_id):
182
182
        """Convert rev_id and all referenced file texts to new format."""
183
 
        inv_xml = self.branch.inventory_store[rev_id].read()
184
 
        inv = serializer_v4.read_inventory_from_string(inv_xml)
 
183
        old_inv_xml = self.branch.inventory_store[rev_id].read()
 
184
        inv = serializer_v4.read_inventory_from_string(old_inv_xml)
 
185
        new_inv_xml = serializer_v5.write_inventory_to_string(inv)
185
186
        inv_parents = [x for x in self.revisions[rev_id].parent_ids
186
187
                       if x not in self.absent_revisions]
187
188
        self.inv_weave.add(rev_id, inv_parents,
188
 
                           inv_xml.splitlines(True))
 
189
                           new_inv_xml.splitlines(True))
189
190
 
190
191
 
191
192
    def _make_order(self):
211
212
        return o
212
213
                
213
214
 
214
 
    def _convert_one_rev(self, rev_id):
215
 
        self._bump_progress()
216
 
        b = self.branch
217
 
 
218
 
        if rev_id not in b.revision_store:
219
 
            self.pb.clear()
220
 
            note('revision {%s} not present in branch; '
221
 
                 'will not be converted',
222
 
                 rev_id)
223
 
            self.absent_revisions.add(rev_id)
224
 
            return
225
 
        
226
 
        rev_xml = b.revision_store[rev_id].read()
227
 
        inv_xml = b.inventory_store[rev_id].read()
228
 
 
229
 
        rev = serializer_v4.read_revision_from_string(rev_xml)
230
 
        inv = serializer_v4.read_inventory_from_string(inv_xml)
231
 
 
232
 
        self.converted_revs.add(rev_id)
233
 
        
234
 
        return ##########################################
235
 
 
236
 
        tree = b.revision_tree(rev_id)
237
 
        inv = tree.inventory
238
 
 
239
 
        # for each file in the inventory, put it into its own revfile
240
 
        for file_id in inv:
241
 
            ie = inv[file_id]
242
 
            if ie.kind != 'file':
243
 
                continue
244
 
            if last_text_sha.get(file_id) == ie.text_sha1:
245
 
                # same as last time
246
 
                continue
247
 
            last_text_sha[file_id] = ie.text_sha1
248
 
 
249
 
            # new text (though possibly already stored); need to store it
250
 
            text_lines = tree.get_file(file_id).readlines()
251
 
 
252
 
            # if the file's created for the first time in this
253
 
            # revision then make a new weave; else find the old one
254
 
            if file_id not in text_weaves:
255
 
                text_weaves[file_id] = Weave()
256
 
 
257
 
            w = text_weaves[file_id]
258
 
 
259
 
            # base the new text version off whatever was last
260
 
            # (actually it'd be better to track this, to allow for
261
 
            # files that are deleted and then reappear)
262
 
            last = len(w)
263
 
            if last == 0:
264
 
                parents = []
265
 
            else:
266
 
                parents = [last-1]
267
 
 
268
 
            w.add(rev_id, parents, text_lines)
269
 
            text_count += 1
270
 
 
271
 
        revno += 1
272
 
        
273
 
 
274
 
 
275
215
def write_atomic_weave(weave, filename):
276
216
    inv_wf = AtomicFile(filename)
277
217
    try: