54
55
self.lockable_thing = lockable_thing
57
return ('ReturnsUnlockable(lockable_thing=%s)' %
58
return ('ReturnsUnlockable(lockable_thing=%s)' %
58
59
self.lockable_thing)
60
61
def match(self, lock_method):
131
132
"""Get the (path, file_id) pairs for the current tree."""
134
return [(path, ie.file_id) for path, ie
135
in tree.iter_entries_by_dir()]
135
for path, ie in tree.iter_entries_by_dir():
136
if ie.parent_id is None:
137
yield (u"", ie.file_id)
139
yield (path+ie.kind_character(), ie.file_id)
144
def _strip_unreferenced_directories(entries):
145
"""Strip all directories that don't (in)directly contain any files.
147
:param entries: List of path strings or (path, ie) tuples to process
150
for entry in entries:
151
if isinstance(entry, basestring):
155
if not path or path[-1] == "/":
157
directories.append((path, entry))
159
# Yield the referenced parent directories
160
for dirpath, direntry in directories:
161
if osutils.is_inside(dirpath, path):
139
166
def __str__(self):
140
return ('HasLayout(%r)' % self.entries)
167
return 'HasLayout(%r)' % self.entries
142
169
def match(self, tree):
143
actual = self.get_tree_layout(tree)
170
actual = list(self.get_tree_layout(tree))
144
171
if self.entries and isinstance(self.entries[0], basestring):
145
172
actual = [path for (path, fileid) in actual]
146
return Equals(actual).match(self.entries)
173
if not tree.has_versioned_directories():
174
entries = list(self._strip_unreferenced_directories(self.entries))
176
entries = self.entries
177
return Equals(entries).match(actual)