703
703
self.set_parent_ids(parents, allow_leftmost_as_ghost=True)
705
def path_content_summary(self, path, _lstat=osutils.lstat,
706
_mapper=osutils.file_kind_from_stat_mode):
707
"""See Tree.path_content_summary."""
708
abspath = self.abspath(path)
710
stat_result = _lstat(abspath)
712
if getattr(e, 'errno', None) == errno.ENOENT:
714
return ('missing', None, None, None)
715
# propagate other errors
717
kind = _mapper(stat_result.st_mode)
719
size = stat_result.st_size
720
# try for a stat cache lookup
721
if not supports_executable():
722
executable = None # caller can decide policy.
724
mode = stat_result.st_mode
725
executable = bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
726
return (kind, size, executable, self._sha_from_stat(
728
elif kind == 'directory':
729
# perhaps it looks like a plain directory, but it's really a
731
if self._directory_is_tree_reference(path):
732
kind = 'tree-reference'
733
return kind, None, None, None
734
elif kind == 'symlink':
735
return ('symlink', None, None, os.readlink(abspath))
737
return (kind, None, None, None)
705
739
@deprecated_method(zero_eleven)
707
741
def pending_merges(self):
799
833
yield Stanza(file_id=file_id.decode('utf8'), hash=hash)
800
834
self._put_rio('merge-hashes', iter_stanzas(), MERGE_MODIFIED_HEADER_1)
836
def _sha_from_stat(self, path, stat_result):
837
"""Get a sha digest from the tree's stat cache.
839
The default implementation assumes no stat cache is present.
841
:param path: The path.
842
:param stat_result: The stat result being looked up.
802
846
def _put_rio(self, filename, stanzas, header):
803
847
self._must_be_locked()
804
848
my_file = rio_file(stanzas, header)
943
987
other_tree.unlock()
944
988
other_tree.bzrdir.retire_bzrdir()
990
def _directory_is_tree_reference(self, relpath):
991
# as a special case, if a directory contains control files then
992
# it's a tree reference, except that the root of the tree is not
993
return relpath and osutils.isdir(self.abspath(relpath) + u"/.bzr")
994
# TODO: We could ask all the control formats whether they
995
# recognize this directory, but at the moment there's no cheap api
996
# to do that. Since we probably can only nest bzr checkouts and
997
# they always use this name it's ok for now. -- mbp 20060306
999
# FIXME: There is an unhandled case here of a subdirectory
1000
# containing .bzr but not a branch; that will probably blow up
1001
# when you try to commit it. It might happen if there is a
1002
# checkout in a subdirectory. This can be avoided by not adding
946
1005
@needs_tree_write_lock
947
1006
def extract(self, file_id, format=None):
948
1007
"""Extract a subtree from this tree.
997
1056
def _serialize(self, inventory, out_file):
998
xml5.serializer_v5.write_inventory(self._inventory, out_file)
1057
xml5.serializer_v5.write_inventory(self._inventory, out_file,
1000
1060
def _deserialize(selt, in_file):
1001
1061
return xml5.serializer_v5.read_inventory(in_file)
1463
1523
@needs_write_lock
1464
1524
def pull(self, source, overwrite=False, stop_revision=None,
1465
change_reporter=None):
1525
change_reporter=None, possible_transports=None):
1466
1526
top_pb = bzrlib.ui.ui_factory.nested_progress_bar()
1467
1527
source.lock_read()
1470
1530
pp.next_phase()
1471
1531
old_revision_info = self.branch.last_revision_info()
1472
1532
basis_tree = self.basis_tree()
1473
count = self.branch.pull(source, overwrite, stop_revision)
1533
count = self.branch.pull(source, overwrite, stop_revision,
1534
possible_transports=possible_transports)
1474
1535
new_revision_info = self.branch.last_revision_info()
1475
1536
if new_revision_info != old_revision_info:
1476
1537
pp.next_phase()
1903
1964
self.apply_inventory_delta(inv_delta)
1905
1966
@needs_tree_write_lock
1906
def revert(self, filenames, old_tree=None, backups=True,
1967
def revert(self, filenames=None, old_tree=None, backups=True,
1907
1968
pb=DummyProgress(), report_changes=False):
1908
1969
from bzrlib.conflicts import resolve
1972
symbol_versioning.warn('Using [] to revert all files is deprecated'
1973
' as of bzr 0.91. Please use None (the default) instead.',
1974
DeprecationWarning, stacklevel=2)
1909
1975
if old_tree is None:
1910
1976
old_tree = self.basis_tree()
1911
1977
conflicts = transform.revert(self, old_tree, filenames, backups, pb,
1912
1978
report_changes)
1913
if not len(filenames):
1979
if filenames is None:
1914
1980
self.set_parent_ids(self.get_parent_ids()[:1])
2018
2084
raise NotImplementedError(self.unlock)
2020
def update(self, change_reporter=None):
2086
def update(self, change_reporter=None, possible_transports=None):
2021
2087
"""Update a working tree along its branch.
2023
2089
This will update the branch if its bound too, which means we have
2636
2702
sio = StringIO()
2637
2703
inv = Inventory()
2638
xml5.serializer_v5.write_inventory(inv, sio)
2704
xml5.serializer_v5.write_inventory(inv, sio, working=True)
2640
2706
control_files.put('inventory', sio)