~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/repository.py

  • Committer: Martin Pool
  • Date: 2006-04-12 04:45:32 UTC
  • mfrom: (1608.2.13 bzr.mbp.escape-stores)
  • mto: This revision was merged to the branch mainline in revision 1657.
  • Revision ID: mbp@sourcefrog.net-20060412044532-fc8c5c9408aae88b
[merge][wip] Storage escaping

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
from bzrlib.store.versioned import VersionedFileStore, WeaveStore
34
34
from bzrlib.store.text import TextStore
35
35
from bzrlib.symbol_versioning import *
36
 
from bzrlib.trace import mutter
 
36
from bzrlib.trace import mutter, note
37
37
from bzrlib.tree import RevisionTree
38
38
from bzrlib.tsort import topo_sort
39
39
from bzrlib.testament import Testament
96
96
            else:
97
97
                # yes, this is not suitable for adding with ghosts.
98
98
                self.add_inventory(rev_id, inv, rev.parent_ids)
99
 
        self._revision_store.add_revision(rev, self.get_transaction())   
 
99
        self._revision_store.add_revision(rev, self.get_transaction())
100
100
 
101
101
    @needs_read_lock
102
102
    def _all_possible_ids(self):
143
143
        getting file texts, inventories and revisions, then
144
144
        this construct will accept instances of those things.
145
145
        """
146
 
        object.__init__(self)
 
146
        super(Repository, self).__init__()
147
147
        self._format = _format
148
148
        # the following are part of the public API for Repository:
149
149
        self.bzrdir = a_bzrdir
156
156
        # 
157
157
        self.control_store = control_store
158
158
        self.control_weaves = control_store
 
159
        # TODO: make sure to construct the right store classes, etc, depending
 
160
        # on whether escaping is required.
159
161
 
160
162
    def lock_write(self):
161
163
        self.control_files.lock_write()
226
228
        self.copy_content_into(result, revision_id, basis)
227
229
        return result
228
230
 
 
231
    # XXX: Is this actually called?
 
232
    @needs_read_lock
 
233
    def copy(self, destination):
 
234
        raise NotImplementedError("Repository.copy() no longer required?")
 
235
        destination.lock_write()
 
236
        try:
 
237
            copy_all(self.weave_store, destination.weave_store)
 
238
            note('copying inventories')
 
239
            destination.control_weaves.copy_multi(self.control_weaves,
 
240
                ['inventory'])
 
241
            copy_all(self.revision_store, destination.revision_store)
 
242
        finally:
 
243
            destination.unlock()
 
244
 
229
245
    @needs_read_lock
230
246
    def has_revision(self, revision_id):
231
247
        """True if this repository has a copy of the revision."""
905
921
                                  transport,
906
922
                                  control_files,
907
923
                                  prefixed=True,
908
 
                                  versionedfile_class=WeaveFile):
 
924
                                  versionedfile_class=WeaveFile,
 
925
                                  escaped=False):
909
926
        weave_transport = control_files._transport.clone(name)
910
927
        dir_mode = control_files._dir_mode
911
928
        file_mode = control_files._file_mode
912
929
        return VersionedFileStore(weave_transport, prefixed=prefixed,
913
 
                                dir_mode=dir_mode,
914
 
                                file_mode=file_mode,
915
 
                                versionedfile_class=versionedfile_class)
 
930
                                  dir_mode=dir_mode,
 
931
                                  file_mode=file_mode,
 
932
                                  versionedfile_class=versionedfile_class,
 
933
                                  escaped=escaped)
916
934
 
917
935
    def initialize(self, a_bzrdir, shared=False):
918
936
        """Initialize a repository of this format in a_bzrdir.
1259
1277
     - an optional 'shared-storage' flag
1260
1278
     - an optional 'no-working-trees' flag
1261
1279
     - a LockDir lock
 
1280
 
 
1281
    This format was introduced in bzr 0.8.
1262
1282
    """
1263
1283
 
1264
1284
    def _get_control_store(self, repo_transport, control_files):
1280
1300
        from bzrlib.store.revision.knit import KnitRevisionStore
1281
1301
        versioned_file_store = VersionedFileStore(
1282
1302
            repo_transport,
1283
 
            file_mode = control_files._file_mode,
 
1303
            file_mode=control_files._file_mode,
1284
1304
            prefixed=False,
1285
1305
            precious=True,
1286
1306
            versionedfile_class=KnitVersionedFile,
1287
 
            versionedfile_kwargs={'delta':False, 'factory':KnitPlainFactory()})
 
1307
            versionedfile_kwargs={'delta':False, 'factory':KnitPlainFactory()},
 
1308
            escaped=True,
 
1309
            )
1288
1310
        return KnitRevisionStore(versioned_file_store)
1289
1311
 
1290
1312
    def _get_text_store(self, transport, control_files):
1292
1314
        return self._get_versioned_file_store('knits',
1293
1315
                                              transport,
1294
1316
                                              control_files,
1295
 
                                              versionedfile_class=KnitVersionedFile)
 
1317
                                              versionedfile_class=KnitVersionedFile,
 
1318
                                              escaped=True)
1296
1319
 
1297
1320
    def initialize(self, a_bzrdir, shared=False):
1298
1321
        """Create a knit format 1 repository.