706
706
if self.text_sha1 != None or self.text_size != None or self.text_id != None:
707
707
raise BzrCheckError('symlink {%s} has text in revision {%s}'
708
708
% (self.file_id, rev_id))
709
if self.symlink_target == None:
709
if self.symlink_target is None:
710
710
raise BzrCheckError('symlink {%s} has no target in revision {%s}'
711
711
% (self.file_id, rev_id))
867
867
def iter_entries(self, from_dir=None):
868
868
"""Return (path, entry) pairs, in order by name."""
871
871
from_dir = self.root
872
872
elif isinstance(from_dir, basestring):
906
906
# if we finished all children, pop it off the stack
909
def iter_entries_by_dir(self, from_dir=None):
910
"""Iterate over the entries in a directory first order.
912
This returns all entries for a directory before returning
913
the entries for children of a directory. This is not
914
lexicographically sorted order, and is a hybrid between
915
depth-first and breadth-first.
917
:return: This yields (path, entry) pairs
919
# TODO? Perhaps this should return the from_dir so that the root is
920
# yielded? or maybe an option?
924
elif isinstance(from_dir, basestring):
925
from_dir = self._byid[from_dir]
927
stack = [(u'', from_dir)]
929
cur_relpath, cur_dir = stack.pop()
932
for child_name, child_ie in sorted(cur_dir.children.iteritems()):
934
child_relpath = cur_relpath + child_name
936
yield child_relpath, child_ie
938
if child_ie.kind == 'directory':
939
child_dirs.append((child_relpath+'/', child_ie))
940
stack.extend(reversed(child_dirs))
909
942
def entries(self):
910
943
"""Return list of (path, ie) for all entries except the root.
1029
1062
parent_path = parts[:-1]
1030
1063
parent_id = self.path2id(parent_path)
1031
if parent_id == None:
1064
if parent_id is None:
1032
1065
raise NotVersionedError(path=parent_path)
1033
1066
ie = make_entry(kind, parts[-1], parent_id, file_id)
1034
1067
return self.add(ie)