1
# Copyright (C) 2008 Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
"""WorkingTree5 format and implementation.
20
from bzrlib.lazy_import import lazy_import
21
lazy_import(globals(), """
28
class WorkingTree5(workingtree_4.WorkingTree4):
29
"""This is the Format 5 working tree.
31
This differs from WorkingTree4 by:
32
- Supporting content filtering.
33
- Supporting a current view that may mask the set of files in a tree
34
impacted by most user operations.
36
This is new in bzr 1.11.
40
class WorkingTreeFormat5(workingtree_4.WorkingTreeFormat4):
41
"""WorkingTree format supporting views.
44
upgrade_recommended = False
46
_tree_class = WorkingTree5
48
def get_format_string(self):
49
"""See WorkingTreeFormat.get_format_string()."""
50
return "Bazaar Working Tree Format 5 (bzr 1.11)\n"
52
def get_format_description(self):
53
"""See WorkingTreeFormat.get_format_description()."""
54
return "Working tree format 5"
56
def _init_custom_control_files(self, wt):
57
"""Subclasses with custom control files should override this method."""
58
wt._transport.put_bytes('views', '', mode=wt.bzrdir._get_file_mode())
60
def supports_content_filtering(self):
63
def supports_views(self):
67
class Converter4to5(object):
68
"""Perform an in-place upgrade of format 4 to format 5 trees."""
71
self.target_format = WorkingTreeFormat5()
73
def convert(self, tree):
74
# lock the control files not the tree, so that we don't get tree
75
# on-unlock behaviours, and so that no-one else diddles with the
76
# tree during upgrade.
77
tree._control_files.lock_write()
79
self.init_custom_control_files(tree)
80
self.update_format(tree)
82
tree._control_files.unlock()
84
def init_custom_control_files(self, tree):
85
"""Initialize custom control files."""
86
tree._transport.put_bytes('views', '',
87
mode=tree.bzrdir._get_file_mode())
89
def update_format(self, tree):
90
"""Change the format marker."""
91
tree._transport.put_bytes('format',
92
self.target_format.get_format_string(),
93
mode=tree.bzrdir._get_file_mode())