14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17
from io import BytesIO
17
from __future__ import absolute_import
101
107
for num, path in enumerate(paths):
102
108
task.update(gettext('Determining hash hits'), num, len(paths))
103
109
hits = self.hitcounts(self.tree.get_file_lines(path))
104
all_hits.extend((v, path, k) for k, v in hits.items())
110
all_hits.extend((v, path, k) for k, v in viewitems(hits))
107
113
def file_match(self, paths):
141
147
required_parents.setdefault(path, []).append(child)
143
for parent, children in required_parents.items():
149
for parent, children in viewitems(required_parents):
144
150
child_file_ids = set()
145
151
for child in children:
146
152
file_id = matches.get(child)
157
163
parent directories.
160
for file_id, file_id_children in missing_parents.items():
161
for path, path_children in required_parents.items():
166
for file_id, file_id_children in viewitems(missing_parents):
167
for path, path_children in viewitems(required_parents):
162
168
hits = len(path_children.intersection(file_id_children))
164
170
all_hits.append((hits, path, file_id))
171
177
with ui_factory.nested_progress_bar() as task:
172
178
iterator = self.tree.iter_changes(basis, want_unversioned=True,
174
for change in iterator:
175
if change.kind[1] is None and change.versioned[1]:
176
if not self.tree.has_filename(
177
self.tree.id2path(change.parent_id[0])):
180
for (file_id, paths, changed_content, versioned, parent, name,
181
kind, executable) in iterator:
182
if kind[1] is None and versioned[1]:
183
if not self.tree.has_filename(self.tree.id2path(parent[0])):
178
184
missing_parents.setdefault(
179
change.parent_id[0], set()).add(change.file_id)
180
if change.kind[0] == 'file':
181
missing_files.add(change.file_id)
185
parent[0], set()).add(file_id)
186
if kind[0] == 'file':
187
missing_files.add(file_id)
183
189
# other kinds are not handled
185
if change.versioned == (False, False):
186
if self.tree.is_ignored(change.path[1]):
191
if versioned == (False, False):
192
if self.tree.is_ignored(paths[1]):
188
if change.kind[1] == 'file':
189
candidate_files.add(change.path[1])
190
if change.kind[1] == 'directory':
191
for _dir, children in self.tree.walkdirs(change.path[1]):
194
if kind[1] == 'file':
195
candidate_files.add(paths[1])
196
if kind[1] == 'directory':
197
for _dir, children in self.tree.walkdirs(paths[1]):
192
198
for child in children:
193
199
if child[2] == 'file':
194
200
candidate_files.add(child[0])
234
240
def _make_inventory_delta(self, matches):
236
file_id_matches = dict((f, p) for p, f in matches.items())
242
file_id_matches = dict((f, p) for p, f in viewitems(matches))
237
243
file_id_query = []
238
for f in matches.values():
244
for f in viewvalues(matches):
240
246
file_id_query.append(self.tree.id2path(f))
241
247
except errors.NoSuchId: