758
753
self._set_merges_from_parent_ids(revision_ids)
760
755
@needs_tree_write_lock
761
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
762
"""See MutableTree.set_parent_trees."""
763
parent_ids = [rev for (rev, tree) in parents_list]
764
for revision_id in parent_ids:
765
_mod_revision.check_not_reserved_id(revision_id)
767
self._check_parents_for_ghosts(parent_ids,
768
allow_leftmost_as_ghost=allow_leftmost_as_ghost)
770
parent_ids = self._filter_parent_ids_by_ancestry(parent_ids)
772
if len(parent_ids) == 0:
773
leftmost_parent_id = _mod_revision.NULL_REVISION
774
leftmost_parent_tree = None
776
leftmost_parent_id, leftmost_parent_tree = parents_list[0]
778
if self._change_last_revision(leftmost_parent_id):
779
if leftmost_parent_tree is None:
780
# If we don't have a tree, fall back to reading the
781
# parent tree from the repository.
782
self._cache_basis_inventory(leftmost_parent_id)
784
inv = leftmost_parent_tree.inventory
785
xml = self._create_basis_xml_from_inventory(
786
leftmost_parent_id, inv)
787
self._write_basis_inventory(xml)
788
self._set_merges_from_parent_ids(parent_ids)
790
@needs_tree_write_lock
791
756
def set_pending_merges(self, rev_list):
792
757
parents = self.get_parent_ids()
793
758
leftmost = parents[:1]
1985
1950
"""See Tree.iter_all_file_ids"""
1986
1951
return set(self.inventory)
1953
@needs_tree_write_lock
1954
def set_parent_trees(self, parents_list, allow_leftmost_as_ghost=False):
1955
"""See MutableTree.set_parent_trees."""
1956
parent_ids = [rev for (rev, tree) in parents_list]
1957
for revision_id in parent_ids:
1958
_mod_revision.check_not_reserved_id(revision_id)
1960
self._check_parents_for_ghosts(parent_ids,
1961
allow_leftmost_as_ghost=allow_leftmost_as_ghost)
1963
parent_ids = self._filter_parent_ids_by_ancestry(parent_ids)
1965
if len(parent_ids) == 0:
1966
leftmost_parent_id = _mod_revision.NULL_REVISION
1967
leftmost_parent_tree = None
1969
leftmost_parent_id, leftmost_parent_tree = parents_list[0]
1971
if self._change_last_revision(leftmost_parent_id):
1972
if leftmost_parent_tree is None:
1973
# If we don't have a tree, fall back to reading the
1974
# parent tree from the repository.
1975
self._cache_basis_inventory(leftmost_parent_id)
1977
inv = leftmost_parent_tree.inventory
1978
xml = self._create_basis_xml_from_inventory(
1979
leftmost_parent_id, inv)
1980
self._write_basis_inventory(xml)
1981
self._set_merges_from_parent_ids(parent_ids)
1988
1983
def _cache_basis_inventory(self, new_revision):
1989
1984
"""Cache new_revision as the basis inventory."""
1990
1985
# TODO: this should allow the ready-to-use inventory to be passed in,
2973
2968
def __init__(self, other_registry=None):
2974
2969
super(WorkingTreeFormatRegistry, self).__init__(other_registry)
2975
2970
self._default_format = None
2971
self._default_format_key = None
2977
2973
def get_default(self):
2978
2974
"""Return the current default format."""
2975
if (self._default_format_key is not None and
2976
self._default_format is None):
2977
self._default_format = self.get(self._default_format_key)
2979
2978
return self._default_format
2981
2980
def set_default(self, format):
2981
"""Set the default format."""
2982
2982
self._default_format = format
2983
self._default_format_key = None
2985
def set_default_key(self, format_string):
2986
"""Set the default format by its format string."""
2987
self._default_format_key = format_string
2988
self._default_format = None
2985
2991
format_registry = WorkingTreeFormatRegistry()
3015
3021
"""If this format supports missing parent conflicts."""
3024
def find_format_string(klass, a_bzrdir):
3025
"""Return format name for the working tree object in a_bzrdir."""
3027
transport = a_bzrdir.get_workingtree_transport(None)
3028
return transport.get_bytes("format")
3029
except errors.NoSuchFile:
3030
raise errors.NoWorkingTree(base=transport.base)
3018
3033
def find_format(klass, a_bzrdir):
3019
3034
"""Return the format for the working tree object in a_bzrdir."""
3021
transport = a_bzrdir.get_workingtree_transport(None)
3022
format_string = transport.get_bytes("format")
3036
format_string = klass.find_format_string(a_bzrdir)
3023
3037
return format_registry.get(format_string)
3024
except errors.NoSuchFile:
3025
raise errors.NoWorkingTree(base=transport.base)
3026
3038
except KeyError:
3027
3039
raise errors.UnknownFormatError(format=format_string,
3028
3040
kind="working tree")
3252
3264
return self.get_format_string()
3255
__default_format = WorkingTreeFormat6()
3256
3267
format_registry.register_lazy("Bazaar Working Tree Format 4 (bzr 0.15)\n",
3257
3268
"bzrlib.workingtree_4", "WorkingTreeFormat4")
3258
3269
format_registry.register_lazy("Bazaar Working Tree Format 5 (bzr 1.11)\n",
3260
3271
format_registry.register_lazy("Bazaar Working Tree Format 6 (bzr 1.14)\n",
3261
3272
"bzrlib.workingtree_4", "WorkingTreeFormat6")
3262
3273
format_registry.register(WorkingTreeFormat3())
3263
format_registry.set_default(__default_format)
3274
format_registry.set_default_key("Bazaar Working Tree Format 6 (bzr 1.14)\n")