703
703
self.set_parent_ids(parents, allow_leftmost_as_ghost=True)
705
def path_content_summary(self, path, _lstat=os.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
# propogate 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
sha1 = None # 'stat-hit-check' here
727
return (kind, size, executable, sha1)
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):
943
977
other_tree.unlock()
944
978
other_tree.bzrdir.retire_bzrdir()
980
def _directory_is_tree_reference(self, relpath):
981
# as a special case, if a directory contains control files then
982
# it's a tree reference, except that the root of the tree is not
983
return relpath and osutils.isdir(self.abspath(relpath) + u"/.bzr")
984
# TODO: We could ask all the control formats whether they
985
# recognize this directory, but at the moment there's no cheap api
986
# to do that. Since we probably can only nest bzr checkouts and
987
# they always use this name it's ok for now. -- mbp 20060306
989
# FIXME: There is an unhandled case here of a subdirectory
990
# containing .bzr but not a branch; that will probably blow up
991
# when you try to commit it. It might happen if there is a
992
# checkout in a subdirectory. This can be avoided by not adding
946
995
@needs_tree_write_lock
947
996
def extract(self, file_id, format=None):
948
997
"""Extract a subtree from this tree.