~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/upgrade.py

Give a reasonable warning on attempts to upgrade a readonly url.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
import sys
72
72
import shutil
73
73
 
 
74
from bzrlib.atomicfile import AtomicFile
74
75
from bzrlib.branch import Branch, find_branch
75
76
from bzrlib.branch import BZR_BRANCH_FORMAT_5, BZR_BRANCH_FORMAT_6
76
77
from bzrlib.branch import BzrBranchFormat4, BzrBranchFormat5, BzrBranchFormat6
 
78
from bzrlib.errors import UpgradeReadonly
77
79
import bzrlib.hashcache as hashcache
 
80
from bzrlib.osutils import sha_strings, sha_string, pathjoin, abspath
 
81
from bzrlib.ui import ui_factory
 
82
from bzrlib.trace import mutter, note, warning
 
83
from bzrlib.transport import get_transport
78
84
from bzrlib.weave import Weave
79
85
from bzrlib.weavefile import read_weave, write_weave
80
 
from bzrlib.ui import ui_factory
81
 
from bzrlib.atomicfile import AtomicFile
82
86
from bzrlib.xml4 import serializer_v4
83
87
from bzrlib.xml5 import serializer_v5
84
 
from bzrlib.trace import mutter, note, warning
85
 
from bzrlib.osutils import sha_strings, sha_string, pathjoin, abspath
86
88
 
87
89
 
88
90
class Convert(object):
89
 
    def __init__(self, base_dir):
90
 
        self.base = base_dir
 
91
 
 
92
    def __init__(self, transport):
 
93
        self.base = transport.base
91
94
        self.converted_revs = set()
92
95
        self.absent_revisions = set()
93
96
        self.text_count = 0
94
97
        self.revisions = {}
 
98
        self.transport = transport
95
99
        self.convert()
96
100
 
97
 
 
98
101
    def convert(self):
 
102
        if self.transport.is_readonly():
 
103
            raise UpgradeReadonly
99
104
        if not self._open_branch():
100
105
            return
101
106
        note('starting upgrade of %s', os.path.abspath(self.base))
403
408
        inv_wf.close()
404
409
 
405
410
 
406
 
def upgrade(base_dir):
407
 
    Convert(base_dir)
 
411
def upgrade(url):
 
412
    t = get_transport(url)
 
413
    Convert(t)