Merge lp:~jelmer/brz/id2path into lp:brz

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/id2path
Merge into: lp:brz
Diff against target: 181 lines (+16/-58)
6 files modified
breezy/git/tree.py (+0/-26)
breezy/git/workingtree.py (+0/-3)
breezy/tests/per_tree/test_test_trees.py (+3/-3)
breezy/tests/per_tree/test_tree.py (+8/-9)
breezy/tests/per_workingtree/test_workingtree.py (+5/-6)
breezy/tree.py (+0/-11)
To merge this branch: bzr merge lp:~jelmer/brz/id2path
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+411822@code.launchpad.net

Commit message

Remove Tree.id2path.

Description of the change

Remove Tree.id2path.

This is now a InventoryTree-specific method.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/tree.py'
2--- breezy/git/tree.py 2021-05-30 16:44:00 +0000
3+++ breezy/git/tree.py 2021-11-13 14:36:34 +0000
4@@ -382,15 +382,6 @@
5 raise _mod_tree.FileTimestampUnavailable(path)
6 return rev.timestamp
7
8- def id2path(self, file_id, recurse='down'):
9- try:
10- path = self.mapping.parse_file_id(file_id)
11- except ValueError:
12- raise errors.NoSuchId(self, file_id)
13- if self.is_versioned(path):
14- return path
15- raise errors.NoSuchId(self, file_id)
16-
17 def is_versioned(self, path):
18 return self.has_filename(path)
19
20@@ -401,9 +392,6 @@
21 return None
22 return self.mapping.generate_file_id(osutils.safe_unicode(path))
23
24- def all_file_ids(self):
25- raise errors.UnsupportedOperation(self.all_file_ids, self)
26-
27 def all_versioned_paths(self):
28 ret = {u''}
29 todo = [(self.store, b'', self.tree)]
30@@ -1164,20 +1152,6 @@
31 osutils.safe_unicode(path))
32 return None
33
34- def id2path(self, file_id, recurse='down'):
35- if file_id is None:
36- return ''
37- if type(file_id) is not bytes:
38- raise TypeError(file_id)
39- with self.lock_read():
40- try:
41- path = self.mapping.parse_file_id(file_id)
42- except ValueError:
43- raise errors.NoSuchId(self, file_id)
44- if self.is_versioned(path):
45- return path
46- raise errors.NoSuchId(self, file_id)
47-
48 def _set_root_id(self, file_id):
49 raise errors.UnsupportedOperation(self._set_root_id, self)
50
51
52=== modified file 'breezy/git/workingtree.py'
53--- breezy/git/workingtree.py 2021-05-30 17:12:41 +0000
54+++ breezy/git/workingtree.py 2021-11-13 14:36:34 +0000
55@@ -920,9 +920,6 @@
56 yield (posixpath.relpath(path, from_dir),
57 ("I" if self.is_ignored(path) else "?"), kind, ie)
58
59- def all_file_ids(self):
60- raise errors.UnsupportedOperation(self.all_file_ids, self)
61-
62 def all_versioned_paths(self):
63 with self.lock_read():
64 paths = {u""}
65
66=== modified file 'breezy/tests/per_tree/test_test_trees.py'
67--- breezy/tests/per_tree/test_test_trees.py 2020-02-07 02:14:30 +0000
68+++ breezy/tests/per_tree/test_test_trees.py 2021-11-13 14:36:34 +0000
69@@ -172,10 +172,11 @@
70 self.assertEqual([], tree.conflicts())
71 self.assertEqual([], list(tree.unknowns()))
72 # __iter__ has no strongly defined order
73- tree_root = tree.path2id('')
74 try:
75 all_file_ids = set(tree.all_file_ids())
76- except errors.UnsupportedOperation:
77+ tree_root = tree.path2id('')
78+ except AttributeError:
79+ # doesn't support file ids
80 all_file_ids = None
81 if tree.has_versioned_directories():
82 if all_file_ids is not None:
83@@ -226,7 +227,6 @@
84 self.assertEqual([], tree.conflicts())
85 self.assertEqual([], list(tree.unknowns()))
86 # __iter__ has no strongly defined order
87- tree_root = tree.path2id('')
88 if tree.has_versioned_directories():
89 self.assertEqual(
90 {'', '0file', '1top-dir', '1top-dir/0file-in-1topdir',
91
92=== modified file 'breezy/tests/per_tree/test_tree.py'
93--- breezy/tests/per_tree/test_tree.py 2020-01-18 00:03:17 +0000
94+++ breezy/tests/per_tree/test_tree.py 2021-11-13 14:36:34 +0000
95@@ -138,11 +138,14 @@
96
97 class TestFileIds(TestCaseWithTree):
98
99+ def setUp(self):
100+ super(TestFileIds, self).setUp()
101+ if not self.workingtree_format.supports_setting_file_ids:
102+ raise tests.TestNotApplicable("working tree does not support setting file ids")
103+
104 def test_id2path(self):
105 # translate from file-id back to path
106 work_tree = self.make_branch_and_tree('wt')
107- if not work_tree.supports_setting_file_ids():
108- self.skipTest("working tree does not support setting file ids")
109 tree = self.get_tree_no_parents_abc_content(work_tree)
110 a_id = tree.path2id('a')
111 with tree.lock_read():
112@@ -155,13 +158,9 @@
113 tree = self.get_tree_no_parents_abc_content(work_tree)
114 tree.lock_read()
115 self.addCleanup(tree.unlock)
116- try:
117- self.assertEqual(tree.all_file_ids(),
118- {tree.path2id('a'), tree.path2id(''),
119- tree.path2id('b'), tree.path2id('b/c')})
120- except errors.UnsupportedOperation:
121- raise tests.TestNotApplicable(
122- 'Tree does not support all_file_ids')
123+ self.assertEqual(tree.all_file_ids(),
124+ {tree.path2id('a'), tree.path2id(''),
125+ tree.path2id('b'), tree.path2id('b/c')})
126
127
128 class TestStoredKind(TestCaseWithTree):
129
130=== modified file 'breezy/tests/per_workingtree/test_workingtree.py'
131--- breezy/tests/per_workingtree/test_workingtree.py 2020-08-22 22:46:24 +0000
132+++ breezy/tests/per_workingtree/test_workingtree.py 2021-11-13 14:36:34 +0000
133@@ -1090,18 +1090,17 @@
134 self.assertFalse(tree.is_executable('filename'))
135
136 def test_all_file_ids_with_missing(self):
137+ if not self.workingtree_format.supports_setting_file_ids:
138+ raise TestNotApplicable('does not support setting file ids')
139 tree = self.make_branch_and_tree('tree')
140 tree.lock_write()
141 self.addCleanup(tree.unlock)
142 self.build_tree(['tree/a', 'tree/b'])
143 tree.add(['a', 'b'])
144 os.unlink('tree/a')
145- try:
146- self.assertEqual(
147- {'a', 'b', ''},
148- set(tree.all_versioned_paths()))
149- except errors.UnsupportedOperation:
150- raise TestNotApplicable('tree does not support all_file_ids')
151+ self.assertEqual(
152+ {'a', 'b', ''},
153+ set(tree.all_versioned_paths()))
154
155 def test_sprout_hardlink(self):
156 real_os_link = getattr(os, 'link', None)
157
158=== modified file 'breezy/tree.py'
159--- breezy/tree.py 2020-08-22 22:46:24 +0000
160+++ breezy/tree.py 2021-11-13 14:36:34 +0000
161@@ -281,21 +281,10 @@
162 """
163 return False
164
165- def all_file_ids(self):
166- """Iterate through all file ids, including ids for missing files."""
167- raise NotImplementedError(self.all_file_ids)
168-
169 def all_versioned_paths(self):
170 """Iterate through all paths, including paths for missing files."""
171 raise NotImplementedError(self.all_versioned_paths)
172
173- def id2path(self, file_id, recurse='down'):
174- """Return the path for a file id.
175-
176- :raises NoSuchId:
177- """
178- raise NotImplementedError(self.id2path)
179-
180 def iter_entries_by_dir(self, specific_files=None, recurse_nested=False):
181 """Walk the tree in 'by_dir' order.
182

Subscribers

People subscribed via source and target branches