Merge lp:~jelmer/brz/walkdirs-no-file-id into lp:brz/3.1
- walkdirs-no-file-id
- Merge into 3.1
Proposed by
Jelmer Vernooij
Status: | Merged |
---|---|
Approved by: | Jelmer Vernooij |
Approved revision: | no longer in the source branch. |
Merge reported by: | The Breezy Bot |
Merged at revision: | not available |
Proposed branch: | lp:~jelmer/brz/walkdirs-no-file-id |
Merge into: | lp:brz/3.1 |
Diff against target: |
682 lines (+125/-178) 13 files modified
breezy/bzr/inventorytree.py (+11/-12) breezy/bzr/transform.py (+2/-2) breezy/bzr/workingtree.py (+12/-15) breezy/bzr/workingtree_4.py (+6/-7) breezy/git/tree.py (+5/-6) breezy/git/workingtree.py (+12/-13) breezy/tests/per_tree/test_transform.py (+1/-2) breezy/tests/per_tree/test_walkdirs.py (+34/-43) breezy/tests/per_workingtree/test_walkdirs.py (+31/-67) breezy/tests/per_workingtree/test_workingtree.py (+4/-4) breezy/tree.py (+2/-5) breezy/workingtree.py (+2/-2) doc/en/release-notes/brz-3.1.txt (+3/-0) |
To merge this branch: | bzr merge lp:~jelmer/brz/walkdirs-no-file-id |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jelmer Vernooij | Approve | ||
Review via email:
|
Commit message
Drop file ids from the Tree.walkdirs API.
Description of the change
Drop file ids from the Tree.walkdirs API.
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jelmer Vernooij (jelmer) : | # |
review:
Approve
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
The Breezy Bot (the-breezy-bot) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'breezy/bzr/inventorytree.py' |
2 | --- breezy/bzr/inventorytree.py 2020-08-06 00:53:48 +0000 |
3 | +++ breezy/bzr/inventorytree.py 2020-08-06 22:38:17 +0000 |
4 | @@ -957,27 +957,26 @@ |
5 | if top_id is None: |
6 | pending = [] |
7 | else: |
8 | - pending = [(prefix, '', _directory, None, top_id, None)] |
9 | + pending = [(prefix, top_id)] |
10 | while pending: |
11 | dirblock = [] |
12 | - currentdir = pending.pop() |
13 | - # 0 - relpath, 1- basename, 2- kind, 3- stat, id, v-kind |
14 | - if currentdir[0]: |
15 | - relroot = currentdir[0] + '/' |
16 | + root, file_id = pending.pop() |
17 | + if root: |
18 | + relroot = root + '/' |
19 | else: |
20 | relroot = "" |
21 | # FIXME: stash the node in pending |
22 | - entry = inv.get_entry(currentdir[4]) |
23 | + entry = inv.get_entry(file_id) |
24 | + subdirs = [] |
25 | for name, child in entry.sorted_children(): |
26 | toppath = relroot + name |
27 | dirblock.append((toppath, name, child.kind, None, |
28 | - child.file_id, child.kind |
29 | - )) |
30 | - yield (currentdir[0], entry.file_id), dirblock |
31 | + child.kind)) |
32 | + if child.kind == _directory: |
33 | + subdirs.append((toppath, child.file_id)) |
34 | + yield root, dirblock |
35 | # push the user specified dirs from dirblock |
36 | - for dir in reversed(dirblock): |
37 | - if dir[2] == _directory: |
38 | - pending.append(dir) |
39 | + pending.extend(reversed(subdirs)) |
40 | |
41 | def iter_files_bytes(self, desired_files): |
42 | """See Tree.iter_files_bytes. |
43 | |
44 | === modified file 'breezy/bzr/transform.py' |
45 | --- breezy/bzr/transform.py 2020-08-06 01:40:59 +0000 |
46 | +++ breezy/bzr/transform.py 2020-08-06 22:38:17 +0000 |
47 | @@ -2121,10 +2121,10 @@ |
48 | if versioned_kind == 'directory': |
49 | subdirs.append(child_id) |
50 | children.append((path_from_root, basename, kind, None, |
51 | - file_id, versioned_kind)) |
52 | + versioned_kind)) |
53 | children.sort() |
54 | if parent_path.startswith(prefix): |
55 | - yield (parent_path, parent_file_id), children |
56 | + yield parent_path, children |
57 | pending.extend(sorted(subdirs, key=self._final_paths.get_path, |
58 | reverse=True)) |
59 | |
60 | |
61 | === modified file 'breezy/bzr/workingtree.py' |
62 | --- breezy/bzr/workingtree.py 2020-07-04 12:29:00 +0000 |
63 | +++ breezy/bzr/workingtree.py 2020-08-06 22:38:17 +0000 |
64 | @@ -408,8 +408,8 @@ |
65 | def recurse_directory_to_add_files(directory): |
66 | # Recurse directory and add all files |
67 | # so we can check if they have changed. |
68 | - for parent_info, file_infos in self.walkdirs(directory): |
69 | - for relpath, basename, kind, lstat, fileid, kind in file_infos: |
70 | + for parent_path, file_infos in self.walkdirs(directory): |
71 | + for relpath, basename, kind, lstat, kind in file_infos: |
72 | # Is it versioned or ignored? |
73 | if self.is_versioned(relpath): |
74 | # Add nested content for deletion. |
75 | @@ -1567,8 +1567,8 @@ |
76 | """Walk the directories of this tree. |
77 | |
78 | returns a generator which yields items in the form: |
79 | - ((curren_directory_path, fileid), |
80 | - [(file1_path, file1_name, file1_kind, (lstat), file1_id, |
81 | + (current_directory_path, |
82 | + [(file1_path, file1_name, file1_kind, (lstat), |
83 | file1_kind), ... ]) |
84 | |
85 | This API returns a generator, which is only valid during the current |
86 | @@ -1631,20 +1631,20 @@ |
87 | |
88 | if direction > 0: |
89 | # disk is before inventory - unknown |
90 | - dirblock = [(relpath, basename, kind, stat, None, None) for |
91 | + dirblock = [(relpath, basename, kind, stat, None) for |
92 | relpath, basename, kind, stat, top_path in |
93 | cur_disk_dir_content] |
94 | - yield (cur_disk_dir_relpath, None), dirblock |
95 | + yield cur_disk_dir_relpath, dirblock |
96 | try: |
97 | current_disk = next(disk_iterator) |
98 | except StopIteration: |
99 | disk_finished = True |
100 | elif direction < 0: |
101 | # inventory is before disk - missing. |
102 | - dirblock = [(relpath, basename, 'unknown', None, fileid, kind) |
103 | + dirblock = [(relpath, basename, 'unknown', None, kind) |
104 | for relpath, basename, dkind, stat, fileid, kind in |
105 | current_inv[1]] |
106 | - yield (current_inv[0][0], current_inv[0][1]), dirblock |
107 | + yield current_inv[0][0], dirblock |
108 | try: |
109 | current_inv = next(inventory_iterator) |
110 | except StopIteration: |
111 | @@ -1662,23 +1662,20 @@ |
112 | # versioned, present file |
113 | dirblock.append((inv_row[0], |
114 | inv_row[1], disk_row[2], |
115 | - disk_row[3], inv_row[4], |
116 | - inv_row[5])) |
117 | + disk_row[3], inv_row[5])) |
118 | elif len(path_elements[0]) == 5: |
119 | # unknown disk file |
120 | dirblock.append( |
121 | (path_elements[0][0], path_elements[0][1], |
122 | - path_elements[0][2], path_elements[0][3], None, |
123 | - None)) |
124 | + path_elements[0][2], path_elements[0][3], None)) |
125 | elif len(path_elements[0]) == 6: |
126 | # versioned, absent file. |
127 | dirblock.append( |
128 | (path_elements[0][0], path_elements[0][1], |
129 | - 'unknown', None, path_elements[0][4], |
130 | - path_elements[0][5])) |
131 | + 'unknown', None, path_elements[0][5])) |
132 | else: |
133 | raise NotImplementedError('unreachable code') |
134 | - yield current_inv[0], dirblock |
135 | + yield current_inv[0][0], dirblock |
136 | try: |
137 | current_inv = next(inventory_iterator) |
138 | except StopIteration: |
139 | |
140 | === modified file 'breezy/bzr/workingtree_4.py' |
141 | --- breezy/bzr/workingtree_4.py 2020-06-17 01:18:14 +0000 |
142 | +++ breezy/bzr/workingtree_4.py 2020-08-06 22:38:17 +0000 |
143 | @@ -2162,16 +2162,15 @@ |
144 | relroot = "" |
145 | # FIXME: stash the node in pending |
146 | entry = inv.get_entry(file_id) |
147 | + subdirs = [] |
148 | for name, child in entry.sorted_children(): |
149 | toppath = relroot + name |
150 | - dirblock.append((toppath, name, child.kind, None, |
151 | - child.file_id, child.kind |
152 | - )) |
153 | - yield (relpath, entry.file_id), dirblock |
154 | + dirblock.append((toppath, name, child.kind, None, child.kind)) |
155 | + if child.kind == _directory: |
156 | + subdirs.append((toppath, child.file_id)) |
157 | + yield relpath, dirblock |
158 | # push the user specified dirs from dirblock |
159 | - for dir in reversed(dirblock): |
160 | - if dir[2] == _directory: |
161 | - pending.append((dir[0], dir[4])) |
162 | + pending.extend(reversed(subdirs)) |
163 | |
164 | |
165 | class InterDirStateTree(InterInventoryTree): |
166 | |
167 | === modified file 'breezy/git/tree.py' |
168 | --- breezy/git/tree.py 2020-08-06 01:40:59 +0000 |
169 | +++ breezy/git/tree.py 2020-08-06 22:38:17 +0000 |
170 | @@ -706,9 +706,9 @@ |
171 | def walkdirs(self, prefix=u""): |
172 | (store, mode, hexsha) = self._lookup_path(prefix) |
173 | todo = deque( |
174 | - [(store, encode_git_path(prefix), hexsha, self.path2id(prefix))]) |
175 | + [(store, encode_git_path(prefix), hexsha)]) |
176 | while todo: |
177 | - store, path, tree_sha, parent_id = todo.popleft() |
178 | + store, path, tree_sha = todo.popleft() |
179 | path_decoded = decode_git_path(path) |
180 | tree = store[tree_sha] |
181 | children = [] |
182 | @@ -716,14 +716,13 @@ |
183 | if self.mapping.is_special_file(name): |
184 | continue |
185 | child_path = posixpath.join(path, name) |
186 | - file_id = self.path2id(decode_git_path(child_path)) |
187 | if stat.S_ISDIR(mode): |
188 | - todo.append((store, child_path, hexsha, file_id)) |
189 | + todo.append((store, child_path, hexsha)) |
190 | children.append( |
191 | (decode_git_path(child_path), decode_git_path(name), |
192 | mode_kind(mode), None, |
193 | - file_id, mode_kind(mode))) |
194 | - yield (path_decoded, parent_id), children |
195 | + mode_kind(mode))) |
196 | + yield path_decoded, children |
197 | |
198 | def preview_transform(self, pb=None): |
199 | from .transform import GitTransformPreview |
200 | |
201 | === modified file 'breezy/git/workingtree.py' |
202 | --- breezy/git/workingtree.py 2020-07-05 12:50:01 +0000 |
203 | +++ breezy/git/workingtree.py 2020-08-06 22:38:17 +0000 |
204 | @@ -333,8 +333,8 @@ |
205 | def recurse_directory_to_add_files(directory): |
206 | # Recurse directory and add all files |
207 | # so we can check if they have changed. |
208 | - for parent_info, file_infos in self.walkdirs(directory): |
209 | - for relpath, basename, kind, lstat, fileid, kind in file_infos: |
210 | + for parent_path, file_infos in self.walkdirs(directory): |
211 | + for relpath, basename, kind, lstat, kind in file_infos: |
212 | # Is it versioned or ignored? |
213 | if self.is_versioned(relpath): |
214 | # Add nested content for deletion. |
215 | @@ -912,8 +912,8 @@ |
216 | """Walk the directories of this tree. |
217 | |
218 | returns a generator which yields items in the form: |
219 | - ((curren_directory_path, fileid), |
220 | - [(file1_path, file1_name, file1_kind, (lstat), file1_id, |
221 | + (current_directory_path, |
222 | + [(file1_path, file1_name, file1_kind, (lstat), |
223 | file1_kind), ... ]) |
224 | |
225 | This API returns a generator, which is only valid during the current |
226 | @@ -977,20 +977,20 @@ |
227 | - (current_inv[0][0] < cur_disk_dir_relpath)) |
228 | if direction > 0: |
229 | # disk is before inventory - unknown |
230 | - dirblock = [(relpath, basename, kind, stat, None, None) for |
231 | + dirblock = [(relpath, basename, kind, stat, None) for |
232 | relpath, basename, kind, stat, top_path in |
233 | cur_disk_dir_content] |
234 | - yield (cur_disk_dir_relpath, None), dirblock |
235 | + yield cur_disk_dir_relpath, dirblock |
236 | try: |
237 | current_disk = next(disk_iterator) |
238 | except StopIteration: |
239 | disk_finished = True |
240 | elif direction < 0: |
241 | # inventory is before disk - missing. |
242 | - dirblock = [(relpath, basename, 'unknown', None, fileid, kind) |
243 | + dirblock = [(relpath, basename, 'unknown', None, kind) |
244 | for relpath, basename, dkind, stat, fileid, kind in |
245 | current_inv[1]] |
246 | - yield (current_inv[0][0], current_inv[0][1]), dirblock |
247 | + yield current_inv[0][0], dirblock |
248 | try: |
249 | current_inv = next(inventory_iterator) |
250 | except StopIteration: |
251 | @@ -1008,23 +1008,22 @@ |
252 | # versioned, present file |
253 | dirblock.append((inv_row[0], |
254 | inv_row[1], disk_row[2], |
255 | - disk_row[3], inv_row[4], |
256 | - inv_row[5])) |
257 | + disk_row[3], inv_row[5])) |
258 | elif len(path_elements[0]) == 5: |
259 | # unknown disk file |
260 | dirblock.append( |
261 | (path_elements[0][0], path_elements[0][1], |
262 | path_elements[0][2], path_elements[0][3], |
263 | - None, None)) |
264 | + None)) |
265 | elif len(path_elements[0]) == 6: |
266 | # versioned, absent file. |
267 | dirblock.append( |
268 | (path_elements[0][0], path_elements[0][1], |
269 | - 'unknown', None, path_elements[0][4], |
270 | + 'unknown', None, |
271 | path_elements[0][5])) |
272 | else: |
273 | raise NotImplementedError('unreachable code') |
274 | - yield current_inv[0], dirblock |
275 | + yield current_inv[0][0], dirblock |
276 | try: |
277 | current_inv = next(inventory_iterator) |
278 | except StopIteration: |
279 | |
280 | === modified file 'breezy/tests/per_tree/test_transform.py' |
281 | --- breezy/tests/per_tree/test_transform.py 2020-07-06 01:43:04 +0000 |
282 | +++ breezy/tests/per_tree/test_transform.py 2020-08-06 22:38:17 +0000 |
283 | @@ -610,8 +610,7 @@ |
284 | preview.fixup_new_roots() |
285 | preview_tree = preview.get_preview_tree() |
286 | preview.new_file('a', preview.root, [b'contents'], b'a-id') |
287 | - expected = [(('', b'tree-root'), |
288 | - [('a', 'a', 'file', None, b'a-id', 'file')])] |
289 | + expected = [('', [('a', 'a', 'file', None, 'file')])] |
290 | self.assertEqual(expected, list(preview_tree.walkdirs())) |
291 | |
292 | def test_extras(self): |
293 | |
294 | === modified file 'breezy/tests/per_tree/test_walkdirs.py' |
295 | --- breezy/tests/per_tree/test_walkdirs.py 2018-11-11 04:08:32 +0000 |
296 | +++ breezy/tests/per_tree/test_walkdirs.py 2020-08-06 22:38:17 +0000 |
297 | @@ -33,48 +33,42 @@ |
298 | dirblocks = {} |
299 | |
300 | dirblocks[''] = [ |
301 | - ('0file', '0file', 'file', None, |
302 | - tree.path2id('0file'), 'file'), |
303 | - ('1top-dir', '1top-dir', 'directory', None, |
304 | - tree.path2id('1top-dir'), 'directory'), |
305 | - (u'2utf\u1234file', u'2utf\u1234file', 'file', None, |
306 | - tree.path2id(u'2utf\u1234file'), 'file')] |
307 | + ('0file', '0file', 'file', None, 'file'), |
308 | + ('1top-dir', '1top-dir', 'directory', None, 'directory'), |
309 | + (u'2utf\u1234file', u'2utf\u1234file', 'file', None, 'file')] |
310 | |
311 | dirblocks['1top-dir'] = [ |
312 | ('1top-dir/0file-in-1topdir', '0file-in-1topdir', |
313 | - 'file', None, tree.path2id('1top-dir/0file-in-1topdir'), 'file')] |
314 | + 'file', None, 'file')] |
315 | if empty_dirs_present: |
316 | dirblocks['1top-dir'].append( |
317 | ('1top-dir/1dir-in-1topdir', '1dir-in-1topdir', 'directory', |
318 | None if empty_dirs_are_versioned else os.stat( |
319 | tree.abspath('1top-dir/1dir-in-1topdir')), |
320 | - tree.path2id('1top-dir/1dir-in-1topdir'), |
321 | 'directory' if empty_dirs_are_versioned else None)) |
322 | dirblocks['1top-dir/1dir-in-1topdir'] = [] |
323 | if symlinks: |
324 | dirblocks[''].append( |
325 | - ('symlink', 'symlink', 'symlink', None, |
326 | - tree.path2id('symlink'), 'symlink')) |
327 | - return [((path, tree.path2id(path)), list(sorted(entries))) |
328 | + ('symlink', 'symlink', 'symlink', None, 'symlink')) |
329 | + return [(path, list(sorted(entries))) |
330 | for (path, entries) in sorted(dirblocks.items())] |
331 | |
332 | def test_walkdir_root(self): |
333 | tree = self.get_tree_with_subdirs_and_all_supported_content_types( |
334 | has_symlinks()) |
335 | - tree.lock_read() |
336 | - expected_dirblocks = self.get_all_subdirs_expected( |
337 | - tree, has_symlinks()) |
338 | - # test that its iterable by iterating |
339 | - result = [] |
340 | - for dirinfo, block in tree.walkdirs(): |
341 | - newblock = [] |
342 | - for row in block: |
343 | - if row[4] is not None: |
344 | - newblock.append(row[0:3] + (None,) + row[4:]) |
345 | - else: |
346 | - newblock.append(row) |
347 | - result.append((dirinfo, newblock)) |
348 | - tree.unlock() |
349 | + with tree.lock_read(): |
350 | + expected_dirblocks = self.get_all_subdirs_expected( |
351 | + tree, has_symlinks()) |
352 | + # test that its iterable by iterating |
353 | + result = [] |
354 | + for dirinfo, block in tree.walkdirs(): |
355 | + newblock = [] |
356 | + for row in block: |
357 | + if row[4] is not None: |
358 | + newblock.append(row[0:3] + (None,) + row[4:]) |
359 | + else: |
360 | + newblock.append(row) |
361 | + result.append((dirinfo, newblock)) |
362 | # check each return value for debugging ease. |
363 | for pos, item in enumerate(expected_dirblocks): |
364 | self.assertEqual(item, result[pos]) |
365 | @@ -85,18 +79,17 @@ |
366 | has_symlinks()) |
367 | # test that its iterable by iterating |
368 | result = [] |
369 | - tree.lock_read() |
370 | - expected_dirblocks = self.get_all_subdirs_expected( |
371 | - tree, has_symlinks())[1:] |
372 | - for dirinfo, block in tree.walkdirs('1top-dir'): |
373 | - newblock = [] |
374 | - for row in block: |
375 | - if row[4] is not None: |
376 | - newblock.append(row[0:3] + (None,) + row[4:]) |
377 | - else: |
378 | - newblock.append(row) |
379 | - result.append((dirinfo, newblock)) |
380 | - tree.unlock() |
381 | + with tree.lock_read(): |
382 | + expected_dirblocks = self.get_all_subdirs_expected( |
383 | + tree, has_symlinks())[1:] |
384 | + for dirinfo, block in tree.walkdirs('1top-dir'): |
385 | + newblock = [] |
386 | + for row in block: |
387 | + if row[4] is not None: |
388 | + newblock.append(row[0:3] + (None,) + row[4:]) |
389 | + else: |
390 | + newblock.append(row) |
391 | + result.append((dirinfo, newblock)) |
392 | # check each return value for debugging ease. |
393 | for pos, item in enumerate(expected_dirblocks): |
394 | self.assertEqual(item, result[pos]) |
395 | @@ -106,8 +99,6 @@ |
396 | work_tree = self.make_branch_and_tree('tree') |
397 | self.build_tree(['tree/file', 'tree/dir/']) |
398 | work_tree.add(['file', 'dir']) |
399 | - file_id = work_tree.path2id('file') |
400 | - dir_id = work_tree.path2id('dir') |
401 | os.unlink('tree/file') |
402 | os.rmdir('tree/dir') |
403 | tree = self._convert_tree(work_tree) |
404 | @@ -116,10 +107,10 @@ |
405 | if tree.path2id('file') is None: |
406 | raise tests.TestNotApplicable( |
407 | 'Tree type cannot represent dangling ids.') |
408 | - expected = [(('', work_tree.path2id('')), ([ |
409 | - ('dir', 'dir', 'unknown', None, dir_id, 'directory')] |
410 | + expected = [('', ([ |
411 | + ('dir', 'dir', 'unknown', None, 'directory')] |
412 | if tree.has_versioned_directories() else []) + |
413 | - [('file', 'file', 'unknown', None, file_id, 'file')])] |
414 | + [('file', 'file', 'unknown', None, 'file')])] |
415 | if tree.has_versioned_directories(): |
416 | - expected.append((('dir', dir_id), [])) |
417 | + expected.append(('dir', [])) |
418 | self.assertEqual(expected, list(tree.walkdirs())) |
419 | |
420 | === modified file 'breezy/tests/per_workingtree/test_walkdirs.py' |
421 | --- breezy/tests/per_workingtree/test_walkdirs.py 2020-07-04 12:29:00 +0000 |
422 | +++ breezy/tests/per_workingtree/test_walkdirs.py 2020-08-06 22:38:17 +0000 |
423 | @@ -28,7 +28,7 @@ |
424 | class DirBlock: |
425 | """Object representation of the tuples returned by dirstate.""" |
426 | |
427 | - def __init__(self, tree, file_path, file_name=None, id=None, |
428 | + def __init__(self, tree, file_path, file_name=None, |
429 | inventory_kind=None, stat=None, disk_kind='unknown'): |
430 | self.file_path = file_path |
431 | self.abspath = tree.abspath(file_path) |
432 | @@ -38,17 +38,16 @@ |
433 | if len(file_name) == 0: |
434 | file_name = os.path.split(file_path)[-2] |
435 | self.file_name = file_name |
436 | - self.id = id |
437 | self.inventory_kind = inventory_kind |
438 | self.stat = stat |
439 | self.disk_kind = disk_kind |
440 | |
441 | def as_tuple(self): |
442 | return (self.relpath, self.file_name, self.disk_kind, |
443 | - self.stat, self.id, self.inventory_kind) |
444 | + self.stat, self.inventory_kind) |
445 | |
446 | def as_dir_tuple(self): |
447 | - return (self.relpath, self.id) |
448 | + return self.relpath |
449 | |
450 | def __str__(self): |
451 | return """ |
452 | @@ -56,11 +55,10 @@ |
453 | abspath = %r |
454 | relpath = %r |
455 | file_name = %r |
456 | -id = %r |
457 | inventory_kind = %r |
458 | stat = %r |
459 | disk_kind = %r""" % (self.file_path, self.abspath, self.relpath, |
460 | - self.file_name, self.id, self.inventory_kind, self.stat, |
461 | + self.file_name, self.inventory_kind, self.stat, |
462 | self.disk_kind) |
463 | |
464 | |
465 | @@ -97,9 +95,6 @@ |
466 | |
467 | if file_status != self.unknown: |
468 | tree.add(paths) |
469 | - for dirblock in dirblocks: |
470 | - if file_status != self.unknown: |
471 | - dirblock.id = tree.path2id(dirblock.relpath) |
472 | |
473 | if file_status == self.missing: |
474 | # now make the files be missing |
475 | @@ -108,7 +103,7 @@ |
476 | tree.controldir.root_transport.delete_tree(dirblocks[3].relpath) |
477 | |
478 | expected_dirblocks = [ |
479 | - (('', tree.path2id('')), |
480 | + ('', |
481 | [dirblocks[1].as_tuple()] + |
482 | ([dirblocks[3].as_tuple()] |
483 | if (tree.has_versioned_directories() or file_status == self.unknown) else []) + |
484 | @@ -120,22 +115,18 @@ |
485 | ] |
486 | if (tree.has_versioned_directories() or |
487 | file_status != self.missing): |
488 | - expected_dirblocks.append( |
489 | - (dirblocks[3].as_dir_tuple(), |
490 | - [] |
491 | - )) |
492 | + expected_dirblocks.append((dirblocks[3].as_dir_tuple(), [])) |
493 | if prefix: |
494 | expected_dirblocks = [e for e in expected_dirblocks |
495 | - if len(e) > 0 and len(e[0]) > 0 and e[0][0] == prefix] |
496 | + if len(e) > 0 and len(e[0]) > 0 and e[0] == prefix] |
497 | return tree, expected_dirblocks |
498 | |
499 | def _test_walkdir(self, file_status, prefix=""): |
500 | result = [] |
501 | tree, expected_dirblocks = self.get_tree(file_status, prefix) |
502 | - tree.lock_read() |
503 | - for dirinfo, dirblock in tree.walkdirs(prefix): |
504 | - result.append((dirinfo, list(dirblock))) |
505 | - tree.unlock() |
506 | + with tree.lock_read(): |
507 | + for dirpath, dirblock in tree.walkdirs(prefix): |
508 | + result.append((dirpath, list(dirblock))) |
509 | |
510 | # check each return value for debugging ease. |
511 | for pos, item in enumerate(expected_dirblocks): |
512 | @@ -200,40 +191,25 @@ |
513 | link1_stat = os.lstat('link1') |
514 | link2_stat = os.lstat('link2') |
515 | expected_dirblocks = [ |
516 | - (('', tree.path2id('')), |
517 | - [('dir1', 'dir1', 'file', dir1_stat, tree.path2id('dir1'), |
518 | + ('', |
519 | + [('dir1', 'dir1', 'file', dir1_stat, |
520 | 'directory' if tree.has_versioned_directories() else None), |
521 | - ('dir2', 'dir2', 'symlink', dir2_stat, tree.path2id('dir2'), |
522 | + ('dir2', 'dir2', 'symlink', dir2_stat, |
523 | 'directory' if tree.has_versioned_directories() else None), |
524 | ('file1', 'file1', 'directory', file1_stat, |
525 | - tree.path2id('file1'), 'file'), |
526 | - ('file2', 'file2', 'symlink', file2_stat, |
527 | - tree.path2id('file2'), 'file'), |
528 | - ('link1', 'link1', 'file', link1_stat, |
529 | - tree.path2id('link1'), 'symlink'), |
530 | - ('link2', 'link2', 'directory', link2_stat, |
531 | - tree.path2id('link2'), 'symlink'), |
532 | + 'file'), |
533 | + ('file2', 'file2', 'symlink', file2_stat, 'file'), |
534 | + ('link1', 'link1', 'file', link1_stat, 'symlink'), |
535 | + ('link2', 'link2', 'directory', link2_stat, 'symlink'), |
536 | ] |
537 | )] |
538 | if tree.has_versioned_directories(): |
539 | expected_dirblocks.extend([ |
540 | - (('dir1', tree.path2id('dir1')), |
541 | - [ |
542 | - ] |
543 | - ), |
544 | - (('dir2', tree.path2id('dir2')), |
545 | - [ |
546 | - ] |
547 | - )]) |
548 | + ('dir1', []), |
549 | + ('dir2', [])]) |
550 | expected_dirblocks.extend([ |
551 | - (('file1', None), |
552 | - [ |
553 | - ] |
554 | - ), |
555 | - (('link2', None), |
556 | - [ |
557 | - ] |
558 | - ), |
559 | + ('file1', []), |
560 | + ('link2', []), |
561 | ]) |
562 | with tree.lock_read(): |
563 | result = list(tree.walkdirs()) |
564 | @@ -257,33 +233,21 @@ |
565 | file1_stat = os.lstat('file1') |
566 | if tree.has_versioned_directories(): |
567 | expected_dirblocks = [ |
568 | - (('', tree.path2id('')), |
569 | - [('dir1', 'dir1', 'file', dir1_stat, tree.path2id('dir1'), 'directory'), |
570 | - ('file1', 'file1', 'directory', file1_stat, |
571 | - tree.path2id('file1'), 'file'), |
572 | - ] |
573 | - ), |
574 | - (('dir1', tree.path2id('dir1')), |
575 | - [ |
576 | - ] |
577 | - ), |
578 | - (('file1', None), |
579 | - [ |
580 | - ] |
581 | - ), |
582 | + ('', |
583 | + [('dir1', 'dir1', 'file', dir1_stat, 'directory'), |
584 | + ('file1', 'file1', 'directory', file1_stat, 'file'), |
585 | + ]), |
586 | + ('dir1', []), |
587 | + ('file1', []), |
588 | ] |
589 | else: |
590 | expected_dirblocks = [ |
591 | - (('', tree.path2id('')), |
592 | - [('dir1', 'dir1', 'file', dir1_stat, tree.path2id('dir1'), None), |
593 | - ('file1', 'file1', 'directory', file1_stat, |
594 | - tree.path2id('file1'), 'file'), |
595 | + ('', |
596 | + [('dir1', 'dir1', 'file', dir1_stat, None), |
597 | + ('file1', 'file1', 'directory', file1_stat, 'file'), |
598 | ] |
599 | ), |
600 | - (('file1', None), |
601 | - [ |
602 | - ] |
603 | - ), |
604 | + ('file1', []), |
605 | ] |
606 | with tree.lock_read(): |
607 | result = list(tree.walkdirs()) |
608 | |
609 | === modified file 'breezy/tests/per_workingtree/test_workingtree.py' |
610 | --- breezy/tests/per_workingtree/test_workingtree.py 2020-07-04 12:29:00 +0000 |
611 | +++ breezy/tests/per_workingtree/test_workingtree.py 2020-08-06 22:38:17 +0000 |
612 | @@ -931,11 +931,11 @@ |
613 | present_stat = os.lstat('present') |
614 | unknown_stat = os.lstat('unknown') |
615 | expected_results = [ |
616 | - (('', tree.path2id('')), |
617 | - [('missing', 'missing', 'unknown', None, b'missing-id', 'file'), |
618 | + ('', |
619 | + [('missing', 'missing', 'unknown', None, 'file'), |
620 | ('present', 'present', 'file', |
621 | - present_stat, b'present-id', 'file'), |
622 | - ('unknown', 'unknown', 'file', unknown_stat, None, None), |
623 | + present_stat, 'file'), |
624 | + ('unknown', 'unknown', 'file', unknown_stat, None), |
625 | ] |
626 | )] |
627 | self.assertEqual(expected_results, list(tree.walkdirs())) |
628 | |
629 | === modified file 'breezy/tree.py' |
630 | --- breezy/tree.py 2020-08-06 01:40:59 +0000 |
631 | +++ breezy/tree.py 2020-08-06 22:38:17 +0000 |
632 | @@ -638,12 +638,10 @@ |
633 | list to exclude some directories, they are then not descended into. |
634 | |
635 | The data yielded is of the form: |
636 | - ((directory-relpath, directory-path-from-root, directory-fileid), |
637 | - [(relpath, basename, kind, lstat, path_from_tree_root, file_id, |
638 | + (directory-relpath, |
639 | + [(relpath, basename, kind, lstat, path_from_tree_root, |
640 | versioned_kind), ...]), |
641 | - - directory-relpath is the containing dirs relpath from prefix |
642 | - directory-path-from-root is the containing dirs path from / |
643 | - - directory-fileid is the id of the directory if it is versioned. |
644 | - relpath is the relative path within the subtree being walked. |
645 | - basename is the basename |
646 | - kind is the kind of the file now. If unknonwn then the file is not |
647 | @@ -651,7 +649,6 @@ |
648 | versioned_kind. |
649 | - lstat is the stat data *if* the file was statted. |
650 | - path_from_tree_root is the path from the root of the tree. |
651 | - - file_id is the file_id if the entry is versioned. |
652 | - versioned_kind is the kind of the file as last recorded in the |
653 | versioning system. If 'unknown' the file is not versioned. |
654 | One of 'kind' and 'versioned_kind' must not be 'unknown'. |
655 | |
656 | === modified file 'breezy/workingtree.py' |
657 | --- breezy/workingtree.py 2020-06-28 19:58:43 +0000 |
658 | +++ breezy/workingtree.py 2020-08-06 22:38:17 +0000 |
659 | @@ -1221,8 +1221,8 @@ |
660 | """Walk the directories of this tree. |
661 | |
662 | returns a generator which yields items in the form: |
663 | - ((curren_directory_path, fileid), |
664 | - [(file1_path, file1_name, file1_kind, (lstat), file1_id, |
665 | + (current_directory_path, |
666 | + [(file1_path, file1_name, file1_kind, (lstat), |
667 | file1_kind), ... ]) |
668 | |
669 | This API returns a generator, which is only valid during the current |
670 | |
671 | === modified file 'doc/en/release-notes/brz-3.1.txt' |
672 | --- doc/en/release-notes/brz-3.1.txt 2020-07-28 02:32:04 +0000 |
673 | +++ doc/en/release-notes/brz-3.1.txt 2020-08-06 22:38:17 +0000 |
674 | @@ -87,6 +87,9 @@ |
675 | * The ``osutils.safe_file_id`` and ``osutils.safe_revision_id`` methods |
676 | have been removed. (Jelmer Vernooij) |
677 | |
678 | + * File ids are no longer returned in ``Tree.walkdirs``. |
679 | + (Jelmer Vernooij) |
680 | + |
681 | Internals |
682 | ********* |
683 |
Running landing tests failed /ci.breezy- vcs.org/ job/brz- 3.1/job/ brz-3.1- land/266/
https:/