1653
1653
# - RBC 20060907
1654
1654
self._write_inventory(self._inventory)
1656
def _iter_conflicts(self):
1658
for info in self.list_files():
1660
stem = get_conflicted_stem(path)
1663
if stem not in conflicted:
1664
conflicted.add(stem)
1667
1656
@needs_write_lock
1668
1657
def pull(self, source, overwrite=False, stop_revision=None,
1669
1658
change_reporter=None, possible_transports=None, local=False,
2428
2417
def add_conflicts(self, arg):
2429
2418
raise errors.UnsupportedOperation(self.add_conflicts, self)
2432
2420
def conflicts(self):
2433
conflicts = _mod_conflicts.ConflictList()
2434
for conflicted in self._iter_conflicts():
2437
if file_kind(self.abspath(conflicted)) != "file":
2439
except errors.NoSuchFile:
2442
for suffix in ('.THIS', '.OTHER'):
2444
kind = file_kind(self.abspath(conflicted+suffix))
2447
except errors.NoSuchFile:
2451
ctype = {True: 'text conflict', False: 'contents conflict'}[text]
2452
conflicts.append(_mod_conflicts.Conflict.factory(ctype,
2454
file_id=self.path2id(conflicted)))
2421
raise NotImplementedError(self.conflicts)
2457
2423
def walkdirs(self, prefix=""):
2458
2424
"""Walk the directories of this tree.
2717
2683
return ShelfManager(self, self._transport)
2720
class WorkingTree2(WorkingTree):
2721
"""This is the Format 2 working tree.
2723
This was the first weave based working tree.
2724
- uses os locks for locking.
2725
- uses the branch last-revision.
2728
def __init__(self, *args, **kwargs):
2729
super(WorkingTree2, self).__init__(*args, **kwargs)
2730
# WorkingTree2 has more of a constraint that self._inventory must
2731
# exist. Because this is an older format, we don't mind the overhead
2732
# caused by the extra computation here.
2734
# Newer WorkingTree's should only have self._inventory set when they
2736
if self._inventory is None:
2737
self.read_working_inventory()
2739
def _get_check_refs(self):
2740
"""Return the references needed to perform a check of this tree."""
2741
return [('trees', self.last_revision())]
2743
def lock_tree_write(self):
2744
"""See WorkingTree.lock_tree_write().
2746
In Format2 WorkingTrees we have a single lock for the branch and tree
2747
so lock_tree_write() degrades to lock_write().
2749
:return: An object with an unlock method which will release the lock
2752
self.branch.lock_write()
2754
self._control_files.lock_write()
2757
self.branch.unlock()
2761
# do non-implementation specific cleanup
2764
# we share control files:
2765
if self._control_files._lock_count == 3:
2766
# _inventory_is_modified is always False during a read lock.
2767
if self._inventory_is_modified:
2769
self._write_hashcache_if_dirty()
2771
# reverse order of locking.
2773
return self._control_files.unlock()
2775
self.branch.unlock()
2778
2686
class WorkingTree3(WorkingTree):
2779
2687
"""This is the Format 3 working tree.
3011
2913
format_registry.remove(format)
3014
class WorkingTreeFormat2(WorkingTreeFormat):
3015
"""The second working tree format.
3017
This format modified the hash cache from the format 1 hash cache.
3020
upgrade_recommended = True
3022
requires_normalized_unicode_filenames = True
3024
case_sensitive_filename = "Branch-FoRMaT"
3026
missing_parent_conflicts = False
3028
def get_format_description(self):
3029
"""See WorkingTreeFormat.get_format_description()."""
3030
return "Working tree format 2"
3032
def _stub_initialize_on_transport(self, transport, file_mode):
3033
"""Workaround: create control files for a remote working tree.
3035
This ensures that it can later be updated and dealt with locally,
3036
since BzrDirFormat6 and BzrDirFormat5 cannot represent dirs with
3037
no working tree. (See bug #43064).
3040
inv = inventory.Inventory()
3041
xml5.serializer_v5.write_inventory(inv, sio, working=True)
3043
transport.put_file('inventory', sio, file_mode)
3044
transport.put_bytes('pending-merges', '', file_mode)
3046
def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
3047
accelerator_tree=None, hardlink=False):
3048
"""See WorkingTreeFormat.initialize()."""
3049
if not isinstance(a_bzrdir.transport, LocalTransport):
3050
raise errors.NotLocalUrl(a_bzrdir.transport.base)
3051
if from_branch is not None:
3052
branch = from_branch
3054
branch = a_bzrdir.open_branch()
3055
if revision_id is None:
3056
revision_id = _mod_revision.ensure_null(branch.last_revision())
3059
branch.generate_revision_history(revision_id)
3062
inv = inventory.Inventory()
3063
wt = WorkingTree2(a_bzrdir.root_transport.local_abspath('.'),
3069
_control_files=branch.control_files)
3070
basis_tree = branch.repository.revision_tree(revision_id)
3071
if basis_tree.inventory.root is not None:
3072
wt.set_root_id(basis_tree.get_root_id())
3073
# set the parent list and cache the basis tree.
3074
if _mod_revision.is_null(revision_id):
3077
parent_trees = [(revision_id, basis_tree)]
3078
wt.set_parent_trees(parent_trees)
3079
transform.build_tree(basis_tree, wt)
3083
super(WorkingTreeFormat2, self).__init__()
3084
self._matchingbzrdir = bzrdir.BzrDirFormat6()
3086
def open(self, a_bzrdir, _found=False):
3087
"""Return the WorkingTree object for a_bzrdir
3089
_found is a private parameter, do not use it. It is used to indicate
3090
if format probing has already been done.
3093
# we are being called directly and must probe.
3094
raise NotImplementedError
3095
if not isinstance(a_bzrdir.transport, LocalTransport):
3096
raise errors.NotLocalUrl(a_bzrdir.transport.base)
3097
wt = WorkingTree2(a_bzrdir.root_transport.local_abspath('.'),
3101
_control_files=a_bzrdir.open_branch().control_files)
3104
2916
class WorkingTreeFormat3(WorkingTreeFormat):
3105
2917
"""The second working tree format updated to record a format marker.