~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Robert Collins
  • Date: 2005-10-10 23:18:27 UTC
  • mfrom: (1437)
  • mto: This revision was merged to the branch mainline in revision 1438.
  • Revision ID: robertc@robertcollins.net-20051010231827-f9e2dda2e92bf565
mergeĀ fromĀ upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
BZR_BRANCH_FORMAT_4 = "Bazaar-NG branch, format 0.0.4\n"
53
53
BZR_BRANCH_FORMAT_5 = "Bazaar-NG branch, format 5\n"
 
54
BZR_BRANCH_FORMAT_6 = "Bazaar-NG branch, format 6\n"
54
55
## TODO: Maybe include checks for common corruption of newlines, etc?
55
56
 
56
57
 
240
241
            self._make_control()
241
242
        self._check_format(relax_version_check)
242
243
 
243
 
        def get_store(name, compressed=True):
 
244
        def get_store(name, compressed=True, prefixed=False):
244
245
            # FIXME: This approach of assuming stores are all entirely compressed
245
246
            # or entirely uncompressed is tidy, but breaks upgrade from 
246
247
            # some existing branches where there's a mixture; we probably 
247
248
            # still want the option to look for both.
248
249
            relpath = self._rel_controlfilename(name)
249
250
            if compressed:
250
 
                store = CompressedTextStore(self._transport.clone(relpath))
 
251
                store = CompressedTextStore(self._transport.clone(relpath),
 
252
                                            prefixed=prefixed)
251
253
            else:
252
 
                store = TextStore(self._transport.clone(relpath))
 
254
                store = TextStore(self._transport.clone(relpath),
 
255
                                  prefixed=prefixed)
253
256
            #if self._transport.should_cache():
254
257
            #    cache_path = os.path.join(self.cache_root, name)
255
258
            #    os.mkdir(cache_path)
256
259
            #    store = bzrlib.store.CachedStore(store, cache_path)
257
260
            return store
258
 
        def get_weave(name):
 
261
        def get_weave(name, prefixed=False):
259
262
            relpath = self._rel_controlfilename(name)
260
 
            ws = WeaveStore(self._transport.clone(relpath))
 
263
            ws = WeaveStore(self._transport.clone(relpath), prefixed=prefixed)
261
264
            if self._transport.should_cache():
262
265
                ws.enable_cache = True
263
266
            return ws
270
273
            self.control_weaves = get_weave([])
271
274
            self.weave_store = get_weave('weaves')
272
275
            self.revision_store = get_store('revision-store', compressed=False)
 
276
        elif self._branch_format == 6:
 
277
            self.control_weaves = get_weave([])
 
278
            self.weave_store = get_weave('weaves', prefixed=True)
 
279
            self.revision_store = get_store('revision-store', compressed=False,
 
280
                                            prefixed=True)
273
281
        self._transaction = None
274
282
 
275
283
    def __str__(self):
335
343
        self._transaction = new_transaction
336
344
 
337
345
    def lock_write(self):
 
346
        mutter("lock write: %s (%s)", self, self._lock_count)
338
347
        # TODO: Upgrade locking to support using a Transport,
339
348
        # and potentially a remote locking protocol
340
349
        if self._lock_mode:
351
360
 
352
361
 
353
362
    def lock_read(self):
 
363
        mutter("lock read: %s (%s)", self, self._lock_count)
354
364
        if self._lock_mode:
355
365
            assert self._lock_mode in ('r', 'w'), \
356
366
                   "invalid lock mode %r" % self._lock_mode
363
373
            self._set_transaction(transactions.ReadOnlyTransaction())
364
374
                        
365
375
    def unlock(self):
 
376
        mutter("unlock: %s (%s)", self, self._lock_count)
366
377
        if not self._lock_mode:
367
378
            raise LockError('branch %r is not locked' % (self))
368
379
 
471
482
        files = [('README', 
472
483
            "This is a Bazaar-NG control directory.\n"
473
484
            "Do not change any files in this directory.\n"),
474
 
            ('branch-format', BZR_BRANCH_FORMAT_5),
 
485
            ('branch-format', BZR_BRANCH_FORMAT_6),
475
486
            ('revision-history', ''),
476
487
            ('branch-name', ''),
477
488
            ('branch-lock', ''),
499
510
        except NoSuchFile:
500
511
            raise NotBranchError(self.base)
501
512
        mutter("got branch format %r", fmt)
502
 
        if fmt == BZR_BRANCH_FORMAT_5:
 
513
        if fmt == BZR_BRANCH_FORMAT_6:
 
514
            self._branch_format = 6
 
515
        elif fmt == BZR_BRANCH_FORMAT_5:
503
516
            self._branch_format = 5
504
517
        elif fmt == BZR_BRANCH_FORMAT_4:
505
518
            self._branch_format = 4
506
519
 
507
520
        if (not relax_version_check
508
 
            and self._branch_format != 5):
509
 
            raise BzrError('sorry, branch format %r not supported' % fmt,
 
521
            and self._branch_format not in (5, 6)):
 
522
            raise errors.UnsupportedFormatError(
 
523
                           'sorry, branch format %r not supported' % fmt,
510
524
                           ['use a different bzr version',
511
525
                            'or remove the .bzr directory'
512
526
                            ' and "bzr init" again'])