96
96
from bzrlib.workingtree import WorkingTree, WorkingTree3, WorkingTreeFormat3
99
class WorkingTree4(WorkingTree3):
100
"""This is the Format 4 working tree.
102
This differs from WorkingTree3 by:
103
- Having a consolidated internal dirstate, stored in a
104
randomly-accessible sorted file on disk.
105
- Not having a regular inventory attribute. One can be synthesized
106
on demand but this is expensive and should be avoided.
108
This is new in bzr 0.15.
99
class DirStateWorkingTree(WorkingTree3):
111
100
def __init__(self, basedir,
113
102
_control_files=None,
894
883
for tree in trees:
895
884
if not (isinstance(tree, DirStateRevisionTree) and tree._revision_id in
897
return super(WorkingTree4, self).paths2ids(paths, trees, require_versioned)
886
return super(DirStateWorkingTree, self).paths2ids(paths,
887
trees, require_versioned)
898
888
search_indexes = [0] + [1 + parents.index(tree._revision_id) for tree in trees]
899
889
# -- make all paths utf8 --
900
890
paths_utf8 = set()
1294
class WorkingTreeFormat4(WorkingTreeFormat3):
1295
"""The first consolidated dirstate working tree format.
1298
- exists within a metadir controlling .bzr
1299
- includes an explicit version marker for the workingtree control
1300
files, separate from the BzrDir format
1301
- modifies the hash cache format
1302
- is new in bzr 0.15
1303
- uses a LockDir to guard access to it.
1306
upgrade_recommended = False
1308
_tree_class = WorkingTree4
1310
def get_format_string(self):
1311
"""See WorkingTreeFormat.get_format_string()."""
1312
return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
1314
def get_format_description(self):
1315
"""See WorkingTreeFormat.get_format_description()."""
1316
return "Working tree format 4"
1284
class WorkingTree4(DirStateWorkingTree):
1285
"""This is the Format 4 working tree.
1287
This differs from WorkingTree3 by:
1288
- Having a consolidated internal dirstate, stored in a
1289
randomly-accessible sorted file on disk.
1290
- Not having a regular inventory attribute. One can be synthesized
1291
on demand but this is expensive and should be avoided.
1293
This is new in bzr 0.15.
1297
class WorkingTree5(DirStateWorkingTree):
1298
"""This is the Format 5 working tree.
1300
This differs from WorkingTree4 by:
1301
- Supporting content filtering.
1302
- Supporting a current view that may mask the set of files in a tree
1303
impacted by most user operations.
1305
This is new in bzr 1.11.
1309
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1318
1310
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1319
1311
accelerator_tree=None, hardlink=False):
1320
1312
"""See WorkingTreeFormat.initialize().
1431
1423
_matchingbzrdir = property(__get_matchingbzrdir)
1426
class WorkingTreeFormat4(DirStateWorkingTreeFormat):
1427
"""The first consolidated dirstate working tree format.
1430
- exists within a metadir controlling .bzr
1431
- includes an explicit version marker for the workingtree control
1432
files, separate from the BzrDir format
1433
- modifies the hash cache format
1434
- is new in bzr 0.15
1435
- uses a LockDir to guard access to it.
1438
upgrade_recommended = False
1440
_tree_class = WorkingTree4
1442
def get_format_string(self):
1443
"""See WorkingTreeFormat.get_format_string()."""
1444
return "Bazaar Working Tree Format 4 (bzr 0.15)\n"
1446
def get_format_description(self):
1447
"""See WorkingTreeFormat.get_format_description()."""
1448
return "Working tree format 4"
1451
class WorkingTreeFormat5(DirStateWorkingTreeFormat):
1452
"""WorkingTree format supporting views.
1455
upgrade_recommended = False
1457
_tree_class = WorkingTree5
1459
def get_format_string(self):
1460
"""See WorkingTreeFormat.get_format_string()."""
1461
return "Bazaar Working Tree Format 5 (bzr 1.11)\n"
1463
def get_format_description(self):
1464
"""See WorkingTreeFormat.get_format_description()."""
1465
return "Working tree format 5"
1467
def _init_custom_control_files(self, wt):
1468
"""Subclasses with custom control files should override this method."""
1469
wt._transport.put_bytes('views', '', mode=wt.bzrdir._get_file_mode())
1471
def supports_content_filtering(self):
1474
def supports_views(self):
1434
1478
class DirStateRevisionTree(Tree):
1435
1479
"""A revision tree pulling the inventory from a dirstate."""
1947
1991
def is_compatible(source, target):
1948
1992
# the target must be a dirstate working tree
1949
if not isinstance(target, WorkingTree4):
1993
if not isinstance(target, DirStateWorkingTree):
1951
# the source must be a revtreee or dirstate rev tree.
1995
# the source must be a revtree or dirstate rev tree.
1952
1996
if not isinstance(source,
1953
1997
(revisiontree.RevisionTree, DirStateRevisionTree)):
2006
2050
tree._transport.put_bytes('format',
2007
2051
self.target_format.get_format_string(),
2008
2052
mode=tree.bzrdir._get_file_mode())
2055
class Converter4to5(object):
2056
"""Perform an in-place upgrade of format 4 to format 5 trees."""
2059
self.target_format = WorkingTreeFormat5()
2061
def convert(self, tree):
2062
# lock the control files not the tree, so that we don't get tree
2063
# on-unlock behaviours, and so that no-one else diddles with the
2064
# tree during upgrade.
2065
tree._control_files.lock_write()
2067
self.init_custom_control_files(tree)
2068
self.update_format(tree)
2070
tree._control_files.unlock()
2072
def init_custom_control_files(self, tree):
2073
"""Initialize custom control files."""
2074
tree._transport.put_bytes('views', '',
2075
mode=tree.bzrdir._get_file_mode())
2077
def update_format(self, tree):
2078
"""Change the format marker."""
2079
tree._transport.put_bytes('format',
2080
self.target_format.get_format_string(),
2081
mode=tree.bzrdir._get_file_mode())