~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

  • Committer: Martin Pool
  • Date: 2005-10-12 10:44:57 UTC
  • mto: (1185.16.26)
  • mto: This revision was merged to the branch mainline in revision 1454.
  • Revision ID: mbp@sourcefrog.net-20051012104457-a186917c83a2afc7
[pick] clear hashcache in format upgrade to avoid worrisome warning

robertc@lifelesslap.robertcollins.net-20051012002452-64068f25c8656f66

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /usr/bin/python
 
2
#
1
3
# Copyright (C) 2005 Canonical Ltd
2
4
#
3
5
# This program is free software; you can redistribute it and/or modify
66
68
# versions.
67
69
 
68
70
 
 
71
# TODO: Don't create a progress bar here, have it passed by the caller.  
 
72
# At least do it from the UI factory.
 
73
 
 
74
if False:
 
75
    try:
 
76
        import psyco
 
77
        psyco.full()
 
78
    except ImportError:
 
79
        pass
 
80
 
 
81
 
69
82
import os
70
83
import tempfile
71
84
import sys
 
85
import logging
72
86
import shutil
73
87
 
74
88
from bzrlib.branch import Branch, find_branch
75
89
from bzrlib.branch import BZR_BRANCH_FORMAT_5, BZR_BRANCH_FORMAT_6
76
90
import bzrlib.hashcache as hashcache
 
91
from bzrlib.revfile import Revfile
77
92
from bzrlib.weave import Weave
78
93
from bzrlib.weavefile import read_weave, write_weave
79
94
from bzrlib.ui import ui_factory
80
95
from bzrlib.atomicfile import AtomicFile
81
96
from bzrlib.xml4 import serializer_v4
82
97
from bzrlib.xml5 import serializer_v5
83
 
from bzrlib.trace import mutter, note, warning
 
98
from bzrlib.trace import mutter, note, warning, enable_default_logging
84
99
from bzrlib.osutils import sha_strings, sha_string
85
100
 
86
101
 
145
160
        # to_read is a stack holding the revisions we still need to process;
146
161
        # appending to it adds new highest-priority revisions
147
162
        self.known_revisions = set(rev_history)
148
 
        self.to_read = rev_history[-1:]
 
163
        self.to_read = [rev_history[-1]]
149
164
        while self.to_read:
150
165
            rev_id = self.to_read.pop()
151
166
            if (rev_id not in self.revisions
248
263
        self.pb.update('loading revision',
249
264
                       len(self.revisions),
250
265
                       len(self.known_revisions))
251
 
        if not self.branch.revision_store.has_id(rev_id):
 
266
        if rev_id not in self.branch.revision_store:
252
267
            self.pb.clear()
253
268
            note('revision {%s} not present in branch; '
254
269
                 'will be converted as a ghost',
255
270
                 rev_id)
256
271
            self.absent_revisions.add(rev_id)
257
272
        else:
258
 
            rev_xml = self.branch.revision_store.get(rev_id).read()
 
273
            rev_xml = self.branch.revision_store[rev_id].read()
259
274
            rev = serializer_v4.read_revision_from_string(rev_xml)
260
275
            for parent_id in rev.parent_ids:
261
276
                self.known_revisions.add(parent_id)
265
280
 
266
281
    def _load_old_inventory(self, rev_id):
267
282
        assert rev_id not in self.converted_revs
268
 
        old_inv_xml = self.branch.inventory_store.get(rev_id).read()
 
283
        old_inv_xml = self.branch.inventory_store[rev_id].read()
269
284
        inv = serializer_v4.read_inventory_from_string(old_inv_xml)
270
285
        rev = self.revisions[rev_id]
271
286
        if rev.inventory_sha1:
360
375
                return
361
376
        parent_indexes = map(w.lookup, previous_revisions)
362
377
        if ie.has_text():
363
 
            file_lines = self.branch.text_store.get(ie.text_id).readlines()
 
378
            file_lines = self.branch.text_store[ie.text_id].readlines()
364
379
            assert sha_strings(file_lines) == ie.text_sha1
365
380
            assert sum(map(len, file_lines)) == ie.text_size
366
381
            w.add(rev_id, parent_indexes, file_lines, ie.text_sha1)