~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: John Arbash Meinel
  • Date: 2005-09-29 20:54:18 UTC
  • mto: (1393.1.12)
  • mto: This revision was merged to the branch mainline in revision 1396.
  • Revision ID: john@arbash-meinel.com-20050929205418-009b4b02254baf64
Updated stores to use Transport

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
from bzrlib.weavestore import WeaveStore
40
40
from bzrlib.store import copy_all
41
41
from bzrlib.store.compressed_text import CompressedTextStore
 
42
from bzrlib.store.text import TextStore
42
43
from bzrlib.transport import Transport
43
44
import bzrlib.xml5
44
45
import bzrlib.ui
231
232
        if init:
232
233
            self._make_control()
233
234
        self._check_format(relax_version_check)
234
 
        cfn = self.controlfilename
 
235
 
 
236
        def get_store(name, compressed=True):
 
237
            relpath = self._rel_controlfilename(name)
 
238
            if compressed:
 
239
                store = CompressedTextStore(self._transport.clone(relpath))
 
240
            else:
 
241
                store = TextStore(self._transport.clone(relpath))
 
242
            if self._transport.should_cache():
 
243
                from meta_store import CachedStore
 
244
                cache_path = os.path.join(self.cache_root, name)
 
245
                os.mkdir(cache_path)
 
246
                store = CachedStore(store, cache_path)
 
247
            return store
 
248
        def get_weave(name):
 
249
            relpath = self._rel_controlfilename(name)
 
250
            ws = WeaveStore(self._transport.clone(relpath))
 
251
            if self._transport.should_cache():
 
252
                ws.enable_cache = True
 
253
            return ws
 
254
 
235
255
        if self._branch_format == 4:
236
 
            self.inventory_store = CompressedTextStore(cfn('inventory-store'))
237
 
            self.text_store = CompressedTextStore(cfn('text-store'))
 
256
            self.inventory_store = get_store('inventory-store')
 
257
            self.text_store = get_store('text-store')
 
258
            self.revision_store = get_store('revision-store')
238
259
        elif self._branch_format == 5:
239
 
            self.control_weaves = WeaveStore(cfn([]))
240
 
            self.weave_store = WeaveStore(cfn('weaves'))
241
 
            if init:
242
 
                # FIXME: Unify with make_control_files
243
 
                self.control_weaves.put_empty_weave('inventory')
244
 
                self.control_weaves.put_empty_weave('ancestry')
245
 
        self.revision_store = CompressedTextStore(cfn('revision-store'))
 
260
            self.control_weaves = get_weave([]))
 
261
            self.weave_store = get_weave('weaves'))
 
262
            self.revision_store = get_store('revision-store', compressed=False)
246
263
 
247
264
    def __str__(self):
248
265
        return '%s(%r)' % (self.__class__.__name__, self._transport.base)
396
413
 
397
414
    def _make_control(self):
398
415
        from bzrlib.inventory import Inventory
 
416
        from bzrlib.weavefile import write_weave_v5
 
417
        from bzrlib.weave import Weave
399
418
        
400
419
        # Create an empty inventory
401
420
        sio = StringIO()
403
422
        # them; they're not needed for now and so ommitted for
404
423
        # simplicity.
405
424
        bzrlib.xml5.serializer_v5.write_inventory(Inventory(), sio)
 
425
        empty_inv = sio.getvalue()
 
426
        sio = StringIO()
 
427
        bzrlib.weavefile.write_weave_v5(Weave(), sio)
 
428
        empty_weave = sio.getvalue()
406
429
 
407
430
        dirs = [[], 'revision-store', 'weaves']
408
431
        files = [('README', 
413
436
            ('branch-name', ''),
414
437
            ('branch-lock', ''),
415
438
            ('pending-merges', ''),
416
 
            ('inventory', sio.getvalue())
 
439
            ('inventory', empty_inv),
 
440
            ('inventory.weave', empty_weave),
 
441
            ('ancestry.weave', empty_weave)
417
442
        ]
418
443
        cfn = self._rel_controlfilename
419
444
        self._transport.mkdir_multi([cfn(d) for d in dirs])