Merge lp:~jelmer/brz/remove-unused into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7406
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/remove-unused
Merge into: lp:brz
Diff against target: 666 lines (+93/-196)
20 files modified
breezy/builtins.py (+7/-7)
breezy/bzr/bundle/bundle_data.py (+17/-24)
breezy/bzr/bundle/serializer/v08.py (+4/-3)
breezy/bzr/inventorytree.py (+0/-4)
breezy/bzr/vf_repository.py (+3/-2)
breezy/bzr/workingtree.py (+3/-9)
breezy/bzr/workingtree_4.py (+7/-11)
breezy/git/tests/test_memorytree.py (+8/-9)
breezy/git/tree.py (+0/-15)
breezy/merge.py (+5/-1)
breezy/tests/blackbox/test_join.py (+2/-2)
breezy/tests/per_tree/test_tree.py (+0/-14)
breezy/tests/per_workingtree/test_commit.py (+11/-23)
breezy/tests/per_workingtree/test_executable.py (+7/-10)
breezy/tests/test_bundle.py (+6/-26)
breezy/tests/test_commit.py (+2/-2)
breezy/tests/test_memorytree.py (+1/-1)
breezy/tests/test_shelf.py (+6/-6)
breezy/tests/test_smart_add.py (+4/-3)
breezy/transform.py (+0/-24)
To merge this branch: bzr merge lp:~jelmer/brz/remove-unused
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+373320@code.launchpad.net

Commit message

Remove Tree.has_id.

Description of the change

Remove Tree.has_id.

This call is O(n-subtrees).

Replace with Tree.id2path or (where possible) avoid it altogether.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Changes here all look sensible. I'm down with making expensive things look expensive.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/builtins.py'
2--- breezy/builtins.py 2019-08-11 13:33:45 +0000
3+++ breezy/builtins.py 2019-10-13 15:35:30 +0000
4@@ -2386,13 +2386,13 @@
5 self.enter_context(tree.lock_read())
6 old = tree.basis_tree()
7 self.enter_context(old.lock_read())
8- for path, ie in old.iter_entries_by_dir():
9- if not tree.has_id(ie.file_id):
10- self.outf.write(path)
11- if show_ids:
12- self.outf.write(' ')
13- self.outf.write(ie.file_id)
14- self.outf.write('\n')
15+ delta = tree.changes_from(old)
16+ for change in delta.removed:
17+ self.outf.write(change.path[0])
18+ if show_ids:
19+ self.outf.write(' ')
20+ self.outf.write(change.file_id)
21+ self.outf.write('\n')
22
23
24 class cmd_modified(Command):
25
26=== modified file 'breezy/bzr/bundle/bundle_data.py'
27--- breezy/bzr/bundle/bundle_data.py 2019-09-21 15:10:27 +0000
28+++ breezy/bzr/bundle/bundle_data.py 2019-10-13 15:35:30 +0000
29@@ -32,6 +32,7 @@
30 from ...errors import (
31 TestamentMismatch,
32 BzrError,
33+ NoSuchId,
34 )
35 from ..inventory import (
36 Inventory,
37@@ -486,7 +487,6 @@
38 self.patches = {}
39 self._targets = {} # new path => new symlink target
40 self.deleted = []
41- self.contents_by_id = True
42 self.revision_id = revision_id
43 self._inventory = None
44
45@@ -602,22 +602,13 @@
46 return path
47 old_path = self.base_tree.id2path(file_id)
48 if old_path is None:
49- return None
50+ raise NoSuchId(file_id, self)
51 if old_path in self.deleted:
52- return None
53- return self.new_path(old_path)
54-
55- def old_contents_id(self, file_id):
56- """Return the id in the base_tree for the given file_id.
57- Return None if the file did not exist in base.
58- """
59- if self.contents_by_id:
60- if self.base_tree.has_id(file_id):
61- return file_id
62- else:
63- return None
64- new_path = self.id2path(file_id)
65- return self.base_tree.path2id(new_path)
66+ raise NoSuchId(file_id, self)
67+ new_path = self.new_path(old_path)
68+ if new_path is None:
69+ raise NoSuchId(file_id, self)
70+ return new_path
71
72 def get_file(self, path):
73 """Return a file-like object containing the new contents of the
74@@ -628,13 +619,14 @@
75 then be cached.
76 """
77 file_id = self.path2id(path)
78- base_id = self.old_contents_id(file_id)
79- if (base_id is not None and
80- base_id != self.base_tree.path2id('')):
81- old_path = self.base_tree.id2path(base_id)
82+ try:
83+ old_path = self.base_tree.id2path(file_id)
84+ except NoSuchId:
85+ patch_original = None
86+ else:
87+ if old_path is None:
88+ import pdb; pdb.set_trace()
89 patch_original = self.base_tree.get_file(old_path)
90- else:
91- patch_original = None
92 file_patch = self.patches.get(path)
93 if file_patch is None:
94 if (patch_original is None and
95@@ -780,8 +772,9 @@
96 for result in viewitems(self._new_id):
97 paths.append(result)
98 for id in self.base_tree.all_file_ids():
99- path = self.id2path(id)
100- if path is None:
101+ try:
102+ path = self.id2path(id)
103+ except NoSuchId:
104 continue
105 paths.append((path, id))
106 paths.sort()
107
108=== modified file 'breezy/bzr/bundle/serializer/v08.py'
109--- breezy/bzr/bundle/serializer/v08.py 2019-09-21 19:27:04 +0000
110+++ breezy/bzr/bundle/serializer/v08.py 2019-10-13 15:35:30 +0000
111@@ -269,13 +269,14 @@
112
113 def do_diff(file_id, old_path, new_path, action, force_binary):
114 def tree_lines(tree, path, require_text=False):
115- if tree.has_id(file_id):
116+ try:
117 tree_file = tree.get_file(path)
118+ except errors.NoSuchFile:
119+ return []
120+ else:
121 if require_text is True:
122 tree_file = text_file(tree_file)
123 return tree_file.readlines()
124- else:
125- return []
126
127 try:
128 if force_binary:
129
130=== modified file 'breezy/bzr/inventorytree.py'
131--- breezy/bzr/inventorytree.py 2019-09-25 19:11:10 +0000
132+++ breezy/bzr/inventorytree.py 2019-10-13 15:35:30 +0000
133@@ -172,10 +172,6 @@
134 inventory, file_id = self._unpack_file_id(file_id)
135 return inventory.id2path(file_id)
136
137- def has_id(self, file_id):
138- inventory, file_id = self._unpack_file_id(file_id)
139- return inventory.has_id(file_id)
140-
141 def all_file_ids(self):
142 return {entry.file_id for path, entry in self.iter_entries_by_dir()}
143
144
145=== modified file 'breezy/bzr/vf_repository.py'
146--- breezy/bzr/vf_repository.py 2019-07-25 23:22:30 +0000
147+++ breezy/bzr/vf_repository.py 2019-10-13 15:35:30 +0000
148@@ -2916,9 +2916,10 @@
149 # the parents inserted are not those commit would do - in particular
150 # they are not filtered by heads(). RBC, AB
151 for revision, tree in viewitems(parent_trees):
152- if not tree.has_id(ie.file_id):
153+ try:
154+ path = tree.id2path(ie.file_id)
155+ except errors.NoSuchId:
156 continue
157- path = tree.id2path(ie.file_id)
158 parent_id = tree.get_file_revision(path)
159 if parent_id in text_parents:
160 continue
161
162=== modified file 'breezy/bzr/workingtree.py'
163--- breezy/bzr/workingtree.py 2019-09-25 19:11:10 +0000
164+++ breezy/bzr/workingtree.py 2019-10-13 15:35:30 +0000
165@@ -658,14 +658,6 @@
166 self._set_inventory(result, dirty=False)
167 return result
168
169- def has_id(self, file_id):
170- # files that have been deleted are excluded
171- inv, inv_file_id = self._unpack_file_id(file_id)
172- if not inv.has_id(inv_file_id):
173- return False
174- path = inv.id2path(inv_file_id)
175- return osutils.lexists(self.abspath(path))
176-
177 def all_file_ids(self):
178 """Iterate through file_ids for this tree.
179
180@@ -1368,7 +1360,9 @@
181 if after:
182 basis = self.basis_tree()
183 with basis.lock_read():
184- if not basis.has_id(to_id):
185+ try:
186+ basis.id2path(to_id)
187+ except errors.NoSuchId:
188 rename_entry.change_id = True
189 allowed = True
190 if not allowed:
191
192=== modified file 'breezy/bzr/workingtree_4.py'
193--- breezy/bzr/workingtree_4.py 2019-09-25 19:11:10 +0000
194+++ breezy/bzr/workingtree_4.py 2019-10-13 15:35:30 +0000
195@@ -175,9 +175,13 @@
196 if sub_tree_id == self.path2id(''):
197 raise BadReferenceTarget(self, sub_tree,
198 'Trees have the same root id.')
199- if self.has_id(sub_tree_id):
200- raise BadReferenceTarget(self, sub_tree,
201- 'Root id already present in tree')
202+ try:
203+ self.id2path(sub_tree_id)
204+ except errors.NoSuchId:
205+ pass
206+ else:
207+ raise BadReferenceTarget(
208+ self, sub_tree, 'Root id already present in tree')
209 self._add([sub_tree_path], [sub_tree_id], ['tree-reference'])
210
211 def break_lock(self):
212@@ -467,14 +471,6 @@
213 def get_nested_tree(self, path):
214 return WorkingTree.open(self.abspath(path))
215
216- def has_id(self, file_id):
217- state = self.current_dirstate()
218- row, parents = self._get_entry(file_id=file_id)
219- if row is None:
220- return False
221- return osutils.lexists(pathjoin(
222- self.basedir, row[0].decode('utf8'), row[1].decode('utf8')))
223-
224 def id2path(self, file_id):
225 "Convert a file-id to a path."
226 with self.lock_read():
227
228=== modified file 'breezy/git/tests/test_memorytree.py'
229--- breezy/git/tests/test_memorytree.py 2018-11-11 04:08:32 +0000
230+++ breezy/git/tests/test_memorytree.py 2019-10-13 15:35:30 +0000
231@@ -142,19 +142,18 @@
232 """Some test for unversion of a memory tree."""
233 branch = self.make_branch('branch')
234 tree = branch.create_memorytree()
235- tree.lock_write()
236- tree.add(['', 'foo'], kinds=['directory', 'file'])
237- tree.unversion(['foo'])
238- self.assertFalse(tree.has_id(b'foo-id'))
239- tree.unlock()
240+ with tree.lock_write():
241+ tree.add(['', 'foo'], kinds=['directory', 'file'])
242+ tree.unversion(['foo'])
243+ self.assertFalse(tree.is_versioned('foo'))
244+ self.assertFalse(tree.has_filename('foo'))
245
246 def test_last_revision(self):
247 """There should be a last revision method we can call."""
248 tree = self.make_branch_and_memory_tree('branch')
249- tree.lock_write()
250- tree.add('')
251- rev_id = tree.commit('first post')
252- tree.unlock()
253+ with tree.lock_write():
254+ tree.add('')
255+ rev_id = tree.commit('first post')
256 self.assertEqual(rev_id, tree.last_revision())
257
258 def test_rename_file(self):
259
260=== modified file 'breezy/git/tree.py'
261--- breezy/git/tree.py 2019-09-25 19:11:10 +0000
262+++ breezy/git/tree.py 2019-10-13 15:35:30 +0000
263@@ -360,13 +360,6 @@
264 todo.append((store, subpath, hexsha))
265 return ret
266
267- def has_id(self, file_id):
268- try:
269- path = self.id2path(file_id)
270- except errors.NoSuchId:
271- return False
272- return self.has_filename(path)
273-
274 def _lookup_path(self, path):
275 if self.tree is None:
276 raise errors.NoSuchFile(path)
277@@ -1024,14 +1017,6 @@
278 osutils.safe_unicode(path))
279 return None
280
281- def has_id(self, file_id):
282- try:
283- self.id2path(file_id)
284- except errors.NoSuchId:
285- return False
286- else:
287- return True
288-
289 def id2path(self, file_id):
290 if file_id is None:
291 return ''
292
293=== modified file 'breezy/merge.py'
294--- breezy/merge.py 2019-09-22 15:13:51 +0000
295+++ breezy/merge.py 2019-10-13 15:35:30 +0000
296@@ -1854,7 +1854,11 @@
297 name_in_target = osutils.basename(self._target_subdir)
298 merge_into_root = subdir.copy()
299 merge_into_root.name = name_in_target
300- if self.this_tree.has_id(merge_into_root.file_id):
301+ try:
302+ self.this_tree.id2path(merge_into_root.file_id)
303+ except errors.NoSuchId:
304+ pass
305+ else:
306 # Give the root a new file-id.
307 # This can happen fairly easily if the directory we are
308 # incorporating is the root, and both trees have 'TREE_ROOT' as
309
310=== modified file 'breezy/tests/blackbox/test_join.py'
311--- breezy/tests/blackbox/test_join.py 2019-09-22 12:47:23 +0000
312+++ breezy/tests/blackbox/test_join.py 2019-10-13 15:35:30 +0000
313@@ -73,7 +73,7 @@
314 self.addCleanup(sub_tree.unlock)
315 if sub_tree.supports_setting_file_ids():
316 self.assertEqual(b'file1-id', sub_tree.path2id('file1'))
317- self.assertTrue(sub_tree.has_id(b'file1-id'))
318+ self.assertEqual('file1', sub_tree.id2path(b'file1-id'))
319 self.assertEqual(subtree_root_id, sub_tree.path2id(''))
320 self.assertEqual('', sub_tree.id2path(subtree_root_id))
321 self.assertIs(None, base_tree.path2id('subtree/file1'))
322@@ -83,7 +83,7 @@
323 self.assertEqual(['subtree'], list(base_tree.iter_references()))
324 if base_tree.supports_setting_file_ids():
325 self.assertEqual(b'file1-id', sub_tree.path2id('file1'))
326- self.assertFalse(base_tree.has_id(b'file1-id'))
327+ self.assertEqual('file1', sub_tree.id2path(b'file1-id'))
328 self.assertEqual(subtree_root_id, base_tree.path2id('subtree'))
329 self.assertEqual('subtree', base_tree.id2path(subtree_root_id))
330
331
332=== modified file 'breezy/tests/per_tree/test_tree.py'
333--- breezy/tests/per_tree/test_tree.py 2019-09-22 12:47:23 +0000
334+++ breezy/tests/per_tree/test_tree.py 2019-10-13 15:35:30 +0000
335@@ -295,20 +295,6 @@
336 list(tree.iter_child_entries('unknown')))
337
338
339-class TestHasId(TestCaseWithTree):
340-
341- def test_has_id(self):
342- work_tree = self.make_branch_and_tree('tree')
343- self.build_tree(['tree/file'])
344- work_tree.add('file')
345- file_id = work_tree.path2id('file')
346- tree = self._convert_tree(work_tree)
347- tree.lock_read()
348- self.addCleanup(tree.unlock)
349- self.assertTrue(tree.has_id(file_id))
350- self.assertFalse(tree.has_id(b'dir-id'))
351-
352-
353 class TestExtras(TestCaseWithTree):
354
355 def test_extras(self):
356
357=== modified file 'breezy/tests/per_workingtree/test_commit.py'
358--- breezy/tests/per_workingtree/test_commit.py 2019-09-25 19:11:10 +0000
359+++ breezy/tests/per_workingtree/test_commit.py 2019-10-13 15:35:30 +0000
360@@ -312,10 +312,6 @@
361 # a present on disk. After commit b-id, c-id and d-id should be
362 # missing from the inventory, within the same tree transaction.
363 wt.commit('commit stuff')
364- self.assertTrue(wt.has_id(a_id))
365- self.assertFalse(wt.has_id(b_id))
366- self.assertFalse(wt.has_id(c_id))
367- self.assertFalse(wt.has_id(d_id))
368 self.assertTrue(wt.has_filename('a'))
369 self.assertFalse(wt.has_filename('b'))
370 self.assertFalse(wt.has_filename('b/c'))
371@@ -324,16 +320,11 @@
372 # the changes should have persisted to disk - reopen the workingtree
373 # to be sure.
374 wt = wt.controldir.open_workingtree()
375- wt.lock_read()
376- self.assertTrue(wt.has_id(a_id))
377- self.assertFalse(wt.has_id(b_id))
378- self.assertFalse(wt.has_id(c_id))
379- self.assertFalse(wt.has_id(d_id))
380- self.assertTrue(wt.has_filename('a'))
381- self.assertFalse(wt.has_filename('b'))
382- self.assertFalse(wt.has_filename('b/c'))
383- self.assertFalse(wt.has_filename('d'))
384- wt.unlock()
385+ with wt.lock_read():
386+ self.assertTrue(wt.has_filename('a'))
387+ self.assertFalse(wt.has_filename('b'))
388+ self.assertFalse(wt.has_filename('b/c'))
389+ self.assertFalse(wt.has_filename('d'))
390
391 def test_commit_deleted_subtree_with_removed(self):
392 wt = self.make_branch_and_tree('.')
393@@ -346,15 +337,12 @@
394 wt.remove('b/c')
395 this_dir = wt.controldir.root_transport
396 this_dir.delete_tree('b')
397- wt.lock_write()
398- wt.commit('commit deleted rename')
399- self.assertTrue(wt.is_versioned('a'))
400- self.assertFalse(wt.has_id(b_id))
401- self.assertFalse(wt.has_id(c_id))
402- self.assertTrue(wt.has_filename('a'))
403- self.assertFalse(wt.has_filename('b'))
404- self.assertFalse(wt.has_filename('b/c'))
405- wt.unlock()
406+ with wt.lock_write():
407+ wt.commit('commit deleted rename')
408+ self.assertTrue(wt.is_versioned('a'))
409+ self.assertTrue(wt.has_filename('a'))
410+ self.assertFalse(wt.has_filename('b'))
411+ self.assertFalse(wt.has_filename('b/c'))
412
413 def test_commit_move_new(self):
414 wt = self.make_branch_and_tree('first')
415
416=== modified file 'breezy/tests/per_workingtree/test_executable.py'
417--- breezy/tests/per_workingtree/test_executable.py 2019-06-17 23:01:58 +0000
418+++ breezy/tests/per_workingtree/test_executable.py 2019-10-13 15:35:30 +0000
419@@ -52,16 +52,13 @@
420 the inventory still shows them, so don't assert that
421 the inventory is empty, just that the tree doesn't have them
422 """
423- tree.lock_read()
424- if not ignore_inv and getattr(tree, 'root_inventory', None):
425- self.assertEqual(
426- [('', tree.root_inventory.root)],
427- list(tree.root_inventory.iter_entries()))
428- self.assertFalse(tree.has_id(self.a_id))
429- self.assertFalse(tree.has_filename('a'))
430- self.assertFalse(tree.has_id(self.b_id))
431- self.assertFalse(tree.has_filename('b'))
432- tree.unlock()
433+ with tree.lock_read():
434+ if not ignore_inv and getattr(tree, 'root_inventory', None):
435+ self.assertEqual(
436+ [('', tree.root_inventory.root)],
437+ list(tree.root_inventory.iter_entries()))
438+ self.assertFalse(tree.has_filename('a'))
439+ self.assertFalse(tree.has_filename('b'))
440
441 def commit_and_branch(self):
442 """Commit the current tree, and create a second tree"""
443
444=== modified file 'breezy/tests/test_bundle.py'
445--- breezy/tests/test_bundle.py 2019-08-11 13:33:45 +0000
446+++ breezy/tests/test_bundle.py 2019-10-13 15:35:30 +0000
447@@ -148,10 +148,10 @@
448 return self.ids.get(path)
449
450 def id2path(self, file_id):
451- return self.paths.get(file_id)
452-
453- def has_id(self, file_id):
454- return self.id2path(file_id) is not None
455+ try:
456+ return self.paths[file_id]
457+ except KeyError:
458+ raise errors.NoSuchId(file_id, self)
459
460 def get_file(self, path):
461 result = BytesIO()
462@@ -270,7 +270,7 @@
463 btree = self.make_tree_1()[0]
464 btree.note_rename("grandparent/parent/file",
465 "grandparent/alt_parent/file")
466- self.assertTrue(btree.id2path(b"e") is None)
467+ self.assertRaises(errors.NoSuchId, btree.id2path, b"e")
468 self.assertFalse(btree.is_versioned("grandparent/parent/file"))
469 btree.note_id(b"e", "grandparent/parent/file")
470 return btree
471@@ -292,16 +292,6 @@
472 self.assertEqual(
473 btree.get_symlink_target('grandparent/parent/symlink'), 'venus')
474
475- def test_adds2(self):
476- """File/inventory adds, with patch-compatibile renames"""
477- btree = self.make_tree_2()
478- btree.contents_by_id = False
479- add_patch = self.unified_diff([b"Hello\n"], [b"Extra cheese\n"])
480- btree.note_patch("grandparent/parent/file", add_patch)
481- btree.note_id(b'f', 'grandparent/parent/symlink', kind='symlink')
482- btree.note_target('grandparent/parent/symlink', 'venus')
483- self.adds_test(btree)
484-
485 def make_tree_3(self):
486 btree, mtree = self.make_tree_1()
487 mtree.add_file(b"e", "grandparent/parent/topping", b"Anchovies\n")
488@@ -324,23 +314,13 @@
489 btree.note_patch("grandparent/alt_parent/stopping", mod_patch)
490 self.get_file_test(btree)
491
492- def test_get_file2(self):
493- """Get file contents, with patch-compatible renames"""
494- btree = self.make_tree_3()
495- btree.contents_by_id = False
496- mod_patch = self.unified_diff([], [b"Lemon\n"])
497- btree.note_patch("grandparent/alt_parent/stopping", mod_patch)
498- mod_patch = self.unified_diff([], [b"Hello\n"])
499- btree.note_patch("grandparent/alt_parent/file", mod_patch)
500- self.get_file_test(btree)
501-
502 def test_delete(self):
503 "Deletion by bundle"
504 btree = self.make_tree_1()[0]
505 with btree.get_file(btree.id2path(b"c")) as f:
506 self.assertEqual(f.read(), b"Hello\n")
507 btree.note_deletion("grandparent/parent/file")
508- self.assertTrue(btree.id2path(b"c") is None)
509+ self.assertRaises(errors.NoSuchId, btree.id2path, b"c")
510 self.assertFalse(btree.is_versioned("grandparent/parent/file"))
511
512 def sorted_ids(self, tree):
513
514=== modified file 'breezy/tests/test_commit.py'
515--- breezy/tests/test_commit.py 2019-06-15 15:59:17 +0000
516+++ breezy/tests/test_commit.py 2019-10-13 15:35:30 +0000
517@@ -173,7 +173,7 @@
518 reporter.calls)
519
520 tree = b.repository.revision_tree(b'rev2')
521- self.assertFalse(tree.has_id(b'hello-id'))
522+ self.assertFalse(tree.has_filename('hello'))
523
524 def test_partial_commit_move(self):
525 """Test a partial commit where a file was renamed but not committed.
526@@ -361,7 +361,7 @@
527 wt.commit('removed hello', rev_id=b'rev2')
528
529 tree = b.repository.revision_tree(b'rev2')
530- self.assertFalse(tree.has_id(b'hello-id'))
531+ self.assertFalse(tree.has_filename('hello'))
532
533 def test_committed_ancestry(self):
534 """Test commit appends revisions to ancestry."""
535
536=== modified file 'breezy/tests/test_memorytree.py'
537--- breezy/tests/test_memorytree.py 2019-06-29 13:16:26 +0000
538+++ breezy/tests/test_memorytree.py 2019-10-13 15:35:30 +0000
539@@ -170,7 +170,7 @@
540 kinds=['directory', 'file'])
541 tree.unversion(['foo'])
542 self.assertFalse(tree.is_versioned('foo'))
543- self.assertFalse(tree.has_id(b'foo-id'))
544+ self.assertRaises(errors.NoSuchId, tree.id2path, b'foo-id')
545
546 def test_last_revision(self):
547 """There should be a last revision method we can call."""
548
549=== modified file 'breezy/tests/test_shelf.py'
550--- breezy/tests/test_shelf.py 2018-11-16 18:33:17 +0000
551+++ breezy/tests/test_shelf.py 2019-10-13 15:35:30 +0000
552@@ -381,8 +381,8 @@
553 return creator, tree
554
555 def check_shelve_deletion(self, tree):
556- self.assertTrue(tree.has_id(b'foo-id'))
557- self.assertTrue(tree.has_id(b'bar-id'))
558+ self.assertEqual(tree.id2path(b'foo-id'), 'foo')
559+ self.assertEqual(tree.id2path(b'bar-id'), 'foo/bar')
560 self.assertFileEqual(b'baz', 'tree/foo/bar')
561
562 def test_shelve_deletion(self):
563@@ -611,15 +611,15 @@
564 creator.transform()
565 creator.finalize()
566 # validate the test setup
567- self.assertTrue(tree.has_id(b'foo-id'))
568- self.assertTrue(tree.has_id(b'bar-id'))
569+ self.assertEqual(tree.id2path(b'foo-id'), 'foo')
570+ self.assertEqual(tree.id2path(b'bar-id'), 'foo/bar')
571 self.assertFileEqual(b'baz', 'tree/foo/bar')
572 with open('shelf', 'r+b') as shelf_file:
573 unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
574 self.addCleanup(unshelver.finalize)
575 unshelver.make_merger().do_merge()
576- self.assertFalse(tree.has_id(b'foo-id'))
577- self.assertFalse(tree.has_id(b'bar-id'))
578+ self.assertRaises(errors.NoSuchId, tree.id2path, b'foo-id')
579+ self.assertRaises(errors.NoSuchId, tree.id2path, b'bar-id')
580
581 def test_unshelve_base(self):
582 tree = self.make_branch_and_tree('tree')
583
584=== modified file 'breezy/tests/test_smart_add.py'
585--- breezy/tests/test_smart_add.py 2019-06-29 13:16:26 +0000
586+++ breezy/tests/test_smart_add.py 2019-10-13 15:35:30 +0000
587@@ -17,6 +17,7 @@
588 from .. import (
589 add,
590 cache_utf8,
591+ errors,
592 tests,
593 )
594 from ..bzr import (
595@@ -116,11 +117,11 @@
596 self.assertNotEqual(None, c_id)
597 self.base_tree.lock_read()
598 self.addCleanup(self.base_tree.unlock)
599- self.assertFalse(self.base_tree.has_id(c_id))
600+ self.assertRaises(errors.NoSuchId, self.base_tree.id2path, c_id)
601
602 d_id = new_tree.path2id('subdir/d')
603 self.assertNotEqual(None, d_id)
604- self.assertFalse(self.base_tree.has_id(d_id))
605+ self.assertRaises(errors.NoSuchId, self.base_tree.id2path, d_id)
606
607 def test_copy_existing_dir(self):
608 self.make_base_tree()
609@@ -141,7 +142,7 @@
610 self.assertNotEqual(None, a_id)
611 self.base_tree.lock_read()
612 self.addCleanup(self.base_tree.unlock)
613- self.assertFalse(self.base_tree.has_id(a_id))
614+ self.assertRaises(errors.NoSuchId, self.base_tree.id2path, a_id)
615
616
617 class TestAddActions(tests.TestCase):
618
619=== modified file 'breezy/transform.py'
620--- breezy/transform.py 2019-09-25 19:11:10 +0000
621+++ breezy/transform.py 2019-10-13 15:35:30 +0000
622@@ -2121,18 +2121,6 @@
623
624 return tree_paths
625
626- def _has_id(self, file_id, fallback_check):
627- if file_id in self._transform._r_new_id:
628- return True
629- elif file_id in {self._transform.tree_file_id(trans_id) for
630- trans_id in self._transform._removed_id}:
631- return False
632- else:
633- return fallback_check(file_id)
634-
635- def has_id(self, file_id):
636- return self._has_id(file_id, self._transform._tree.has_id)
637-
638 def _path2trans_id(self, path):
639 # We must not use None here, because that is a valid value to store.
640 trans_id = self._path2trans_id_cache.get(path, object)
641@@ -2180,11 +2168,6 @@
642 self._all_children_cache[trans_id] = children
643 return children
644
645- def _iter_children(self, file_id):
646- trans_id = self._transform.trans_id_file_id(file_id)
647- for child_trans_id in self._all_children(trans_id):
648- yield self._transform.final_file_id(child_trans_id)
649-
650 def extras(self):
651 possible_extras = set(self._transform.trans_id_tree_path(p) for p
652 in self._transform._tree.extras())
653@@ -2561,13 +2544,6 @@
654 return [(self.get_path(t), t) for t in trans_ids]
655
656
657-def topology_sorted_ids(tree):
658- """Determine the topological order of the ids in a tree"""
659- file_ids = list(tree)
660- file_ids.sort(key=tree.id2path)
661- return file_ids
662-
663-
664 def build_tree(tree, wt, accelerator_tree=None, hardlink=False,
665 delta_from_tree=False):
666 """Create working tree for a branch, using a TreeTransform.

Subscribers

People subscribed via source and target branches