~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

[merge] jam-integration 1527, including branch-formats, help text, misc bug fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from cStringIO import StringIO
18
18
 
 
19
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
20
from bzrlib.errors import InvalidRevisionId
19
21
from bzrlib.lockable_files import LockableFiles
20
 
from bzrlib.tree import EmptyTree
 
22
from bzrlib.osutils import safe_unicode
21
23
from bzrlib.revision import NULL_REVISION
22
24
from bzrlib.store import copy_all
23
25
from bzrlib.store.weave import WeaveStore
24
26
from bzrlib.store.text import TextStore
25
 
import bzrlib.xml5
26
27
from bzrlib.tree import RevisionTree
27
 
from bzrlib.errors import InvalidRevisionId
28
28
from bzrlib.testament import Testament
29
 
from bzrlib.decorators import needs_read_lock, needs_write_lock
 
29
from bzrlib.tree import EmptyTree
 
30
import bzrlib.xml5
30
31
 
31
32
 
32
33
 
43
44
    """
44
45
 
45
46
    def __init__(self, transport, branch_format):
 
47
        # circular dependencies:
 
48
        from bzrlib.branch import (BzrBranchFormat4,
 
49
                                   BzrBranchFormat5,
 
50
                                   BzrBranchFormat6,
 
51
                                   )
46
52
        object.__init__(self)
47
53
        self.control_files = LockableFiles(transport.clone(bzrlib.BZRDIR), 'README')
48
54
 
51
57
 
52
58
        def get_weave(name, prefixed=False):
53
59
            if name:
54
 
                name = bzrlib.BZRDIR + '/' + unicode(name)
 
60
                name = bzrlib.BZRDIR + '/' + safe_unicode(name)
55
61
            else:
56
62
                name = bzrlib.BZRDIR
57
63
            relpath = self.control_files._escape(name)
63
69
                ws.enable_cache = True
64
70
            return ws
65
71
 
 
72
 
66
73
        def get_store(name, compressed=True, prefixed=False):
67
74
            # FIXME: This approach of assuming stores are all entirely compressed
68
75
            # or entirely uncompressed is tidy, but breaks upgrade from 
69
76
            # some existing branches where there's a mixture; we probably 
70
77
            # still want the option to look for both.
71
78
            if name:
72
 
                name = bzrlib.BZRDIR + '/' + unicode(name)
 
79
                name = bzrlib.BZRDIR + '/' + safe_unicode(name)
73
80
            else:
74
81
                name = bzrlib.BZRDIR
75
82
            relpath = self.control_files._escape(name)
83
90
            #    store = bzrlib.store.CachedStore(store, cache_path)
84
91
            return store
85
92
 
86
 
        if branch_format == 4:
 
93
 
 
94
        if isinstance(branch_format, BzrBranchFormat4):
87
95
            self.inventory_store = get_store('inventory-store')
88
96
            self.text_store = get_store('text-store')
89
97
            self.revision_store = get_store('revision-store')
90
 
        elif branch_format == 5:
 
98
        elif isinstance(branch_format, BzrBranchFormat5):
91
99
            self.control_weaves = get_weave('')
92
100
            self.weave_store = get_weave('weaves')
93
101
            self.revision_store = get_store('revision-store', compressed=False)
94
 
        elif branch_format == 6:
 
102
        elif isinstance(branch_format, BzrBranchFormat6):
95
103
            self.control_weaves = get_weave('')
96
104
            self.weave_store = get_weave('weaves', prefixed=True)
97
105
            self.revision_store = get_store('revision-store', compressed=False,
204
212
        # TODO: Unify this with get_inventory()
205
213
        # bzr 0.0.6 and later imposes the constraint that the inventory_id
206
214
        # must be the same as its revision, so this is trivial.
207
 
        if revision_id == None:
 
215
        if revision_id is None:
208
216
            # This does not make sense: if there is no revision,
209
217
            # then it is the current tree inventory surely ?!
210
218
            # and thus get_root_id() is something that looks at the last
222
230
        an `EmptyTree` is returned."""
223
231
        # TODO: refactor this to use an existing revision object
224
232
        # so we don't need to read it in twice.
225
 
        if revision_id == None or revision_id == NULL_REVISION:
 
233
        if revision_id is None or revision_id == NULL_REVISION:
226
234
            return EmptyTree()
227
235
        else:
228
236
            inv = self.get_revision_inventory(revision_id)