bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
3586.1.8
by Ian Clatworthy
add workingtree_5 and initial upgrade code |
1 |
# Copyright (C) 2008 Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
16 |
||
17 |
"""WorkingTree5 format and implementation.
|
|
18 |
"""
|
|
19 |
||
20 |
from bzrlib.lazy_import import lazy_import |
|
21 |
lazy_import(globals(), """ |
|
22 |
from bzrlib import (
|
|
23 |
views,
|
|
24 |
workingtree_4,
|
|
25 |
)
|
|
26 |
""") |
|
27 |
||
28 |
||
29 |
class WorkingTree5(workingtree_4.WorkingTree4): |
|
30 |
"""This is the Format 5 working tree. |
|
31 |
||
32 |
This differs from WorkingTree4 by:
|
|
33 |
- Supporting a current view that may mask the set of files in a tree
|
|
34 |
impacted by most user operations.
|
|
35 |
||
36 |
This is new in bzr 1.7.
|
|
37 |
"""
|
|
38 |
||
39 |
def _make_views(self): |
|
40 |
return views.PathBasedViews(self) |
|
41 |
||
42 |
||
43 |
class WorkingTreeFormat5(workingtree_4.WorkingTreeFormat4): |
|
44 |
"""WorkingTree format supporting views. |
|
45 |
"""
|
|
46 |
||
47 |
upgrade_recommended = False |
|
48 |
||
49 |
_tree_class = WorkingTree5 |
|
50 |
||
51 |
def get_format_string(self): |
|
52 |
"""See WorkingTreeFormat.get_format_string().""" |
|
53 |
return "Bazaar Working Tree Format 5 (bzr 1.7)\n" |
|
54 |
||
55 |
def get_format_description(self): |
|
56 |
"""See WorkingTreeFormat.get_format_description().""" |
|
57 |
return "Working tree format 5" |
|
58 |
||
59 |
def _init_custom_control_files(self, wt): |
|
60 |
"""Subclasses with custom control files should override this method.""" |
|
61 |
wt._transport.put_bytes('views', '', mode=wt.bzrdir._get_file_mode()) |
|
62 |
||
63 |
def supports_views(self): |
|
64 |
return True |
|
65 |
||
66 |
||
67 |
class Converter4to5(object): |
|
68 |
"""Perform an in-place upgrade of format 4 to format 5 trees.""" |
|
69 |
||
70 |
def __init__(self): |
|
71 |
self.target_format = WorkingTreeFormat5() |
|
72 |
||
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() |
|
78 |
try: |
|
79 |
self.init_custom_control_files(tree) |
|
80 |
self.update_format(tree) |
|
81 |
finally: |
|
82 |
tree._control_files.unlock() |
|
83 |
||
|
3586.2.1
by Ian Clatworthy
minor upgrade fix |
84 |
def init_custom_control_files(self, tree): |
|
3586.1.8
by Ian Clatworthy
add workingtree_5 and initial upgrade code |
85 |
"""Initialize custom control files.""" |
86 |
tree._transport.put_bytes('views', '', |
|
87 |
mode=tree.bzrdir._get_file_mode()) |
|
88 |
||
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()) |