~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Robert Collins
  • Date: 2005-10-06 22:15:52 UTC
  • mfrom: (1185.13.2)
  • mto: This revision was merged to the branch mainline in revision 1420.
  • Revision ID: robertc@robertcollins.net-20051006221552-9b15c96fa504e0ad
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
from bzrlib.xml5 import serializer_v5
96
96
from bzrlib.trace import mutter, note, warning, enable_default_logging
97
97
from bzrlib.osutils import sha_strings, sha_string
98
 
from bzrlib.commit import merge_ancestry_lines
99
98
 
100
99
 
101
100
class Convert(object):
119
118
        if not os.path.isdir(self.base + '/.bzr/weaves'):
120
119
            os.mkdir(self.base + '/.bzr/weaves')
121
120
        self.inv_weave = Weave('inventory')
122
 
        self.anc_weave = Weave('ancestry')
123
 
        self.ancestries = {}
124
121
        # holds in-memory weaves for all files
125
122
        self.text_weaves = {}
126
123
        os.remove(self.branch.controlfilename('branch-format'))
197
194
 
198
195
    def _write_all_weaves(self):
199
196
        write_a_weave(self.inv_weave, self.base + '/.bzr/inventory.weave')
200
 
        write_a_weave(self.anc_weave, self.base + '/.bzr/ancestry.weave')
201
197
        i = 0
202
198
        try:
203
199
            for file_id, file_weave in self.text_weaves.items():
273
269
                           if p not in self.absent_revisions]
274
270
        self._convert_revision_contents(rev, inv, present_parents)
275
271
        self._store_new_weave(rev, inv, present_parents)
276
 
        self._make_rev_ancestry(rev, present_parents)
277
272
        self.converted_revs.add(rev_id)
278
273
 
279
274
 
295
290
                           new_inv_sha1)
296
291
        rev.inventory_sha1 = new_inv_sha1
297
292
 
298
 
 
299
 
    def _make_rev_ancestry(self, rev, present_parents):
300
 
        rev_id = rev.revision_id
301
 
        for parent_id in present_parents:
302
 
            assert parent_id in self.converted_revs
303
 
        if present_parents:
304
 
            lines = list(self.anc_weave.mash_iter(present_parents))
305
 
        else:
306
 
            lines = []
307
 
        lines.append(rev_id + '\n')
308
 
        if __debug__:
309
 
            parent_ancestries = [self.ancestries[p] for p in present_parents]
310
 
            new_lines = merge_ancestry_lines(rev_id, parent_ancestries)
311
 
            assert set(lines) == set(new_lines)
312
 
            self.ancestries[rev_id] = new_lines
313
 
        self.anc_weave.add(rev_id, present_parents, lines)
314
 
 
315
 
 
316
293
    def _convert_revision_contents(self, rev, inv, present_parents):
317
294
        """Convert all the files within a revision.
318
295
 
340
317
            w = Weave(file_id)
341
318
            self.text_weaves[file_id] = w
342
319
        text_changed = False
343
 
        previous_revisions = {}
344
 
        for parent_inv in parent_invs:
345
 
            if parent_inv.has_id(file_id):
346
 
                previous_ie = parent_inv[file_id]
347
 
                if previous_ie.revision in previous_revisions:
348
 
                    assert previous_revisions[previous_ie.revision] == previous_ie
349
 
                else:
350
 
                    previous_revisions[previous_ie.revision] = previous_ie
351
 
                old_revision = previous_ie.revision
352
 
        for old_revision in previous_revisions:
 
320
        previous_entries = ie.find_previous_heads(parent_invs, w)
 
321
        for old_revision in previous_entries:
353
322
                # if this fails, its a ghost ?
354
323
                assert old_revision in self.converted_revs 
355
 
        self.snapshot_ie(previous_revisions, ie, w, rev_id)
 
324
        self.snapshot_ie(previous_entries, ie, w, rev_id)
356
325
        del ie.text_id
357
326
        assert getattr(ie, 'revision', None) is not None
358
327
 
359
328
    def snapshot_ie(self, previous_revisions, ie, w, rev_id):
360
329
        # TODO: convert this logic, which is ~= snapshot to
361
330
        # a call to:. This needs the path figured out. rather than a work_tree
362
 
        # a v4 revision_tree can be given, or something that can give the
363
 
        # text for the ie if it needs it.
 
331
        # a v4 revision_tree can be given, or something that looks enough like
 
332
        # one to give the file content to the entry if it needs it.
364
333
        # and we need something that looks like a weave store for snapshot to 
365
334
        # save against.
366
335
        #ie.snapshot(rev, PATH, previous_revisions, REVISION_TREE, InMemoryWeaveStore(self.text_weaves))