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?
240
241
self._make_control()
241
242
self._check_format(relax_version_check)
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)
250
store = CompressedTextStore(self._transport.clone(relpath))
251
store = CompressedTextStore(self._transport.clone(relpath),
252
store = TextStore(self._transport.clone(relpath))
254
store = TextStore(self._transport.clone(relpath),
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)
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
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,
273
281
self._transaction = None
275
283
def __str__(self):
335
343
self._transaction = new_transaction
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:
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
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
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'])