669
670
def _read_tree_state(self, path, work_tree):
670
671
"""See InventoryEntry._read_tree_state."""
671
self.text_sha1 = work_tree.get_file_sha1(self.file_id)
672
self.executable = work_tree.is_executable(self.file_id)
672
self.text_sha1 = work_tree.get_file_sha1(self.file_id, path=path)
673
self.executable = work_tree.is_executable(self.file_id, path=path)
674
675
def _forget_tree_state(self):
675
676
self.text_sha1 = None
827
828
May also look up by name:
829
830
>>> [x[0] for x in inv.iter_entries()]
831
832
>>> inv = Inventory('TREE_ROOT-12345678-12345678')
832
833
>>> inv.add(InventoryFile('123-123', 'hello.c', ROOT_ID))
833
834
InventoryFile('123-123', 'hello.c', parent_id='TREE_ROOT-12345678-12345678')
880
881
elif isinstance(from_dir, basestring):
881
882
from_dir = self._byid[from_dir]
883
kids = from_dir.children.items()
885
for name, ie in kids:
887
if ie.kind == 'directory':
888
for cn, cie in self.iter_entries(from_dir=ie.file_id):
889
yield pathjoin(name, cn), cie
884
# unrolling the recursive called changed the time from
885
# 440ms/663ms (inline/total) to 116ms/116ms
886
children = from_dir.children.items()
888
children = collections.deque(children)
889
stack = [(u'', children)]
891
from_dir_relpath, children = stack[-1]
894
name, ie = children.popleft()
896
# we know that from_dir_relpath never ends in a slash
897
# and 'f' doesn't begin with one, we can do a string op, rather
898
# than the checks of pathjoin(), though this means that all paths
900
path = from_dir_relpath + '/' + name
904
if ie.kind != 'directory':
907
# But do this child first
908
new_children = ie.children.items()
910
new_children = collections.deque(new_children)
911
stack.append((path, new_children))
912
# Break out of inner loop, so that we start outer loop with child
915
# if we finished all children, pop it off the stack
892
918
def entries(self):
893
919
"""Return list of (path, ie) for all entries except the root.