1351
1357
basis_tree.unlock()
1352
1358
return conflicts
1361
def store_uncommitted(self):
1362
"""Store uncommitted changes from the tree in the branch."""
1363
target_tree = self.basis_tree()
1364
shelf_creator = shelf.ShelfCreator(self, target_tree)
1366
if not shelf_creator.shelve_all():
1368
self.branch.store_uncommitted(shelf_creator)
1369
shelf_creator.transform()
1371
shelf_creator.finalize()
1372
note('Uncommitted changes stored in branch "%s".', self.branch.nick)
1375
def restore_uncommitted(self):
1376
"""Restore uncommitted changes from the branch into the tree."""
1377
unshelver = self.branch.get_unshelver(self)
1378
if unshelver is None:
1381
merger = unshelver.make_merger()
1382
merger.ignore_zero = True
1384
self.branch.store_uncommitted(None)
1386
unshelver.finalize()
1354
1388
def revision_tree(self, revision_id):
1355
1389
"""See Tree.revision_tree.
2374
2409
other_tree.lock_tree_write()
2376
2411
new_parents = other_tree.get_parent_ids()
2377
other_root = other_tree.inventory.root
2412
other_root = other_tree.root_inventory.root
2378
2413
other_root.parent_id = new_root_parent
2379
2414
other_root.name = osutils.basename(other_tree_path)
2380
self.inventory.add(other_root)
2381
add_children(self.inventory, other_root)
2382
self._write_inventory(self.inventory)
2415
self.root_inventory.add(other_root)
2416
add_children(self.root_inventory, other_root)
2417
self._write_inventory(self.root_inventory)
2383
2418
# normally we don't want to fetch whole repositories, but i think
2384
2419
# here we really do want to consolidate the whole thing.
2385
2420
for parent_id in other_tree.get_parent_ids():
2455
2491
raise errors.ObjectNotLocked(self)
2457
2493
if from_dir is None and include_root is True:
2458
yield ('', 'V', 'directory', self.get_root_id(), self.inventory.root)
2494
yield ('', 'V', 'directory', self.get_root_id(), self.root_inventory.root)
2459
2495
# Convert these into local objects to save lookup times
2460
2496
pathjoin = osutils.pathjoin
2461
2497
file_kind = self._kind
3071
3112
def __ne__(self, other):
3072
3113
return not (self == other)
3075
@symbol_versioning.deprecated_method(
3076
symbol_versioning.deprecated_in((2, 4, 0)))
3077
def get_default_format(klass):
3078
"""Return the current default format."""
3079
return format_registry.get_default()
3081
3115
def get_format_description(self):
3082
3116
"""Return the short description for this format."""
3083
3117
raise NotImplementedError(self.get_format_description)
3099
3133
"""True if this format supports stored views."""
3103
@symbol_versioning.deprecated_method(
3104
symbol_versioning.deprecated_in((2, 4, 0)))
3105
def register_format(klass, format):
3106
format_registry.register(format)
3109
@symbol_versioning.deprecated_method(
3110
symbol_versioning.deprecated_in((2, 4, 0)))
3111
def register_extra_format(klass, format):
3112
format_registry.register_extra(format)
3115
@symbol_versioning.deprecated_method(
3116
symbol_versioning.deprecated_in((2, 4, 0)))
3117
def unregister_extra_format(klass, format):
3118
format_registry.unregister_extra(format)
3121
@symbol_versioning.deprecated_method(
3122
symbol_versioning.deprecated_in((2, 4, 0)))
3123
def get_formats(klass):
3124
return format_registry._get_all()
3127
@symbol_versioning.deprecated_method(
3128
symbol_versioning.deprecated_in((2, 4, 0)))
3129
def set_default_format(klass, format):
3130
format_registry.set_default(format)
3133
@symbol_versioning.deprecated_method(
3134
symbol_versioning.deprecated_in((2, 4, 0)))
3135
def unregister_format(klass, format):
3136
format_registry.remove(format)
3136
def get_controldir_for_branch(self):
3137
"""Get the control directory format for creating branches.
3139
This is to support testing of working tree formats that can not exist
3140
in the same control directory as a branch.
3142
return self._matchingbzrdir
3145
class WorkingTreeFormatMetaDir(bzrdir.BzrFormat, WorkingTreeFormat):
3146
"""Base class for working trees that live in bzr meta directories."""
3149
WorkingTreeFormat.__init__(self)
3150
bzrdir.BzrFormat.__init__(self)
3153
def find_format_string(klass, controldir):
3154
"""Return format name for the working tree object in controldir."""
3156
transport = controldir.get_workingtree_transport(None)
3157
return transport.get_bytes("format")
3158
except errors.NoSuchFile:
3159
raise errors.NoWorkingTree(base=transport.base)
3162
def find_format(klass, controldir):
3163
"""Return the format for the working tree object in controldir."""
3164
format_string = klass.find_format_string(controldir)
3165
return klass._find_format(format_registry, 'working tree',
3168
def check_support_status(self, allow_unsupported, recommend_upgrade=True,
3170
WorkingTreeFormat.check_support_status(self,
3171
allow_unsupported=allow_unsupported, recommend_upgrade=recommend_upgrade,
3173
bzrdir.BzrFormat.check_support_status(self, allow_unsupported=allow_unsupported,
3174
recommend_upgrade=recommend_upgrade, basedir=basedir)
3138
3176
def get_controldir_for_branch(self):
3139
3177
"""Get the control directory format for creating branches.