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):
471
479
files = [('README',
472
480
"This is a Bazaar-NG control directory.\n"
473
481
"Do not change any files in this directory.\n"),
474
('branch-format', BZR_BRANCH_FORMAT_5),
482
('branch-format', BZR_BRANCH_FORMAT_6),
475
483
('revision-history', ''),
476
484
('branch-name', ''),
477
485
('branch-lock', ''),
499
507
except NoSuchFile:
500
508
raise NotBranchError(self.base)
501
509
mutter("got branch format %r", fmt)
502
if fmt == BZR_BRANCH_FORMAT_5:
510
if fmt == BZR_BRANCH_FORMAT_6:
511
self._branch_format = 6
512
elif fmt == BZR_BRANCH_FORMAT_5:
503
513
self._branch_format = 5
504
514
elif fmt == BZR_BRANCH_FORMAT_4:
505
515
self._branch_format = 4
507
517
if (not relax_version_check
508
and self._branch_format != 5):
518
and self._branch_format not in (5, 6)):
509
519
raise errors.UnsupportedFormatError(
510
520
'sorry, branch format %r not supported' % fmt,
511
521
['use a different bzr version',