Merge lp:~jelmer/brz/get-root-id 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/get-root-id
Merge into: lp:brz
Diff against target: 1877 lines (+187/-249)
56 files modified
breezy/bzr/bundle/bundle_data.py (+1/-4)
breezy/bzr/bzrdir.py (+1/-1)
breezy/bzr/fetch.py (+3/-3)
breezy/bzr/inventorytree.py (+0/-4)
breezy/bzr/vf_repository.py (+1/-1)
breezy/bzr/workingtree.py (+3/-8)
breezy/bzr/workingtree_3.py (+2/-2)
breezy/bzr/workingtree_4.py (+3/-11)
breezy/git/object_store.py (+2/-2)
breezy/git/tests/test_repository.py (+1/-1)
breezy/git/tree.py (+1/-9)
breezy/git/workingtree.py (+1/-1)
breezy/memorytree.py (+0/-3)
breezy/merge.py (+1/-1)
breezy/plugins/weave_fmt/workingtree.py (+2/-2)
breezy/tests/blackbox/test_join.py (+1/-1)
breezy/tests/per_intertree/test_compare.py (+44/-44)
breezy/tests/per_repository/test_commit_builder.py (+2/-2)
breezy/tests/per_repository/test_repository.py (+0/-1)
breezy/tests/per_repository_vf/test_fileid_involved.py (+2/-2)
breezy/tests/per_repository_vf/test_repository.py (+1/-1)
breezy/tests/per_tree/test_get_root_id.py (+3/-3)
breezy/tests/per_tree/test_ids.py (+1/-1)
breezy/tests/per_tree/test_test_trees.py (+1/-1)
breezy/tests/per_tree/test_tree.py (+1/-1)
breezy/tests/per_workingtree/test_add.py (+2/-2)
breezy/tests/per_workingtree/test_add_reference.py (+2/-2)
breezy/tests/per_workingtree/test_commit.py (+2/-5)
breezy/tests/per_workingtree/test_flush.py (+6/-15)
breezy/tests/per_workingtree/test_inv.py (+6/-6)
breezy/tests/per_workingtree/test_locking.py (+4/-4)
breezy/tests/per_workingtree/test_merge_from_branch.py (+1/-1)
breezy/tests/per_workingtree/test_pull.py (+4/-4)
breezy/tests/per_workingtree/test_rename_one.py (+0/-1)
breezy/tests/per_workingtree/test_set_root_id.py (+8/-11)
breezy/tests/per_workingtree/test_workingtree.py (+7/-7)
breezy/tests/test__dirstate_helpers.py (+1/-1)
breezy/tests/test_commit_merge.py (+1/-1)
breezy/tests/test_dirstate.py (+13/-16)
breezy/tests/test_extract.py (+1/-1)
breezy/tests/test_fetch.py (+1/-1)
breezy/tests/test_matchers.py (+1/-1)
breezy/tests/test_memorytree.py (+1/-1)
breezy/tests/test_merge.py (+3/-3)
breezy/tests/test_revert.py (+2/-2)
breezy/tests/test_revisiontree.py (+1/-1)
breezy/tests/test_shelf_ui.py (+3/-3)
breezy/tests/test_smart_add.py (+1/-1)
breezy/tests/test_subsume.py (+4/-4)
breezy/tests/test_switch.py (+1/-1)
breezy/tests/test_transform.py (+13/-13)
breezy/tests/test_workingtree_4.py (+5/-8)
breezy/transform.py (+7/-10)
breezy/tree.py (+0/-4)
breezy/workingtree.py (+5/-9)
doc/en/release-notes/brz-3.1.txt (+3/-0)
To merge this branch: bzr merge lp:~jelmer/brz/get-root-id
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+369477@code.launchpad.net

Commit message

Remove Tree.get_root_id() in favour of Tree.path2id('').

Description of the change

Remove Tree.get_root_id() in favour of Tree.path2id('').

This is a mechanical change, just s/get_root_id()/path2id('')/.

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

Fast eyeball of the diff, everything looks sane.

review: Approve
Revision history for this message
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/bundle/bundle_data.py'
2--- breezy/bzr/bundle/bundle_data.py 2019-06-30 10:50:40 +0000
3+++ breezy/bzr/bundle/bundle_data.py 2019-07-25 23:25:31 +0000
4@@ -579,9 +579,6 @@
5 return None
6 return new_path
7
8- def get_root_id(self):
9- return self.path2id('')
10-
11 def path2id(self, path):
12 """Return the id of the file present at path in the target tree."""
13 file_id = self._new_id.get(path)
14@@ -629,7 +626,7 @@
15 file_id = self.path2id(path)
16 base_id = self.old_contents_id(file_id)
17 if (base_id is not None and
18- base_id != self.base_tree.get_root_id()):
19+ base_id != self.base_tree.path2id('')):
20 old_path = self.base_tree.id2path(base_id)
21 patch_original = self.base_tree.get_file(old_path)
22 else:
23
24=== modified file 'breezy/bzr/bzrdir.py'
25--- breezy/bzr/bzrdir.py 2019-06-21 16:36:04 +0000
26+++ breezy/bzr/bzrdir.py 2019-07-25 23:25:31 +0000
27@@ -459,7 +459,7 @@
28 with wt.lock_write():
29 if not wt.is_versioned(''):
30 try:
31- wt.set_root_id(self.open_workingtree.get_root_id())
32+ wt.set_root_id(self.open_workingtree.path2id(''))
33 except errors.NoWorkingTree:
34 pass
35 else:
36
37=== modified file 'breezy/bzr/fetch.py'
38--- breezy/bzr/fetch.py 2018-11-16 18:33:17 +0000
39+++ breezy/bzr/fetch.py 2019-07-25 23:25:31 +0000
40@@ -211,7 +211,7 @@
41 def _find_root_ids(self, revs, parent_map, graph):
42 revision_root = {}
43 for tree in self.iter_rev_trees(revs):
44- root_id = tree.get_root_id()
45+ root_id = tree.path2id('')
46 revision_id = tree.get_file_revision(u'')
47 revision_root[revision_id] = root_id
48 # Find out which parents we don't already know root ids for
49@@ -221,7 +221,7 @@
50 # Limit to revisions present in the versionedfile
51 parents = graph.get_parent_map(parents)
52 for tree in self.iter_rev_trees(parents):
53- root_id = tree.get_root_id()
54+ root_id = tree.path2id('')
55 revision_root[tree.get_revision_id()] = root_id
56 return revision_root
57
58@@ -296,7 +296,7 @@
59 # But set parent_root_id to None since we don't really know
60 parent_root_id = None
61 else:
62- parent_root_id = tree.get_root_id()
63+ parent_root_id = tree.path2id('')
64 rev_id_to_root_id_map[parent_id] = None
65 # XXX: why not:
66 # rev_id_to_root_id_map[parent_id] = parent_root_id
67
68=== modified file 'breezy/bzr/inventorytree.py'
69--- breezy/bzr/inventorytree.py 2019-06-29 12:29:45 +0000
70+++ breezy/bzr/inventorytree.py 2019-07-25 23:25:31 +0000
71@@ -778,10 +778,6 @@
72 nested_revid = self.get_reference_revision(path)
73 raise MissingNestedTree(path)
74
75- def get_root_id(self):
76- if self.root_inventory.root:
77- return self.root_inventory.root.file_id
78-
79 def kind(self, path):
80 return self._path2ie(path).kind
81
82
83=== modified file 'breezy/bzr/vf_repository.py'
84--- breezy/bzr/vf_repository.py 2019-06-30 10:50:40 +0000
85+++ breezy/bzr/vf_repository.py 2019-07-25 23:25:31 +0000
86@@ -2642,7 +2642,7 @@
87 current_revision_id, revision.parent_ids))
88 if self._converting_to_rich_root:
89 self._revision_id_to_root_id[current_revision_id] = \
90- tree.get_root_id()
91+ tree.path2id('')
92 # Determine which texts are in present in this revision but not in
93 # any of the available parents.
94 texts_possibly_new_in_tree = set()
95
96=== modified file 'breezy/bzr/workingtree.py'
97--- breezy/bzr/workingtree.py 2019-06-22 10:30:21 +0000
98+++ breezy/bzr/workingtree.py 2019-07-25 23:25:31 +0000
99@@ -284,7 +284,7 @@
100 InventoryFile,
101 InventoryLink)
102 with self.lock_tree_write():
103- inv = Inventory(self.get_root_id())
104+ inv = Inventory(self.path2id(''))
105 for path, file_id, parent, kind in new_inventory_list:
106 name = os.path.basename(path)
107 if name == "":
108@@ -658,11 +658,6 @@
109 self._set_inventory(result, dirty=False)
110 return result
111
112- def get_root_id(self):
113- """Return the id of this trees root"""
114- with self.lock_read():
115- return self._inventory.root.file_id
116-
117 def has_id(self, file_id):
118 # files that have been deleted are excluded
119 inv, inv_file_id = self._unpack_file_id(file_id)
120@@ -672,7 +667,7 @@
121 return osutils.lexists(self.abspath(path))
122
123 def has_or_had_id(self, file_id):
124- if file_id == self.get_root_id():
125+ if file_id == self.path2id(''):
126 return True
127 inv, inv_file_id = self._unpack_file_id(file_id)
128 return inv.has_id(inv_file_id)
129@@ -951,7 +946,7 @@
130 if child_entry.kind == 'directory':
131 add_children(inventory, child_entry)
132 with self.lock_write():
133- if other_tree.get_root_id() == self.get_root_id():
134+ if other_tree.path2id('') == self.path2id(''):
135 raise errors.BadSubsumeSource(self, other_tree,
136 'Trees have the same root')
137 try:
138
139=== modified file 'breezy/bzr/workingtree_3.py'
140--- breezy/bzr/workingtree_3.py 2018-12-04 19:22:35 +0000
141+++ breezy/bzr/workingtree_3.py 2019-07-25 23:25:31 +0000
142@@ -224,8 +224,8 @@
143 try:
144 basis_tree = branch.repository.revision_tree(revision_id)
145 # only set an explicit root id if there is one to set.
146- if basis_tree.get_root_id() is not None:
147- wt.set_root_id(basis_tree.get_root_id())
148+ if basis_tree.path2id('') is not None:
149+ wt.set_root_id(basis_tree.path2id(''))
150 if revision_id == _mod_revision.NULL_REVISION:
151 wt.set_parent_trees([])
152 else:
153
154=== modified file 'breezy/bzr/workingtree_4.py'
155--- breezy/bzr/workingtree_4.py 2019-06-29 12:29:45 +0000
156+++ breezy/bzr/workingtree_4.py 2019-07-25 23:25:31 +0000
157@@ -171,8 +171,8 @@
158 except errors.PathNotChild:
159 raise BadReferenceTarget(self, sub_tree,
160 'Target not inside tree.')
161- sub_tree_id = sub_tree.get_root_id()
162- if sub_tree_id == self.get_root_id():
163+ sub_tree_id = sub_tree.path2id('')
164+ if sub_tree_id == self.path2id(''):
165 raise BadReferenceTarget(self, sub_tree,
166 'Trees have the same root id.')
167 if self.has_id(sub_tree_id):
168@@ -467,11 +467,6 @@
169 def get_nested_tree(self, path):
170 return WorkingTree.open(self.abspath(path))
171
172- def get_root_id(self):
173- """Return the id of this trees root"""
174- with self.lock_read():
175- return self._get_entry(path='')[0][2]
176-
177 def has_id(self, file_id):
178 state = self.current_dirstate()
179 row, parents = self._get_entry(file_id=file_id)
180@@ -1549,7 +1544,7 @@
181 wt.flush()
182 # if the basis has a root id we have to use that; otherwise we
183 # use a new random one
184- basis_root_id = basis.get_root_id()
185+ basis_root_id = basis.path2id('')
186 if basis_root_id is not None:
187 wt._set_root_id(basis_root_id)
188 wt.flush()
189@@ -1748,9 +1743,6 @@
190 pred = self.has_filename
191 return set((p for p in paths if not pred(p)))
192
193- def get_root_id(self):
194- return self.path2id('')
195-
196 def id2path(self, file_id):
197 "Convert a file-id to a path."
198 entry = self._get_entry(file_id=file_id)
199
200=== modified file 'breezy/git/object_store.py'
201--- breezy/git/object_store.py 2019-07-25 22:52:58 +0000
202+++ breezy/git/object_store.py 2019-07-25 23:25:31 +0000
203@@ -518,7 +518,7 @@
204 else:
205 base_sha1 = self._lookup_revision_sha1(rev.parent_ids[0])
206 root_tree = self[self[base_sha1].tree]
207- root_key_data = (tree.get_root_id(), tree.get_revision_id())
208+ root_key_data = (tree.path2id(''), tree.get_revision_id())
209 if add_cache_entry is not None:
210 add_cache_entry(root_tree, root_key_data, "")
211 yield "", root_tree
212@@ -614,7 +614,7 @@
213 path,
214 bzr_tree.iter_child_entries(path),
215 get_ie_sha1, unusual_modes, self.mapping.BZR_DUMMY_FILE,
216- bzr_tree.get_root_id() == fileid)
217+ bzr_tree.path2id('') == fileid)
218 if tree is not None:
219 _check_expected_sha(expected_sha, tree)
220 return tree
221
222=== modified file 'breezy/git/tests/test_repository.py'
223--- breezy/git/tests/test_repository.py 2018-11-21 21:34:30 +0000
224+++ breezy/git/tests/test_repository.py 2019-07-25 23:25:31 +0000
225@@ -190,7 +190,7 @@
226 repo = self.git_repo
227 tree = repo.revision_tree(revision.NULL_REVISION)
228 self.assertEqual(tree.get_revision_id(), revision.NULL_REVISION)
229- self.assertIs(None, tree.get_root_id())
230+ self.assertIs(None, tree.path2id(''))
231
232 def test_get_parent_map_null(self):
233 self.assertEqual({revision.NULL_REVISION: ()},
234
235=== modified file 'breezy/git/tree.py'
236--- breezy/git/tree.py 2019-07-25 22:52:58 +0000
237+++ breezy/git/tree.py 2019-07-25 23:25:31 +0000
238@@ -360,11 +360,6 @@
239 todo.append((store, subpath, hexsha))
240 return ret
241
242- def get_root_id(self):
243- if self.tree is None:
244- return None
245- return self.path2id("")
246-
247 def has_or_had_id(self, file_id):
248 try:
249 self.id2path(file_id)
250@@ -512,7 +507,7 @@
251 else:
252 specific_files = set([p.encode('utf-8')
253 for p in specific_files])
254- todo = deque([(self.store, b"", self.tree, self.get_root_id())])
255+ todo = deque([(self.store, b"", self.tree, self.path2id(''))])
256 if specific_files is None or u"" in specific_files:
257 yield u"", self._get_dir_ie(b"", None)
258 while todo:
259@@ -1016,9 +1011,6 @@
260 def _set_root_id(self, file_id):
261 raise errors.UnsupportedOperation(self._set_root_id, self)
262
263- def get_root_id(self):
264- return self.path2id(u"")
265-
266 def _add(self, files, ids, kinds):
267 for (path, file_id, kind) in zip(files, ids, kinds):
268 if file_id is not None:
269
270=== modified file 'breezy/git/workingtree.py'
271--- breezy/git/workingtree.py 2019-06-29 15:50:22 +0000
272+++ breezy/git/workingtree.py 2019-07-25 23:25:31 +0000
273@@ -1039,7 +1039,7 @@
274 prefix = prefix.encode('utf-8')
275 per_dir = defaultdict(set)
276 if prefix == b"":
277- per_dir[(u'', self.get_root_id())] = set()
278+ per_dir[(u'', self.path2id(''))] = set()
279
280 def add_entry(path, kind):
281 if path == b'' or not path.startswith(prefix):
282
283=== modified file 'breezy/memorytree.py'
284--- breezy/memorytree.py 2019-03-04 00:19:25 +0000
285+++ breezy/memorytree.py 2019-07-25 23:25:31 +0000
286@@ -106,9 +106,6 @@
287 stream = self._file_transport.get(path)
288 return sha_file(stream)
289
290- def get_root_id(self):
291- return self.path2id('')
292-
293 def _comparison_data(self, entry, path):
294 """See Tree._comparison_data."""
295 if entry is None:
296
297=== modified file 'breezy/merge.py'
298--- breezy/merge.py 2019-06-22 13:51:23 +0000
299+++ breezy/merge.py 2019-07-25 23:25:31 +0000
300@@ -1563,7 +1563,7 @@
301 if other_parent is None or other_name is None:
302 other_path = '<deleted>'
303 else:
304- if other_parent == self.other_tree.get_root_id():
305+ if other_parent == self.other_tree.path2id(''):
306 # The tree transform doesn't know about the other root,
307 # so we special case here to avoid a NoFinalPath
308 # exception
309
310=== modified file 'breezy/plugins/weave_fmt/workingtree.py'
311--- breezy/plugins/weave_fmt/workingtree.py 2018-11-21 03:20:30 +0000
312+++ breezy/plugins/weave_fmt/workingtree.py 2019-07-25 23:25:31 +0000
313@@ -111,8 +111,8 @@
314 _controldir=a_controldir,
315 _control_files=branch.control_files)
316 basis_tree = branch.repository.revision_tree(revision_id)
317- if basis_tree.get_root_id() is not None:
318- wt.set_root_id(basis_tree.get_root_id())
319+ if basis_tree.path2id('') is not None:
320+ wt.set_root_id(basis_tree.path2id(''))
321 # set the parent list and cache the basis tree.
322 if _mod_revision.is_null(revision_id):
323 parent_trees = []
324
325=== modified file 'breezy/tests/blackbox/test_join.py'
326--- breezy/tests/blackbox/test_join.py 2018-11-11 04:08:32 +0000
327+++ breezy/tests/blackbox/test_join.py 2019-07-25 23:25:31 +0000
328@@ -67,7 +67,7 @@
329 def test_join_reference(self):
330 """Join can add a reference if --reference is supplied"""
331 base_tree, sub_tree = self.make_trees()
332- subtree_root_id = sub_tree.get_root_id()
333+ subtree_root_id = sub_tree.path2id('')
334 self.run_bzr('join . --reference', working_dir='tree/subtree')
335 sub_tree.lock_read()
336 self.addCleanup(sub_tree.unlock)
337
338=== modified file 'breezy/tests/per_intertree/test_compare.py'
339--- breezy/tests/per_intertree/test_compare.py 2019-06-17 23:01:58 +0000
340+++ breezy/tests/per_intertree/test_compare.py 2019-07-25 23:25:31 +0000
341@@ -73,7 +73,7 @@
342 def test_compare_empty_trees(self):
343 tree1 = self.make_branch_and_tree('1')
344 tree2 = self.make_to_branch_and_tree('2')
345- tree2.set_root_id(tree1.get_root_id())
346+ tree2.set_root_id(tree1.path2id(''))
347 tree1 = self.get_tree_no_parents_no_content(tree1)
348 tree2 = self.get_tree_no_parents_no_content(tree2)
349 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
350@@ -87,7 +87,7 @@
351 def test_empty_to_abc_content(self):
352 tree1 = self.make_branch_and_tree('1')
353 tree2 = self.make_to_branch_and_tree('2')
354- tree2.set_root_id(tree1.get_root_id())
355+ tree2.set_root_id(tree1.path2id(''))
356 tree1 = self.get_tree_no_parents_no_content(tree1)
357 tree2 = self.get_tree_no_parents_abc_content(tree2)
358 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
359@@ -109,7 +109,7 @@
360 # the test.
361 tree1 = self.make_branch_and_tree('1')
362 tree2 = self.make_to_branch_and_tree('2')
363- tree2.set_root_id(tree1.get_root_id())
364+ tree2.set_root_id(tree1.path2id(''))
365 self.build_tree(['2/a'])
366 tree2.add('a')
367 os.unlink('2/a')
368@@ -131,7 +131,7 @@
369 def test_abc_content_to_empty(self):
370 tree1 = self.make_branch_and_tree('1')
371 tree2 = self.make_to_branch_and_tree('2')
372- tree2.set_root_id(tree1.get_root_id())
373+ tree2.set_root_id(tree1.path2id(''))
374 tree1 = self.get_tree_no_parents_abc_content(tree1)
375 tree2 = self.get_tree_no_parents_no_content(tree2)
376 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
377@@ -148,7 +148,7 @@
378 def test_content_modification(self):
379 tree1 = self.make_branch_and_tree('1')
380 tree2 = self.make_to_branch_and_tree('2')
381- tree2.set_root_id(tree1.get_root_id())
382+ tree2.set_root_id(tree1.path2id(''))
383 tree1 = self.get_tree_no_parents_abc_content(tree1)
384 tree2 = self.get_tree_no_parents_abc_content_2(tree2)
385 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
386@@ -163,7 +163,7 @@
387 def test_meta_modification(self):
388 tree1 = self.make_branch_and_tree('1')
389 tree2 = self.make_to_branch_and_tree('2')
390- tree2.set_root_id(tree1.get_root_id())
391+ tree2.set_root_id(tree1.path2id(''))
392 tree1 = self.get_tree_no_parents_abc_content(tree1)
393 tree2 = self.get_tree_no_parents_abc_content_3(tree2)
394 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
395@@ -178,7 +178,7 @@
396 def test_file_rename(self):
397 tree1 = self.make_branch_and_tree('1')
398 tree2 = self.make_to_branch_and_tree('2')
399- tree2.set_root_id(tree1.get_root_id())
400+ tree2.set_root_id(tree1.path2id(''))
401 tree1 = self.get_tree_no_parents_abc_content(tree1)
402 tree2 = self.get_tree_no_parents_abc_content_4(tree2)
403 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
404@@ -193,7 +193,7 @@
405 def test_file_rename_and_modification(self):
406 tree1 = self.make_branch_and_tree('1')
407 tree2 = self.make_to_branch_and_tree('2')
408- tree2.set_root_id(tree1.get_root_id())
409+ tree2.set_root_id(tree1.path2id(''))
410 tree1 = self.get_tree_no_parents_abc_content(tree1)
411 tree2 = self.get_tree_no_parents_abc_content_5(tree2)
412 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
413@@ -208,7 +208,7 @@
414 def test_file_rename_and_meta_modification(self):
415 tree1 = self.make_branch_and_tree('1')
416 tree2 = self.make_to_branch_and_tree('2')
417- tree2.set_root_id(tree1.get_root_id())
418+ tree2.set_root_id(tree1.path2id(''))
419 tree1 = self.get_tree_no_parents_abc_content(tree1)
420 tree2 = self.get_tree_no_parents_abc_content_6(tree2)
421 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
422@@ -223,7 +223,7 @@
423 def test_empty_to_abc_content_a_only(self):
424 tree1 = self.make_branch_and_tree('1')
425 tree2 = self.make_to_branch_and_tree('2')
426- tree2.set_root_id(tree1.get_root_id())
427+ tree2.set_root_id(tree1.path2id(''))
428 tree1 = self.get_tree_no_parents_no_content(tree1)
429 tree2 = self.get_tree_no_parents_abc_content(tree2)
430 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
431@@ -349,7 +349,7 @@
432 def test_default_ignores_unversioned_files(self):
433 tree1 = self.make_branch_and_tree('tree1')
434 tree2 = self.make_to_branch_and_tree('tree2')
435- tree2.set_root_id(tree1.get_root_id())
436+ tree2.set_root_id(tree1.path2id(''))
437 self.build_tree(['tree1/a', 'tree1/c',
438 'tree2/a', 'tree2/b', 'tree2/c'])
439 tree1.add(['a', 'c'], [b'a-id', b'c-id'])
440@@ -368,7 +368,7 @@
441 def test_unversioned_paths_in_tree(self):
442 tree1 = self.make_branch_and_tree('tree1')
443 tree2 = self.make_to_branch_and_tree('tree2')
444- tree2.set_root_id(tree1.get_root_id())
445+ tree2.set_root_id(tree1.path2id(''))
446 self.build_tree(['tree2/file', 'tree2/dir/'])
447 if has_symlinks():
448 os.symlink('target', 'tree2/link')
449@@ -495,7 +495,7 @@
450 """Create a tree with filenames chosen to exercise the walk order."""
451 tree1 = self.make_branch_and_tree('tree1')
452 tree2 = self.make_to_branch_and_tree('tree2')
453- tree2.set_root_id(tree1.get_root_id())
454+ tree2.set_root_id(tree1.path2id(''))
455 paths, path_ids = self._create_special_names(tree2, 'tree2')
456 tree2.commit('initial', rev_id=b'rev-1')
457 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
458@@ -508,7 +508,7 @@
459 """
460 tree1 = self.make_branch_and_tree('tree1')
461 tree2 = self.make_to_branch_and_tree('tree2')
462- tree2.set_root_id(tree1.get_root_id())
463+ tree2.set_root_id(tree1.path2id(''))
464 paths, path_ids = self._create_special_names(tree1, 'tree1')
465 paths, path_ids = self._create_special_names(tree2, 'tree2')
466 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
467@@ -808,7 +808,7 @@
468 tree1.put_file_bytes_non_atomic(
469 'changing/unchanging/file', b'a file')
470 tree2 = self.make_to_branch_and_tree('2')
471- tree2.set_root_id(tree1.get_root_id())
472+ tree2.set_root_id(tree1.path2id(''))
473 tree2.mkdir('changed', b'parent-id')
474 tree2.mkdir('changed/unchanging', b'mid-id')
475 tree2.add(['changed/unchanging/file'], [b'file-id'], ['file'])
476@@ -887,7 +887,7 @@
477 tree1.add(['a'], [b'a-id'], ['file'])
478 tree1.put_file_bytes_non_atomic('a', b'a file')
479 tree2 = self.make_to_branch_and_tree('2')
480- tree2.set_root_id(tree1.get_root_id())
481+ tree2.set_root_id(tree1.path2id(''))
482 tree2.mkdir('a', b'b-id')
483 tree2.add(['a/c'], [b'c-id'], ['file'])
484 tree2.put_file_bytes_non_atomic('a/c', b'another file')
485@@ -907,7 +907,7 @@
486 tree1.mkdir('a/reparented', b'reparented-id')
487 tree1.mkdir('a/deleted', b'deleted-id')
488 tree2 = self.make_to_branch_and_tree('2')
489- tree2.set_root_id(tree1.get_root_id())
490+ tree2.set_root_id(tree1.path2id(''))
491 tree2.mkdir('a', b'a-new-id')
492 tree2.mkdir('a/reparented', b'reparented-id')
493 tree2.add(['b'], [b'a-old-id'], ['file'])
494@@ -931,7 +931,7 @@
495 tree1.mkdir('a/reparented', b'reparented-id')
496 tree1.mkdir('a/deleted', b'deleted-id')
497 tree2 = self.make_to_branch_and_tree('2')
498- tree2.set_root_id(tree1.get_root_id())
499+ tree2.set_root_id(tree1.path2id(''))
500 tree2.mkdir('a', b'a-new-id')
501 tree2.mkdir('a/reparented', b'reparented-id')
502 tree1, tree2 = self.mutable_trees_to_locked_test_trees(tree1, tree2)
503@@ -955,7 +955,7 @@
504 tree1.mkdir('a/reparented', b'reparented-id')
505 tree1.mkdir('collides', b'collides-id')
506 tree2 = self.make_to_branch_and_tree('2')
507- tree2.set_root_id(tree1.get_root_id())
508+ tree2.set_root_id(tree1.path2id(''))
509 tree2.mkdir('a', b'a-new-id')
510 tree2.mkdir('a/selected', b'selected-id')
511 tree2.mkdir('collides', b'reparented-id')
512@@ -984,7 +984,7 @@
513 tree1.mkdir('a/deleted/reparented', b'reparented-id-2')
514 tree1.mkdir('a/deleted/deleted', b'deleted-id-2')
515 tree2 = self.make_to_branch_and_tree('2')
516- tree2.set_root_id(tree1.get_root_id())
517+ tree2.set_root_id(tree1.path2id(''))
518 tree2.mkdir('a', b'a-new-id')
519 tree2.mkdir('a/reparented', b'reparented-id-1')
520 tree2.mkdir('reparented', b'reparented-id-2')
521@@ -1068,7 +1068,7 @@
522 def test_missing_and_renamed(self):
523 tree1 = self.make_branch_and_tree('tree1')
524 tree2 = self.make_to_branch_and_tree('tree2')
525- tree2.set_root_id(tree1.get_root_id())
526+ tree2.set_root_id(tree1.path2id(''))
527 self.build_tree(['tree1/file'])
528 tree1.add(['file'], [b'file-id'])
529 self.build_tree(['tree2/directory/'])
530@@ -1086,7 +1086,7 @@
531 def test_only_in_source_and_missing(self):
532 tree1 = self.make_branch_and_tree('tree1')
533 tree2 = self.make_to_branch_and_tree('tree2')
534- tree2.set_root_id(tree1.get_root_id())
535+ tree2.set_root_id(tree1.path2id(''))
536 self.build_tree(['tree1/file'])
537 tree1.add(['file'], [b'file-id'])
538 os.unlink('tree1/file')
539@@ -1101,7 +1101,7 @@
540 def test_only_in_target_and_missing(self):
541 tree1 = self.make_branch_and_tree('tree1')
542 tree2 = self.make_to_branch_and_tree('tree2')
543- tree2.set_root_id(tree1.get_root_id())
544+ tree2.set_root_id(tree1.path2id(''))
545 self.build_tree(['tree2/file'])
546 tree2.add(['file'], [b'file-id'])
547 os.unlink('tree2/file')
548@@ -1116,7 +1116,7 @@
549 def test_only_in_target_missing_subtree_specific_bug_367632(self):
550 tree1 = self.make_branch_and_tree('tree1')
551 tree2 = self.make_to_branch_and_tree('tree2')
552- tree2.set_root_id(tree1.get_root_id())
553+ tree2.set_root_id(tree1.path2id(''))
554 self.build_tree(['tree2/a-dir/', 'tree2/a-dir/a-file'])
555 tree2.add(['a-dir', 'a-dir/a-file'], [b'dir-id', b'file-id'])
556 os.unlink('tree2/a-dir/a-file')
557@@ -1226,7 +1226,7 @@
558 def test_default_ignores_unversioned_files(self):
559 tree1 = self.make_branch_and_tree('tree1')
560 tree2 = self.make_to_branch_and_tree('tree2')
561- tree2.set_root_id(tree1.get_root_id())
562+ tree2.set_root_id(tree1.path2id(''))
563 self.build_tree(['tree1/a', 'tree1/c',
564 'tree2/a', 'tree2/b', 'tree2/c'])
565 tree1.add(['a', 'c'], [b'a-id', b'c-id'])
566@@ -1246,7 +1246,7 @@
567 def test_unversioned_paths_in_tree(self):
568 tree1 = self.make_branch_and_tree('tree1')
569 tree2 = self.make_to_branch_and_tree('tree2')
570- tree2.set_root_id(tree1.get_root_id())
571+ tree2.set_root_id(tree1.path2id(''))
572 self.build_tree(['tree2/file', 'tree2/dir/'])
573 if has_symlinks():
574 os.symlink('target', 'tree2/link')
575@@ -1299,7 +1299,7 @@
576 # both foo and bar.
577 tree1 = self.make_branch_and_tree('tree1')
578 tree2 = self.make_to_branch_and_tree('tree2')
579- tree2.set_root_id(tree1.get_root_id())
580+ tree2.set_root_id(tree1.path2id(''))
581 self.build_tree(['tree2/file', 'tree2/dir/',
582 'tree1/file', 'tree2/movedfile',
583 'tree1/dir/', 'tree2/moveddir/'])
584@@ -1343,7 +1343,7 @@
585 """Test when we have a few files with similar names."""
586 tree1 = self.make_branch_and_tree('tree1')
587 tree2 = self.make_branch_and_tree('tree2')
588- tree2.set_root_id(tree1.get_root_id())
589+ tree2.set_root_id(tree1.path2id(''))
590
591 # The trees are actually identical, but they happen to contain
592 # similarly named files.
593@@ -1371,7 +1371,7 @@
594 self.assertEqual([], self.do_iter_changes(tree1, tree2,
595 want_unversioned=True))
596 expected = self.sorted([
597- self.unchanged(tree2, tree2.get_root_id()),
598+ self.unchanged(tree2, tree2.path2id('')),
599 self.unchanged(tree2, b'a-id'),
600 self.unchanged(tree2, b'b-id'),
601 self.unchanged(tree2, b'c-id'),
602@@ -1387,7 +1387,7 @@
603 def test_unversioned_subtree_only_emits_root(self):
604 tree1 = self.make_branch_and_tree('tree1')
605 tree2 = self.make_to_branch_and_tree('tree2')
606- tree2.set_root_id(tree1.get_root_id())
607+ tree2.set_root_id(tree1.path2id(''))
608 self.build_tree(['tree2/dir/', 'tree2/dir/file'])
609 tree1, tree2 = self.mutable_trees_to_test_trees(self, tree1, tree2)
610 self.not_applicable_if_cannot_represent_unversioned(tree2)
611@@ -1400,7 +1400,7 @@
612 def make_trees_with_symlinks(self):
613 tree1 = self.make_branch_and_tree('tree1')
614 tree2 = self.make_to_branch_and_tree('tree2')
615- tree2.set_root_id(tree1.get_root_id())
616+ tree2.set_root_id(tree1.path2id(''))
617 self.build_tree(['tree1/fromfile', 'tree1/fromdir/'])
618 self.build_tree(['tree2/tofile', 'tree2/todir/', 'tree2/unknown'])
619 os.symlink('original', 'tree1/changed')
620@@ -1500,7 +1500,7 @@
621 def test_trees_with_deleted_dir(self):
622 tree1 = self.make_branch_and_tree('tree1')
623 tree2 = self.make_to_branch_and_tree('tree2')
624- tree2.set_root_id(tree1.get_root_id())
625+ tree2.set_root_id(tree1.path2id(''))
626 self.build_tree(['tree1/a', 'tree1/b/', 'tree1/b/c',
627 'tree1/b/d/', 'tree1/b/d/e', 'tree1/f/', 'tree1/f/g',
628 'tree2/a', 'tree2/f/', 'tree2/f/g'])
629@@ -1525,7 +1525,7 @@
630 def test_added_unicode(self):
631 tree1 = self.make_branch_and_tree('tree1')
632 tree2 = self.make_to_branch_and_tree('tree2')
633- root_id = tree1.get_root_id()
634+ root_id = tree1.path2id('')
635 tree2.set_root_id(root_id)
636
637 # u'\u03b1' == GREEK SMALL LETTER ALPHA
638@@ -1554,7 +1554,7 @@
639 def test_deleted_unicode(self):
640 tree1 = self.make_branch_and_tree('tree1')
641 tree2 = self.make_to_branch_and_tree('tree2')
642- root_id = tree1.get_root_id()
643+ root_id = tree1.path2id('')
644 tree2.set_root_id(root_id)
645
646 # u'\u03b1' == GREEK SMALL LETTER ALPHA
647@@ -1583,7 +1583,7 @@
648 def test_modified_unicode(self):
649 tree1 = self.make_branch_and_tree('tree1')
650 tree2 = self.make_to_branch_and_tree('tree2')
651- root_id = tree1.get_root_id()
652+ root_id = tree1.path2id('')
653 tree2.set_root_id(root_id)
654
655 # u'\u03b1' == GREEK SMALL LETTER ALPHA
656@@ -1613,7 +1613,7 @@
657 def test_renamed_unicode(self):
658 tree1 = self.make_branch_and_tree('tree1')
659 tree2 = self.make_to_branch_and_tree('tree2')
660- root_id = tree1.get_root_id()
661+ root_id = tree1.path2id('')
662 tree2.set_root_id(root_id)
663
664 # u'\u03b1' == GREEK SMALL LETTER ALPHA
665@@ -1644,7 +1644,7 @@
666 def test_unchanged_unicode(self):
667 tree1 = self.make_branch_and_tree('tree1')
668 tree2 = self.make_to_branch_and_tree('tree2')
669- root_id = tree1.get_root_id()
670+ root_id = tree1.path2id('')
671 tree2.set_root_id(root_id)
672 # u'\u03b1' == GREEK SMALL LETTER ALPHA
673 # u'\u03c9' == GREEK SMALL LETTER OMEGA
674@@ -1692,7 +1692,7 @@
675 def test_unknown_unicode(self):
676 tree1 = self.make_branch_and_tree('tree1')
677 tree2 = self.make_to_branch_and_tree('tree2')
678- root_id = tree1.get_root_id()
679+ root_id = tree1.path2id('')
680 tree2.set_root_id(root_id)
681 # u'\u03b1' == GREEK SMALL LETTER ALPHA
682 # u'\u03c9' == GREEK SMALL LETTER OMEGA
683@@ -1746,7 +1746,7 @@
684 def test_unknown_empty_dir(self):
685 tree1 = self.make_branch_and_tree('tree1')
686 tree2 = self.make_to_branch_and_tree('tree2')
687- root_id = tree1.get_root_id()
688+ root_id = tree1.path2id('')
689 tree2.set_root_id(root_id)
690
691 # Start with 2 identical trees
692@@ -1788,7 +1788,7 @@
693 def test_rename_over_deleted(self):
694 tree1 = self.make_branch_and_tree('tree1')
695 tree2 = self.make_to_branch_and_tree('tree2')
696- root_id = tree1.get_root_id()
697+ root_id = tree1.path2id('')
698 tree2.set_root_id(root_id)
699
700 # The final changes should be:
701@@ -1825,7 +1825,7 @@
702 """Test a file marked removed, but still present on disk."""
703 tree1 = self.make_branch_and_tree('tree1')
704 tree2 = self.make_to_branch_and_tree('tree2')
705- root_id = tree1.get_root_id()
706+ root_id = tree1.path2id('')
707 tree2.set_root_id(root_id)
708
709 # The final changes should be:
710@@ -1863,7 +1863,7 @@
711 """Test when we have renamed a file, and put another in its place."""
712 tree1 = self.make_branch_and_tree('tree1')
713 tree2 = self.make_to_branch_and_tree('tree2')
714- root_id = tree1.get_root_id()
715+ root_id = tree1.path2id('')
716 tree2.set_root_id(root_id)
717
718 # The final changes are:
719@@ -1900,7 +1900,7 @@
720 """A file was moved on the filesystem, but not in bzr."""
721 tree1 = self.make_branch_and_tree('tree1')
722 tree2 = self.make_to_branch_and_tree('tree2')
723- root_id = tree1.get_root_id()
724+ root_id = tree1.path2id('')
725 tree2.set_root_id(root_id)
726
727 # The final changes are:
728@@ -1921,7 +1921,7 @@
729 self.not_applicable_if_missing_in('a', tree2)
730
731 expected = self.sorted([
732- self.missing(b'a-id', 'a', 'a', tree2.get_root_id(), 'file'),
733+ self.missing(b'a-id', 'a', 'a', tree2.path2id(''), 'file'),
734 self.unversioned(tree2, 'a2'),
735 ])
736 self.assertEqual(expected,
737
738=== modified file 'breezy/tests/per_repository/test_commit_builder.py'
739--- breezy/tests/per_repository/test_commit_builder.py 2019-06-16 17:36:59 +0000
740+++ breezy/tests/per_repository/test_commit_builder.py 2019-07-25 23:25:31 +0000
741@@ -176,7 +176,7 @@
742 builder.finish_inventory()
743 builder.commit('rev')
744 builder_tree = builder.revision_tree()
745- new_root_id = builder_tree.get_root_id()
746+ new_root_id = builder_tree.path2id('')
747 new_root_revision = builder_tree.get_file_revision(u'')
748 if tree.branch.repository.supports_rich_root():
749 # We should not have seen a new root revision
750@@ -332,7 +332,7 @@
751 try:
752 tree.add_reference(subtree)
753 self._commit_check_unchanged(tree, 'reference',
754- subtree.get_root_id())
755+ subtree.path2id(''))
756 except errors.UnsupportedOperation:
757 return
758
759
760=== modified file 'breezy/tests/per_repository/test_repository.py'
761--- breezy/tests/per_repository/test_repository.py 2019-06-26 23:12:10 +0000
762+++ breezy/tests/per_repository/test_repository.py 2019-07-25 23:25:31 +0000
763@@ -485,7 +485,6 @@
764 rev_tree = tree.branch.repository.revision_tree(tree.last_revision())
765 rev_tree.lock_read()
766 self.addCleanup(rev_tree.unlock)
767- root_id = rev_tree.get_root_id()
768 self.assertEqual(revid, rev_tree.get_file_revision(u''))
769
770 def test_pointless_commit(self):
771
772=== modified file 'breezy/tests/per_repository_vf/test_fileid_involved.py'
773--- breezy/tests/per_repository_vf/test_fileid_involved.py 2019-06-17 23:01:58 +0000
774+++ breezy/tests/per_repository_vf/test_fileid_involved.py 2019-07-25 23:25:31 +0000
775@@ -277,7 +277,7 @@
776 def fileids_altered_by_revision_ids(self, revision_ids):
777 """This is a wrapper to strip TREE_ROOT if it occurs"""
778 repo = self.branch.repository
779- root_id = self.branch.basis_tree().get_root_id()
780+ root_id = self.branch.basis_tree().path2id('')
781 result = repo.fileids_altered_by_revision_ids(revision_ids)
782 if root_id in result:
783 del result[root_id]
784@@ -352,7 +352,7 @@
785 repo.lock_read()
786 self.addCleanup(repo.unlock)
787 file_ids = repo.fileids_altered_by_revision_ids([revision_id])
788- root_id = main_wt.basis_tree().get_root_id()
789+ root_id = main_wt.basis_tree().path2id('')
790 if root_id in file_ids:
791 self.assertEqual({file_id: {revision_id},
792 root_id: {revision_id}
793
794=== modified file 'breezy/tests/per_repository_vf/test_repository.py'
795--- breezy/tests/per_repository_vf/test_repository.py 2019-05-29 03:22:34 +0000
796+++ breezy/tests/per_repository_vf/test_repository.py 2019-07-25 23:25:31 +0000
797@@ -280,7 +280,7 @@
798 'file_id %r cannot be stored on this'
799 ' platform for this repo format' % (file_id,))
800 if repo._format.rich_root_data:
801- root_commit = (tree.get_root_id(),) + rev_key
802+ root_commit = (tree.path2id(''),) + rev_key
803 keys = {root_commit}
804 parents = {root_commit: ()}
805 else:
806
807=== modified file 'breezy/tests/per_tree/test_get_root_id.py'
808--- breezy/tests/per_tree/test_get_root_id.py 2018-11-11 04:08:32 +0000
809+++ breezy/tests/per_tree/test_get_root_id.py 2019-07-25 23:25:31 +0000
810@@ -14,7 +14,7 @@
811 # along with this program; if not, write to the Free Software
812 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
813
814-"""Tests for Tree.get_root_id()"""
815+"""Tests for Tree.path2id('')"""
816
817 from breezy.tests.per_tree import TestCaseWithTree
818
819@@ -40,9 +40,9 @@
820 def test_get_root_id_default(self):
821 tree = self.make_tree_with_default_root_id()
822 with tree.lock_read():
823- self.assertIsNot(None, tree.get_root_id())
824+ self.assertIsNot(None, tree.path2id(''))
825
826 def test_get_root_id_fixed(self):
827 tree = self.make_tree_with_fixed_root_id()
828 with tree.lock_read():
829- self.assertEqual(b'custom-tree-root-id', tree.get_root_id())
830+ self.assertEqual(b'custom-tree-root-id', tree.path2id(''))
831
832=== modified file 'breezy/tests/per_tree/test_ids.py'
833--- breezy/tests/per_tree/test_ids.py 2018-11-11 04:08:32 +0000
834+++ breezy/tests/per_tree/test_ids.py 2019-07-25 23:25:31 +0000
835@@ -43,7 +43,7 @@
836 self.assertEqual(b'bla-id', self.tree_a.path2id(['bla']))
837 self.assertEqual(b'dir-id', self.tree_a.path2id(['dir']))
838 self.assertEqual(b'file-id', self.tree_a.path2id(['dir', 'file']))
839- self.assertEqual(self.tree_a.get_root_id(),
840+ self.assertEqual(self.tree_a.path2id(''),
841 self.tree_a.path2id([]))
842 self.assertIs(None, self.tree_a.path2id(['idontexist']))
843 self.assertIs(None, self.tree_a.path2id(['dir', 'idontexist']))
844
845=== modified file 'breezy/tests/per_tree/test_test_trees.py'
846--- breezy/tests/per_tree/test_test_trees.py 2018-11-19 23:04:59 +0000
847+++ breezy/tests/per_tree/test_test_trees.py 2019-07-25 23:25:31 +0000
848@@ -273,7 +273,7 @@
849 b'ba\xe2\x82\xacz-id',
850 ]
851 self.build_tree(paths[1:])
852- if tree.get_root_id() is None:
853+ if tree.path2id('') is None:
854 # Some trees do not have a root yet.
855 tree.add(paths, file_ids)
856 else:
857
858=== modified file 'breezy/tests/per_tree/test_tree.py'
859--- breezy/tests/per_tree/test_tree.py 2019-06-29 12:29:45 +0000
860+++ breezy/tests/per_tree/test_tree.py 2019-07-25 23:25:31 +0000
861@@ -120,7 +120,7 @@
862 def test_get_root_id(self):
863 # trees should return some kind of root id; it can be none
864 tree = self.make_branch_and_tree('tree')
865- root_id = tree.get_root_id()
866+ root_id = tree.path2id('')
867 if root_id is not None:
868 self.assertIsInstance(root_id, bytes)
869
870
871=== modified file 'breezy/tests/per_workingtree/test_add.py'
872--- breezy/tests/per_workingtree/test_add.py 2018-11-11 04:08:32 +0000
873+++ breezy/tests/per_workingtree/test_add.py 2019-07-25 23:25:31 +0000
874@@ -103,7 +103,7 @@
875 tree.add(['dir'], [b'dir-id'])
876 tree.add(['dir/subdir'], [b'subdir-id'])
877 tree.add(['dir/subdir/foo'], [b'foo-id'])
878- root_id = tree.get_root_id()
879+ root_id = tree.path2id('')
880
881 self.assertTreeLayout([('', root_id), ('dir/', b'dir-id'),
882 ('dir/subdir/', b'subdir-id'),
883@@ -136,7 +136,7 @@
884 tree.add(['a', 'b', 'dir', 'dir/subdir', 'dir/subdir/foo'],
885 [b'a-id', b'b-id', b'dir-id', b'subdir-id', b'foo-id'])
886
887- self.assertTreeLayout([('', tree.get_root_id()), ('a', b'a-id'), ('b', b'b-id'),
888+ self.assertTreeLayout([('', tree.path2id('')), ('a', b'a-id'), ('b', b'b-id'),
889 ('dir/', b'dir-id'), ('dir/subdir/', b'subdir-id'),
890 ('dir/subdir/foo', b'foo-id')], tree)
891
892
893=== modified file 'breezy/tests/per_workingtree/test_add_reference.py'
894--- breezy/tests/per_workingtree/test_add_reference.py 2018-11-16 18:33:17 +0000
895+++ breezy/tests/per_workingtree/test_add_reference.py 2019-07-25 23:25:31 +0000
896@@ -49,7 +49,7 @@
897
898 def test_add_reference(self):
899 tree, sub_tree = self.make_nested_trees()
900- sub_tree_root_id = sub_tree.get_root_id()
901+ sub_tree_root_id = sub_tree.path2id('')
902 with tree.lock_write():
903 if tree.supports_setting_file_ids():
904 self.assertEqual(tree.path2id('sub-tree'), sub_tree_root_id)
905@@ -101,7 +101,7 @@
906
907 def test_get_nested_tree(self):
908 tree, sub_tree = self.make_nested_trees()
909- sub_tree_root_id = sub_tree.get_root_id()
910+ sub_tree_root_id = sub_tree.path2id('')
911 with tree.lock_read():
912 sub_tree2 = tree.get_nested_tree('sub-tree')
913 self.assertEqual(sub_tree.basedir, sub_tree2.basedir)
914
915=== modified file 'breezy/tests/per_workingtree/test_commit.py'
916--- breezy/tests/per_workingtree/test_commit.py 2018-11-11 04:08:32 +0000
917+++ breezy/tests/per_workingtree/test_commit.py 2019-07-25 23:25:31 +0000
918@@ -53,13 +53,10 @@
919 osutils.rmtree('a/dir')
920 tree_a.commit('autoremoved')
921
922- tree_a.lock_read()
923- try:
924- root_id = tree_a.get_root_id()
925+ with tree_a.lock_read():
926+ root_id = tree_a.path2id('')
927 paths = [(path, ie.file_id)
928 for path, ie in tree_a.iter_entries_by_dir()]
929- finally:
930- tree_a.unlock()
931 # The only paths left should be the root
932 self.assertEqual([('', root_id)], paths)
933
934
935=== modified file 'breezy/tests/per_workingtree/test_flush.py'
936--- breezy/tests/per_workingtree/test_flush.py 2018-03-25 00:39:16 +0000
937+++ breezy/tests/per_workingtree/test_flush.py 2019-07-25 23:25:31 +0000
938@@ -26,11 +26,8 @@
939
940 def test_flush_fresh_tree(self):
941 tree = self.make_branch_and_tree('t1')
942- tree.lock_write()
943- try:
944+ with tree.lock_write():
945 tree.flush()
946- finally:
947- tree.unlock()
948
949 def test_flush_when_inventory_is_modified(self):
950 if sys.platform == "win32":
951@@ -49,30 +46,24 @@
952 tree = self.make_branch_and_tree('tree')
953 # prepare for a series of changes that will modify the
954 # inventory
955- tree.lock_write()
956- try:
957- old_root = tree.get_root_id()
958+ with tree.lock_write():
959+ old_root = tree.path2id('')
960 tree.add('')
961 # to detect that the inventory is written by flush, we
962 # first check that it was not written yet.
963 reference_tree = tree.controldir.open_workingtree()
964- self.assertEqual(old_root, reference_tree.get_root_id())
965+ self.assertEqual(old_root, reference_tree.path2id(''))
966 # now flush the tree which should write the inventory.
967 tree.flush()
968 # and check it was written using another reference tree
969 reference_tree = tree.controldir.open_workingtree()
970- self.assertIsNot(None, reference_tree.get_root_id())
971- finally:
972- tree.unlock()
973+ self.assertIsNot(None, reference_tree.path2id(''))
974
975 def test_flush_with_read_lock_fails(self):
976 """Flush cannot be used during a read lock."""
977 tree = self.make_branch_and_tree('t1')
978- tree.lock_read()
979- try:
980+ with tree.lock_read():
981 self.assertRaises(errors.NotWriteLocked, tree.flush)
982- finally:
983- tree.unlock()
984
985 def test_flush_with_no_lock_fails(self):
986 tree = self.make_branch_and_tree('t1')
987
988=== modified file 'breezy/tests/per_workingtree/test_inv.py'
989--- breezy/tests/per_workingtree/test_inv.py 2018-11-11 04:08:32 +0000
990+++ breezy/tests/per_workingtree/test_inv.py 2019-07-25 23:25:31 +0000
991@@ -53,7 +53,7 @@
992 wt = self.make_branch_and_tree('.')
993 wt.lock_write()
994 self.addCleanup(wt.unlock)
995- root_id = wt.get_root_id()
996+ root_id = wt.path2id('')
997 wt.apply_inventory_delta([(None, 'bar/foo', b'foo-id',
998 inventory.InventoryFile(b'foo-id', 'foo', parent_id=b'bar-id')),
999 (None, 'bar', b'bar-id', inventory.InventoryDirectory(b'bar-id',
1000@@ -74,7 +74,7 @@
1001 def test_rename_dir_with_children(self):
1002 wt = self.make_branch_and_tree('.')
1003 wt.lock_write()
1004- root_id = wt.get_root_id()
1005+ root_id = wt.path2id('')
1006 self.addCleanup(wt.unlock)
1007 self.build_tree(['foo/', 'foo/bar'])
1008 wt.add(['foo', 'foo/bar'],
1009@@ -88,7 +88,7 @@
1010 def test_rename_dir_with_children_with_children(self):
1011 wt = self.make_branch_and_tree('.')
1012 wt.lock_write()
1013- root_id = wt.get_root_id()
1014+ root_id = wt.path2id('')
1015 self.addCleanup(wt.unlock)
1016 self.build_tree(['foo/', 'foo/bar/', 'foo/bar/baz'])
1017 wt.add(['foo', 'foo/bar', 'foo/bar/baz'],
1018@@ -118,7 +118,7 @@
1019 """
1020 wt = self.make_branch_and_tree('.')
1021 wt.lock_write()
1022- root_id = wt.get_root_id()
1023+ root_id = wt.path2id('')
1024 self.addCleanup(wt.unlock)
1025 self.build_tree(['foo/', 'foo/bar', 'baz/', 'baz/qux'])
1026 wt.add(['foo', 'foo/bar', 'baz', 'baz/qux'],
1027@@ -137,7 +137,7 @@
1028 unable to find the child.)
1029 """
1030 wt = self.make_branch_and_tree('.')
1031- root_id = wt.get_root_id()
1032+ root_id = wt.path2id('')
1033 self.build_tree(['dir/', 'dir/child', 'other/'])
1034 wt.add(['dir', 'dir/child', 'other'],
1035 [b'dir-id', b'child-id', b'other-id'])
1036@@ -155,7 +155,7 @@
1037 wt.lock_write()
1038 self.addCleanup(wt.unlock)
1039
1040- root_id = wt.get_root_id()
1041+ root_id = wt.path2id('')
1042 wt.apply_inventory_delta([('', None, root_id, None),
1043 (None, '', b'root-id',
1044 inventory.InventoryDirectory(b'root-id', '', None))])
1045
1046=== modified file 'breezy/tests/per_workingtree/test_locking.py'
1047--- breezy/tests/per_workingtree/test_locking.py 2018-03-25 00:39:16 +0000
1048+++ breezy/tests/per_workingtree/test_locking.py 2019-07-25 23:25:31 +0000
1049@@ -148,23 +148,23 @@
1050 # e.g. mkdir('foo') but all the mutating methods at the
1051 # moment trigger inventory writes and thus will not
1052 # let us trigger a read-when-dirty situation.
1053- old_root = tree.get_root_id()
1054+ old_root = tree.path2id('')
1055 tree.add('')
1056 # to detect that the inventory is written by unlock, we
1057 # first check that it was not written yet.
1058 # TODO: This requires taking a read lock while we are holding the above
1059 # write lock, which shouldn't actually be possible
1060 reference_tree = tree.controldir.open_workingtree()
1061- self.assertEqual(old_root, reference_tree.get_root_id())
1062+ self.assertEqual(old_root, reference_tree.path2id(''))
1063 # now unlock the second held lock, which should do nothing.
1064 tree.unlock()
1065 reference_tree = tree.controldir.open_workingtree()
1066- self.assertEqual(old_root, reference_tree.get_root_id())
1067+ self.assertEqual(old_root, reference_tree.path2id(''))
1068 # unlocking the first lock we took will now flush.
1069 tree.unlock()
1070 # and check it was written using another reference tree
1071 reference_tree = tree.controldir.open_workingtree()
1072- self.assertIsNot(None, reference_tree.get_root_id())
1073+ self.assertIsNot(None, reference_tree.path2id(''))
1074
1075 def test_unlock_from_tree_write_lock_flushes(self):
1076 self._test_unlock_with_lock_method("lock_tree_write")
1077
1078=== modified file 'breezy/tests/per_workingtree/test_merge_from_branch.py'
1079--- breezy/tests/per_workingtree/test_merge_from_branch.py 2019-06-17 19:04:30 +0000
1080+++ breezy/tests/per_workingtree/test_merge_from_branch.py 2019-07-25 23:25:31 +0000
1081@@ -166,7 +166,7 @@
1082 inner, to_revision=revs[0], from_revision=b'null:')
1083 # retain original root id.
1084 if outer.supports_setting_file_ids():
1085- outer.set_root_id(outer.basis_tree().get_root_id())
1086+ outer.set_root_id(outer.basis_tree().path2id(''))
1087 outer.commit('merge inner branch')
1088 outer.mkdir('dir-outer')
1089 outer.move(['dir', 'file3'], to_dir='dir-outer')
1090
1091=== modified file 'breezy/tests/per_workingtree/test_pull.py'
1092--- breezy/tests/per_workingtree/test_pull.py 2018-11-11 04:08:32 +0000
1093+++ breezy/tests/per_workingtree/test_pull.py 2019-07-25 23:25:31 +0000
1094@@ -33,9 +33,9 @@
1095
1096 def test_pull_null(self):
1097 tree_a, tree_b, rev_a = self.get_pullable_trees()
1098- root_id = tree_a.get_root_id()
1099+ root_id = tree_a.path2id('')
1100 tree_a.pull(tree_b.branch, stop_revision=NULL_REVISION, overwrite=True)
1101- self.assertEqual(root_id, tree_a.get_root_id())
1102+ self.assertEqual(root_id, tree_a.path2id(''))
1103
1104 def test_pull(self):
1105 tree_a, tree_b, rev_a = self.get_pullable_trees()
1106@@ -66,11 +66,11 @@
1107 tree.add(['file'])
1108 tree.commit('first')
1109 to_tree = tree.controldir.sprout('to').open_workingtree()
1110- self.assertEqual(b'first_root_id', to_tree.get_root_id())
1111+ self.assertEqual(b'first_root_id', to_tree.path2id(''))
1112 tree.set_root_id(b'second_root_id')
1113 tree.commit('second')
1114 to_tree.pull(tree.branch)
1115- self.assertEqual(b'second_root_id', to_tree.get_root_id())
1116+ self.assertEqual(b'second_root_id', to_tree.path2id(''))
1117
1118
1119 class TestPullWithOrphans(per_workingtree.TestCaseWithWorkingTree):
1120
1121=== modified file 'breezy/tests/per_workingtree/test_rename_one.py'
1122--- breezy/tests/per_workingtree/test_rename_one.py 2018-11-11 04:08:32 +0000
1123+++ breezy/tests/per_workingtree/test_rename_one.py 2019-07-25 23:25:31 +0000
1124@@ -342,7 +342,6 @@
1125 self.build_tree(['a/', 'a/b', 'c/'])
1126 tree.add(['a', 'a/b', 'c'])
1127 tree.commit('initial')
1128- root_id = tree.get_root_id()
1129
1130 tree.rename_one('a/b', 'c/foo')
1131 self.assertPathRelations(
1132
1133=== modified file 'breezy/tests/per_workingtree/test_set_root_id.py'
1134--- breezy/tests/per_workingtree/test_set_root_id.py 2018-02-18 15:21:06 +0000
1135+++ breezy/tests/per_workingtree/test_set_root_id.py 2019-07-25 23:25:31 +0000
1136@@ -36,25 +36,22 @@
1137 self.skipTest('format does not support setting file ids')
1138 # setting the root id allows it to be read via get_root_id.
1139 root_id = u'\xe5n-id'.encode('utf8')
1140- tree.lock_write()
1141- try:
1142- old_id = tree.get_root_id()
1143+ with tree.lock_write():
1144+ old_id = tree.path2id('')
1145 tree.set_root_id(root_id)
1146- self.assertEqual(root_id, tree.get_root_id())
1147+ self.assertEqual(root_id, tree.path2id(''))
1148 # set root id should not have triggered a flush of the tree,
1149 # so check a new tree sees the old state.
1150 reference_tree = tree.controldir.open_workingtree()
1151- self.assertEqual(old_id, reference_tree.get_root_id())
1152- finally:
1153- tree.unlock()
1154+ self.assertEqual(old_id, reference_tree.path2id(''))
1155 # having unlocked the tree, the value should have been
1156 # preserved into the next lock, which is an implicit read
1157 # lock around the get_root_id call.
1158- self.assertEqual(root_id, tree.get_root_id())
1159+ self.assertEqual(root_id, tree.path2id(''))
1160 # and if we get a new working tree instance, then the value
1161 # should still be retained
1162 tree = tree.controldir.open_workingtree()
1163- self.assertEqual(root_id, tree.get_root_id())
1164+ self.assertEqual(root_id, tree.path2id(''))
1165 tree._validate()
1166
1167 def test_set_root_id(self):
1168@@ -63,12 +60,12 @@
1169 self.skipTest('format does not support setting file ids')
1170 tree.lock_write()
1171 self.addCleanup(tree.unlock)
1172- orig_root_id = tree.get_root_id()
1173+ orig_root_id = tree.path2id('')
1174 self.assertNotEqual(b'custom-root-id', orig_root_id)
1175 self.assertEqual('', tree.id2path(orig_root_id))
1176 self.assertRaises(errors.NoSuchId, tree.id2path, 'custom-root-id')
1177 tree.set_root_id(b'custom-root-id')
1178- self.assertEqual(b'custom-root-id', tree.get_root_id())
1179+ self.assertEqual(b'custom-root-id', tree.path2id(''))
1180 self.assertEqual(b'custom-root-id', tree.path2id(''))
1181 self.assertEqual('', tree.id2path(b'custom-root-id'))
1182 self.assertRaises(errors.NoSuchId, tree.id2path, orig_root_id)
1183
1184=== modified file 'breezy/tests/per_workingtree/test_workingtree.py'
1185--- breezy/tests/per_workingtree/test_workingtree.py 2019-06-22 10:30:21 +0000
1186+++ breezy/tests/per_workingtree/test_workingtree.py 2019-07-25 23:25:31 +0000
1187@@ -575,8 +575,8 @@
1188 # and update checkout
1189 self.assertEqual(0, checkout.update())
1190 self.assertPathExists('checkout/file')
1191- self.assertEqual(wt.get_root_id(), checkout.get_root_id())
1192- self.assertNotEqual(None, wt.get_root_id())
1193+ self.assertEqual(wt.path2id(''), checkout.path2id(''))
1194+ self.assertNotEqual(None, wt.path2id(''))
1195
1196 def test_update_sets_updated_root_id(self):
1197 wt = self.make_branch_and_tree('tree')
1198@@ -585,16 +585,16 @@
1199 'first_root_id')
1200 return
1201 wt.set_root_id(b'first_root_id')
1202- self.assertEqual(b'first_root_id', wt.get_root_id())
1203+ self.assertEqual(b'first_root_id', wt.path2id(''))
1204 self.build_tree(['tree/file'])
1205 wt.add(['file'])
1206 wt.commit('first')
1207 co = wt.branch.create_checkout('checkout')
1208 wt.set_root_id(b'second_root_id')
1209 wt.commit('second')
1210- self.assertEqual(b'second_root_id', wt.get_root_id())
1211+ self.assertEqual(b'second_root_id', wt.path2id(''))
1212 self.assertEqual(0, co.update())
1213- self.assertEqual(b'second_root_id', co.get_root_id())
1214+ self.assertEqual(b'second_root_id', co.path2id(''))
1215
1216 def test_update_returns_conflict_count(self):
1217 # working tree formats from the meta-dir format and newer support
1218@@ -920,7 +920,7 @@
1219 # if we write write an inventory then do a walkdirs we should get back
1220 # missing entries, and actual, and unknowns as appropriate.
1221 self.build_tree(['present', 'unknown'])
1222- inventory = Inventory(tree.get_root_id())
1223+ inventory = Inventory(tree.path2id(''))
1224 inventory.add_path('missing', 'file', b'missing-id')
1225 inventory.add_path('present', 'file', b'present-id')
1226 # there is no point in being able to write an inventory to an unlocked
1227@@ -932,7 +932,7 @@
1228 present_stat = os.lstat('present')
1229 unknown_stat = os.lstat('unknown')
1230 expected_results = [
1231- (('', tree.get_root_id()),
1232+ (('', tree.path2id('')),
1233 [('missing', 'missing', 'unknown', None, b'missing-id', 'file'),
1234 ('present', 'present', 'file',
1235 present_stat, b'present-id', 'file'),
1236
1237=== modified file 'breezy/tests/test__dirstate_helpers.py'
1238--- breezy/tests/test__dirstate_helpers.py 2019-06-15 12:04:34 +0000
1239+++ breezy/tests/test__dirstate_helpers.py 2019-07-25 23:25:31 +0000
1240@@ -1326,7 +1326,7 @@
1241 tree = self.make_branch_and_tree('tree')
1242 self.build_tree(['tree/file'])
1243 tree.add(['file'], [b'file-id'])
1244- self.assertChangedFileIds([tree.get_root_id(), b'file-id'], tree)
1245+ self.assertChangedFileIds([tree.path2id(''), b'file-id'], tree)
1246 tree.commit('one')
1247 self.assertChangedFileIds([], tree)
1248
1249
1250=== modified file 'breezy/tests/test_commit_merge.py'
1251--- breezy/tests/test_commit_merge.py 2018-11-11 04:08:32 +0000
1252+++ breezy/tests/test_commit_merge.py 2019-07-25 23:25:31 +0000
1253@@ -76,7 +76,7 @@
1254 bx = wtx.branch
1255 wtx.commit('establish root id')
1256 wty = wtx.controldir.sprout('y').open_workingtree()
1257- self.assertEqual(wtx.get_root_id(), wty.get_root_id())
1258+ self.assertEqual(wtx.path2id(''), wty.path2id(''))
1259 by = wty.branch
1260
1261 self.build_tree(['x/ecks', 'y/why'])
1262
1263=== modified file 'breezy/tests/test_dirstate.py'
1264--- breezy/tests/test_dirstate.py 2019-06-03 22:25:41 +0000
1265+++ breezy/tests/test_dirstate.py 2019-07-25 23:25:31 +0000
1266@@ -394,7 +394,7 @@
1267 # There are no files on disk and no parents
1268 tree = self.make_branch_and_tree('tree')
1269 expected_result = ([], [
1270- ((b'', b'', tree.get_root_id()), # common details
1271+ ((b'', b'', tree.path2id('')), # common details
1272 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1273 ])])
1274 state = dirstate.DirState.from_tree(tree, 'dirstate')
1275@@ -407,7 +407,7 @@
1276 rev_id = tree.commit('first post')
1277 root_stat_pack = dirstate.pack_stat(os.stat(tree.basedir))
1278 expected_result = ([rev_id], [
1279- ((b'', b'', tree.get_root_id()), # common details
1280+ ((b'', b'', tree.path2id('')), # common details
1281 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1282 (b'd', b'', 0, False, rev_id), # first parent details
1283 ])])
1284@@ -427,7 +427,7 @@
1285 rev_id2 = tree2.commit('second post', allow_pointless=True)
1286 tree.merge_from_branch(tree2.branch)
1287 expected_result = ([rev_id, rev_id2], [
1288- ((b'', b'', tree.get_root_id()), # common details
1289+ ((b'', b'', tree.path2id('')), # common details
1290 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1291 (b'd', b'', 0, False, rev_id), # first parent details
1292 (b'd', b'', 0, False, rev_id), # second parent details
1293@@ -446,7 +446,7 @@
1294 tree = self.make_branch_and_tree('tree')
1295 self.build_tree(['tree/unknown'])
1296 expected_result = ([], [
1297- ((b'', b'', tree.get_root_id()), # common details
1298+ ((b'', b'', tree.path2id('')), # common details
1299 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1300 ])])
1301 state = dirstate.DirState.from_tree(tree, 'dirstate')
1302@@ -463,7 +463,7 @@
1303 # There are files on disk and no parents
1304 tree = self.get_tree_with_a_file()
1305 expected_result = ([], [
1306- ((b'', b'', tree.get_root_id()), # common details
1307+ ((b'', b'', tree.path2id('')), # common details
1308 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1309 ]),
1310 ((b'', b'a file', b'a-file-id'), # common
1311@@ -481,7 +481,7 @@
1312 # and length:
1313 self.build_tree_contents([('tree/a file', b'new content\n')])
1314 expected_result = ([rev_id], [
1315- ((b'', b'', tree.get_root_id()), # common details
1316+ ((b'', b'', tree.path2id('')), # common details
1317 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1318 (b'd', b'', 0, False, rev_id), # first parent details
1319 ]),
1320@@ -508,7 +508,7 @@
1321 # and length again, giving us three distinct values:
1322 self.build_tree_contents([('tree/a file', b'new content\n')])
1323 expected_result = ([rev_id, rev_id2], [
1324- ((b'', b'', tree.get_root_id()), # common details
1325+ ((b'', b'', tree.path2id('')), # common details
1326 [(b'd', b'', 0, False, dirstate.DirState.NULLSTAT), # current tree
1327 (b'd', b'', 0, False, rev_id), # first parent details
1328 (b'd', b'', 0, False, rev_id), # second parent details
1329@@ -573,7 +573,7 @@
1330 # get a state object
1331 # no parents, default tree content
1332 expected_result = ([], [
1333- ((b'', b'', tree.get_root_id()), # common details
1334+ ((b'', b'', tree.path2id('')), # common details
1335 # current tree details, but new from_tree skips statting, it
1336 # uses set_state_from_inventory, and thus depends on the
1337 # inventory state.
1338@@ -899,7 +899,7 @@
1339 tree1.add(['a', 'a/b', 'a-b', 'a/b/foo', 'a-b/bar'],
1340 [b'a-id', b'b-id', b'a-b-id', b'foo-id', b'bar-id'])
1341 tree1.commit('rev1', rev_id=b'rev1')
1342- root_id = tree1.get_root_id()
1343+ root_id = tree1.path2id('')
1344 inv = tree1.root_inventory
1345 finally:
1346 tree1.unlock()
1347@@ -1045,7 +1045,7 @@
1348 tree2.lock_write()
1349 try:
1350 revid2 = tree2.commit('foo')
1351- root_id = tree2.get_root_id()
1352+ root_id = tree2.path2id('')
1353 finally:
1354 tree2.unlock()
1355 state = dirstate.DirState.initialize('dirstate')
1356@@ -1116,7 +1116,7 @@
1357 try:
1358 tree2.put_file_bytes_non_atomic('a file', b'new file-content')
1359 revid2 = tree2.commit('foo')
1360- root_id = tree2.get_root_id()
1361+ root_id = tree2.path2id('')
1362 finally:
1363 tree2.unlock()
1364 # check the layout in memory
1365@@ -1337,10 +1337,9 @@
1366 # incorrect absent in tree 1, and future changes go to pot.
1367 tree1 = self.make_branch_and_tree('tree1')
1368 self.build_tree(['tree1/b'])
1369- tree1.lock_write()
1370- try:
1371+ with tree1.lock_write():
1372 tree1.add(['b'], [b'b-id'])
1373- root_id = tree1.get_root_id()
1374+ root_id = tree1.path2id('')
1375 inv = tree1.root_inventory
1376 state = dirstate.DirState.initialize('dirstate')
1377 try:
1378@@ -1358,8 +1357,6 @@
1379 self.assertEqual(expected_result1, values)
1380 finally:
1381 state.unlock()
1382- finally:
1383- tree1.unlock()
1384
1385
1386 class TestDirStateHashUpdates(TestCaseWithDirState):
1387
1388=== modified file 'breezy/tests/test_extract.py'
1389--- breezy/tests/test_extract.py 2018-11-16 18:33:17 +0000
1390+++ breezy/tests/test_extract.py 2019-07-25 23:25:31 +0000
1391@@ -29,7 +29,7 @@
1392 wt.add(['b', 'b/c', 'd'], [b'b-id', b'c-id', b'd-id'])
1393 wt.commit('added files')
1394 b_wt = wt.extract('b')
1395- self.assertEqual(b'b-id', b_wt.get_root_id())
1396+ self.assertEqual(b'b-id', b_wt.path2id(''))
1397 self.assertEqual(b'c-id', b_wt.path2id('c'))
1398 self.assertEqual('c', b_wt.id2path(b'c-id'))
1399 self.assertRaises(errors.BzrError, wt.id2path, b'b-id')
1400
1401=== modified file 'breezy/tests/test_fetch.py'
1402--- breezy/tests/test_fetch.py 2018-11-11 04:08:32 +0000
1403+++ breezy/tests/test_fetch.py 2019-07-25 23:25:31 +0000
1404@@ -498,7 +498,7 @@
1405 self.tree.add_parent_tree_id(b'not-ghost-parent')
1406 self.tree.commit('second commit', rev_id=b'second-id')
1407 self.repo.fetch(self.tree.branch.repository, b'second-id')
1408- root_id = self.tree.get_root_id()
1409+ root_id = self.tree.path2id('')
1410 self.assertEqual(
1411 ((root_id, b'left-parent'), (root_id, b'not-ghost-parent')),
1412 self.get_parents(root_id, b'second-id'))
1413
1414=== modified file 'breezy/tests/test_matchers.py'
1415--- breezy/tests/test_matchers.py 2018-11-11 04:08:32 +0000
1416+++ breezy/tests/test_matchers.py 2019-07-25 23:25:31 +0000
1417@@ -122,7 +122,7 @@
1418 t.add(['a', 'b', 'b/c'], [b'a-id', b'b-id', b'c-id'])
1419 self.assertThat(t, HasLayout(['', 'a', 'b/', 'b/c']))
1420 self.assertThat(t, HasLayout(
1421- [('', t.get_root_id()),
1422+ [('', t.path2id('')),
1423 ('a', b'a-id'),
1424 ('b/', b'b-id'),
1425 ('b/c', b'c-id')]))
1426
1427=== modified file 'breezy/tests/test_memorytree.py'
1428--- breezy/tests/test_memorytree.py 2019-02-16 21:12:42 +0000
1429+++ breezy/tests/test_memorytree.py 2019-07-25 23:25:31 +0000
1430@@ -56,7 +56,7 @@
1431 tree = MemoryTree.create_on_branch(branch)
1432 with tree.lock_write():
1433 tree.add([''])
1434- self.assertIsNot(None, tree.get_root_id())
1435+ self.assertIsNot(None, tree.path2id(''))
1436
1437 def test_lock_tree_write(self):
1438 """Check we can lock_tree_write and unlock MemoryTrees."""
1439
1440=== modified file 'breezy/tests/test_merge.py'
1441--- breezy/tests/test_merge.py 2019-06-18 00:20:56 +0000
1442+++ breezy/tests/test_merge.py 2019-07-25 23:25:31 +0000
1443@@ -137,7 +137,7 @@
1444 with merger.make_preview_transform() as tt:
1445 self.assertEqual([], tt.find_conflicts())
1446 preview = tt.get_preview_tree()
1447- self.assertEqual(wt.get_root_id(), preview.get_root_id())
1448+ self.assertEqual(wt.path2id(''), preview.path2id(''))
1449
1450 def test_merge_unrelated_retains_root(self):
1451 wt = self.make_branch_and_tree('tree')
1452@@ -149,7 +149,7 @@
1453 with transform.TransformPreview(wt) as merger.tt:
1454 merger._compute_transform()
1455 new_root_id = merger.tt.final_file_id(merger.tt.root)
1456- self.assertEqual(wt.get_root_id(), new_root_id)
1457+ self.assertEqual(wt.path2id(''), new_root_id)
1458
1459 def test_create_rename(self):
1460 """Rename an inventory entry while creating the file"""
1461@@ -511,7 +511,7 @@
1462 self.build_tree(['a'])
1463 tree.add('a')
1464 first_rev = tree.commit("added a")
1465- old_root_id = tree.get_root_id()
1466+ old_root_id = tree.path2id('')
1467 merger = _mod_merge.Merger.from_revision_ids(tree,
1468 _mod_revision.NULL_REVISION,
1469 first_rev)
1470
1471=== modified file 'breezy/tests/test_revert.py'
1472--- breezy/tests/test_revert.py 2019-06-22 10:30:21 +0000
1473+++ breezy/tests/test_revert.py 2019-07-25 23:25:31 +0000
1474@@ -159,6 +159,6 @@
1475 tree.add(['file1'])
1476 tree.commit('first')
1477 tree.set_root_id(b'temp-root-id')
1478- self.assertEqual(b'temp-root-id', tree.get_root_id())
1479+ self.assertEqual(b'temp-root-id', tree.path2id(''))
1480 tree.revert()
1481- self.assertEqual(b'initial-root-id', tree.get_root_id())
1482+ self.assertEqual(b'initial-root-id', tree.path2id(''))
1483
1484=== modified file 'breezy/tests/test_revisiontree.py'
1485--- breezy/tests/test_revisiontree.py 2018-11-16 18:33:17 +0000
1486+++ breezy/tests/test_revisiontree.py 2019-07-25 23:25:31 +0000
1487@@ -58,7 +58,7 @@
1488 def test_empty_no_root(self):
1489 null_tree = self.t.branch.repository.revision_tree(
1490 revision.NULL_REVISION)
1491- self.assertIs(None, null_tree.get_root_id())
1492+ self.assertIs(None, null_tree.path2id(''))
1493
1494 def test_get_file_revision_root(self):
1495 self.assertEqual(self.rev_id, self.rev_tree.get_file_revision(u''))
1496
1497=== modified file 'breezy/tests/test_shelf_ui.py'
1498--- breezy/tests/test_shelf_ui.py 2018-11-12 01:41:38 +0000
1499+++ breezy/tests/test_shelf_ui.py 2019-07-25 23:25:31 +0000
1500@@ -302,14 +302,14 @@
1501 def test_shelve_old_root_preserved(self):
1502 tree1 = self.make_branch_and_tree('tree1')
1503 tree1.commit('add root')
1504- tree1_root_id = tree1.get_root_id()
1505+ tree1_root_id = tree1.path2id('')
1506 tree2 = self.make_branch_and_tree('tree2')
1507 rev2 = tree2.commit('add root')
1508- self.assertNotEqual(tree1_root_id, tree2.get_root_id())
1509+ self.assertNotEqual(tree1_root_id, tree2.path2id(''))
1510 tree1.merge_from_branch(tree2.branch,
1511 from_revision=revision.NULL_REVISION)
1512 tree1.commit('merging in tree2')
1513- self.assertEqual(tree1_root_id, tree1.get_root_id())
1514+ self.assertEqual(tree1_root_id, tree1.path2id(''))
1515 # This is essentially assertNotRaises(InconsistentDelta)
1516 # With testtools 0.9.9, it can be rewritten as:
1517 # with ExpectedException(AssertionError,
1518
1519=== modified file 'breezy/tests/test_smart_add.py'
1520--- breezy/tests/test_smart_add.py 2018-11-12 01:41:38 +0000
1521+++ breezy/tests/test_smart_add.py 2019-07-25 23:25:31 +0000
1522@@ -92,7 +92,7 @@
1523
1524 self.build_tree(['new/a', 'new/b', 'new/c',
1525 'new/subdir/', 'new/subdir/b', 'new/subdir/d'])
1526- new_tree.set_root_id(self.base_tree.get_root_id())
1527+ new_tree.set_root_id(self.base_tree.path2id(''))
1528 self.add_helper(self.base_tree, 'dir', new_tree, ['new'])
1529
1530 # We know 'a' and 'b' exist in the root, and they are being added
1531
1532=== modified file 'breezy/tests/test_subsume.py'
1533--- breezy/tests/test_subsume.py 2018-11-16 18:33:17 +0000
1534+++ breezy/tests/test_subsume.py 2019-07-25 23:25:31 +0000
1535@@ -36,7 +36,7 @@
1536 sub_tree = self.make_branch_and_tree('tree/subtree',
1537 format='development-subtree')
1538 if same_root is True:
1539- sub_tree.set_root_id(base_tree.get_root_id())
1540+ sub_tree.set_root_id(base_tree.path2id(''))
1541 sub_tree.add('file2', b'file2-id')
1542 sub_tree.commit('first commit', rev_id=b'subtree-1')
1543 return base_tree, sub_tree
1544@@ -59,8 +59,8 @@
1545
1546 def test_subsume_tree(self):
1547 base_tree, sub_tree = self.make_trees()
1548- self.assertNotEqual(base_tree.get_root_id(), sub_tree.get_root_id())
1549- sub_root_id = sub_tree.get_root_id()
1550+ self.assertNotEqual(base_tree.path2id(''), sub_tree.path2id(''))
1551+ sub_root_id = sub_tree.path2id('')
1552 # this test checks the subdir is removed, so it needs to know the
1553 # control directory; that changes rarely so just hardcode (and check)
1554 # it is correct.
1555@@ -94,7 +94,7 @@
1556
1557 def test_subsume_failure(self):
1558 base_tree, sub_tree = self.make_trees()
1559- if base_tree.get_root_id() == sub_tree.get_root_id():
1560+ if base_tree.path2id('') == sub_tree.path2id(''):
1561 raise tests.TestSkipped('This test requires unique roots')
1562 self.assertRaises(errors.BadSubsumeSource, base_tree.subsume,
1563 base_tree)
1564
1565=== modified file 'breezy/tests/test_switch.py'
1566--- breezy/tests/test_switch.py 2018-11-12 01:41:38 +0000
1567+++ breezy/tests/test_switch.py 2019-07-25 23:25:31 +0000
1568@@ -179,7 +179,7 @@
1569 checkout = tree.branch.create_checkout('checkout',
1570 lightweight=self.lightweight)
1571 switch.switch(checkout.controldir, tree2.branch)
1572- self.assertEqual(b'custom-root-id', tree2.get_root_id())
1573+ self.assertEqual(b'custom-root-id', tree2.path2id(''))
1574
1575 def test_switch_configurable_file_merger(self):
1576 class DummyMerger(_mod_merge.ConfigurableFileMerger):
1577
1578=== modified file 'breezy/tests/test_transform.py'
1579--- breezy/tests/test_transform.py 2019-06-22 12:07:42 +0000
1580+++ breezy/tests/test_transform.py 2019-07-25 23:25:31 +0000
1581@@ -147,7 +147,7 @@
1582 self.assertEqual(imaginary_id, imaginary_id2)
1583 self.assertEqual(root, transform.get_tree_parent(imaginary_id))
1584 self.assertEqual('directory', transform.final_kind(root))
1585- self.assertEqual(self.wt.get_root_id(), transform.final_file_id(root))
1586+ self.assertEqual(self.wt.path2id(''), transform.final_file_id(root))
1587 trans_id = transform.create_path('name', root)
1588 self.assertIs(transform.final_file_id(trans_id), None)
1589 self.assertIs(None, transform.final_kind(trans_id))
1590@@ -270,17 +270,17 @@
1591
1592 def test_change_root_id(self):
1593 transform, root = self.get_transform()
1594- self.assertNotEqual(b'new-root-id', self.wt.get_root_id())
1595+ self.assertNotEqual(b'new-root-id', self.wt.path2id(''))
1596 transform.new_directory('', ROOT_PARENT, b'new-root-id')
1597 transform.delete_contents(root)
1598 transform.unversion_file(root)
1599 transform.fixup_new_roots()
1600 transform.apply()
1601- self.assertEqual(b'new-root-id', self.wt.get_root_id())
1602+ self.assertEqual(b'new-root-id', self.wt.path2id(''))
1603
1604 def test_change_root_id_add_files(self):
1605 transform, root = self.get_transform()
1606- self.assertNotEqual(b'new-root-id', self.wt.get_root_id())
1607+ self.assertNotEqual(b'new-root-id', self.wt.path2id(''))
1608 new_trans_id = transform.new_directory('', ROOT_PARENT, b'new-root-id')
1609 transform.new_file('file', new_trans_id, [b'new-contents\n'],
1610 b'new-file-id')
1611@@ -288,7 +288,7 @@
1612 transform.unversion_file(root)
1613 transform.fixup_new_roots()
1614 transform.apply()
1615- self.assertEqual(b'new-root-id', self.wt.get_root_id())
1616+ self.assertEqual(b'new-root-id', self.wt.path2id(''))
1617 self.assertEqual(b'new-file-id', self.wt.path2id('file'))
1618 self.assertFileEqual(b'new-contents\n', self.wt.abspath('file'))
1619
1620@@ -321,13 +321,13 @@
1621
1622 def test_remove_root_fixup(self):
1623 transform, root = self.get_transform()
1624- old_root_id = self.wt.get_root_id()
1625+ old_root_id = self.wt.path2id('')
1626 self.assertNotEqual(b'new-root-id', old_root_id)
1627 transform.delete_contents(root)
1628 transform.unversion_file(root)
1629 transform.fixup_new_roots()
1630 transform.apply()
1631- self.assertEqual(old_root_id, self.wt.get_root_id())
1632+ self.assertEqual(old_root_id, self.wt.path2id(''))
1633
1634 transform, root = self.get_transform()
1635 transform.new_directory('', ROOT_PARENT, b'new-root-id')
1636@@ -358,7 +358,7 @@
1637 old_root_id = transform.tree_file_id(root)
1638 transform.unversion_file(root)
1639 transform.apply()
1640- self.assertEqual(old_root_id, self.wt.get_root_id())
1641+ self.assertEqual(old_root_id, self.wt.path2id(''))
1642
1643 def test_hardlink(self):
1644 self.requireFeature(HardlinkFeature)
1645@@ -1741,7 +1741,7 @@
1646 tree.add('foo', b'foo-id')
1647 with TransformPreview(tree) as tt:
1648 tt.unversion_file(tt.root)
1649- tt.version_file(tree.get_root_id(), tt.root)
1650+ tt.version_file(tree.path2id(''), tt.root)
1651 tt.trans_id_tree_path('foo')
1652 self.assertEqual([], tt._inventory_altered())
1653
1654@@ -2872,7 +2872,7 @@
1655
1656 def test_iter_changes(self):
1657 revision_tree, preview_tree = self.get_tree_and_preview_tree()
1658- root = revision_tree.get_root_id()
1659+ root = revision_tree.path2id('')
1660 self.assertEqual([(b'a-id', ('a', 'a'), True, (True, True),
1661 (root, root), ('a', 'a'), ('file', 'file'),
1662 (False, False))],
1663@@ -2981,7 +2981,7 @@
1664 preview.unversion_file(c_trans_id)
1665 preview.version_file(b'c-id', c_trans_id)
1666 preview_tree = preview.get_preview_tree()
1667- self.assertEqual({b'a-id', b'c-id', tree.get_root_id()},
1668+ self.assertEqual({b'a-id', b'c-id', tree.path2id('')},
1669 preview_tree.all_file_ids())
1670
1671 def test_path2id_deleted_unchanged(self):
1672@@ -3817,7 +3817,7 @@
1673 transform, root = self.get_transform()
1674 old_root_id = transform.tree_file_id(root)
1675 transform.apply()
1676- self.assertEqual(old_root_id, self.wt.get_root_id())
1677+ self.assertEqual(old_root_id, self.wt.path2id(''))
1678 self.assertEqual([(self.wt, transform)], calls)
1679
1680 def test_post_commit_hooks(self):
1681@@ -3830,7 +3830,7 @@
1682 transform, root = self.get_transform()
1683 old_root_id = transform.tree_file_id(root)
1684 transform.apply()
1685- self.assertEqual(old_root_id, self.wt.get_root_id())
1686+ self.assertEqual(old_root_id, self.wt.path2id(''))
1687 self.assertEqual([(self.wt, transform)], calls)
1688
1689
1690
1691=== modified file 'breezy/tests/test_workingtree_4.py'
1692--- breezy/tests/test_workingtree_4.py 2019-06-16 23:54:50 +0000
1693+++ breezy/tests/test_workingtree_4.py 2019-07-25 23:25:31 +0000
1694@@ -538,22 +538,19 @@
1695 format=format_name)
1696 tree2 = self.make_branch_and_tree('tree2',
1697 format=format_name)
1698- self.assertNotEqual(tree1.get_root_id(), tree2.get_root_id())
1699+ self.assertNotEqual(tree1.path2id(''), tree2.path2id(''))
1700 # when you branch, it inherits the same root id
1701 tree1.commit('first post')
1702 tree3 = tree1.controldir.sprout('tree3').open_workingtree()
1703- self.assertEqual(tree3.get_root_id(), tree1.get_root_id())
1704+ self.assertEqual(tree3.path2id(''), tree1.path2id(''))
1705
1706 def test_set_root_id(self):
1707 # similar to some code that fails in the dirstate-plus-subtree branch
1708 # -- setting the root id while adding a parent seems to scramble the
1709 # dirstate invariants. -- mbp 20070303
1710 def validate():
1711- wt.lock_read()
1712- try:
1713+ with wt.lock_read():
1714 wt.current_dirstate()._validate()
1715- finally:
1716- wt.unlock()
1717 wt = self.make_workingtree('tree')
1718 wt.set_root_id(b'TREE-ROOTID')
1719 validate()
1720@@ -567,10 +564,10 @@
1721
1722 def test_default_root_id(self):
1723 tree = self.make_branch_and_tree('tag', format='dirstate-tags')
1724- self.assertEqual(inventory.ROOT_ID, tree.get_root_id())
1725+ self.assertEqual(inventory.ROOT_ID, tree.path2id(''))
1726 tree = self.make_branch_and_tree('subtree',
1727 format='development-subtree')
1728- self.assertNotEqual(inventory.ROOT_ID, tree.get_root_id())
1729+ self.assertNotEqual(inventory.ROOT_ID, tree.path2id(''))
1730
1731 def test_non_subtree_with_nested_trees(self):
1732 # prior to dirstate, st/diff/commit ignored nested trees.
1733
1734=== modified file 'breezy/transform.py'
1735--- breezy/transform.py 2019-06-22 12:07:42 +0000
1736+++ breezy/transform.py 2019-07-25 23:25:31 +0000
1737@@ -455,7 +455,7 @@
1738 return None
1739 # the file is old; the old id is still valid
1740 if self._new_root == trans_id:
1741- return self._tree.get_root_id()
1742+ return self._tree.path2id('')
1743 return self._tree.path2id(path)
1744
1745 def final_file_id(self, trans_id):
1746@@ -1823,7 +1823,7 @@
1747 child_pb.update(gettext('removing file'),
1748 num, total_entries)
1749 if trans_id == self._new_root:
1750- file_id = self._tree.get_root_id()
1751+ file_id = self._tree.path2id('')
1752 else:
1753 file_id = self.tree_file_id(trans_id)
1754 # File-id isn't really being deleted, just moved
1755@@ -2102,9 +2102,6 @@
1756 """This Tree does not use inventory as its backing data."""
1757 raise NotImplementedError(_PreviewTree.root_inventory)
1758
1759- def get_root_id(self):
1760- return self._transform.final_file_id(self._transform.root)
1761-
1762 def all_file_ids(self):
1763 tree_ids = set(self._transform._tree.all_file_ids())
1764 tree_ids.difference_update(self._transform.tree_file_id(t)
1765@@ -2288,7 +2285,7 @@
1766 else:
1767 if from_dir is None and include_root is True:
1768 root_entry = inventory.make_entry(
1769- 'directory', '', ROOT_PARENT, self.get_root_id())
1770+ 'directory', '', ROOT_PARENT, self.path2id(''))
1771 yield '', 'V', 'directory', root_entry
1772 entries = self._iter_entries_for_dir(from_dir or '')
1773 for path, entry in entries:
1774@@ -2620,7 +2617,7 @@
1775 file_trans_id = {}
1776 top_pb = ui.ui_factory.nested_progress_bar()
1777 pp = ProgressPhase("Build phase", 2, top_pb)
1778- if tree.get_root_id() is not None:
1779+ if tree.path2id('') is not None:
1780 # This is kind of a hack: we should be altering the root
1781 # as part of the regular tree shape diff logic.
1782 # The conditional test here is to avoid doing an
1783@@ -2628,14 +2625,14 @@
1784 # is set within the tree, nor setting the root and thus
1785 # marking the tree as dirty, because we use two different
1786 # idioms here: tree interfaces and inventory interfaces.
1787- if wt.get_root_id() != tree.get_root_id():
1788- wt.set_root_id(tree.get_root_id())
1789+ if wt.path2id('') != tree.path2id(''):
1790+ wt.set_root_id(tree.path2id(''))
1791 wt.flush()
1792 tt = wt.get_transform()
1793 divert = set()
1794 try:
1795 pp.next_phase()
1796- file_trans_id[wt.get_root_id()] = tt.trans_id_tree_path('')
1797+ file_trans_id[wt.path2id('')] = tt.trans_id_tree_path('')
1798 with ui.ui_factory.nested_progress_bar() as pb:
1799 deferred_contents = []
1800 num = 0
1801
1802=== modified file 'breezy/tree.py'
1803--- breezy/tree.py 2019-06-29 12:29:45 +0000
1804+++ breezy/tree.py 2019-07-25 23:25:31 +0000
1805@@ -529,10 +529,6 @@
1806 """
1807 raise NotImplementedError(self.get_symlink_target)
1808
1809- def get_root_id(self):
1810- """Return the file_id for the root of this tree."""
1811- raise NotImplementedError(self.get_root_id)
1812-
1813 def annotate_iter(self, path,
1814 default_revision=_mod_revision.CURRENT_REVISION):
1815 """Return an iterator of revision_id, line tuples.
1816
1817=== modified file 'breezy/workingtree.py'
1818--- breezy/workingtree.py 2019-06-18 11:21:15 +0000
1819+++ breezy/workingtree.py 2019-07-25 23:25:31 +0000
1820@@ -398,10 +398,6 @@
1821 parents.append(revision_id)
1822 return parents
1823
1824- def get_root_id(self):
1825- """Return the id of this trees root"""
1826- raise NotImplementedError(self.get_root_id)
1827-
1828 def clone(self, to_controldir, revision_id=None):
1829 """Duplicate this working tree into to_bzr, including all state.
1830
1831@@ -424,7 +420,7 @@
1832 def copy_content_into(self, tree, revision_id=None):
1833 """Copy the current content and user files of this tree into tree."""
1834 with self.lock_read():
1835- tree.set_root_id(self.get_root_id())
1836+ tree.set_root_id(self.path2id(''))
1837 if revision_id is None:
1838 merge.transform_tree(tree, self)
1839 else:
1840@@ -841,8 +837,8 @@
1841 this_tree=self,
1842 change_reporter=change_reporter,
1843 show_base=show_base)
1844- basis_root_id = basis_tree.get_root_id()
1845- new_root_id = new_basis_tree.get_root_id()
1846+ basis_root_id = basis_tree.path2id('')
1847+ new_root_id = new_basis_tree.path2id('')
1848 if new_root_id is not None and basis_root_id != new_root_id:
1849 self.set_root_id(new_root_id)
1850 # TODO - dedup parents list with things merged by pull ?
1851@@ -1170,11 +1166,11 @@
1852 # the working tree is up to date with the branch
1853 # we can merge the specified revision from master
1854 to_tree = self.branch.repository.revision_tree(revision)
1855- to_root_id = to_tree.get_root_id()
1856+ to_root_id = to_tree.path2id('')
1857
1858 basis = self.basis_tree()
1859 with basis.lock_read():
1860- if (basis.get_root_id() is None or basis.get_root_id() != to_root_id):
1861+ if (basis.path2id('') is None or basis.path2id('') != to_root_id):
1862 self.set_root_id(to_root_id)
1863 self.flush()
1864
1865
1866=== modified file 'doc/en/release-notes/brz-3.1.txt'
1867--- doc/en/release-notes/brz-3.1.txt 2019-07-07 19:36:13 +0000
1868+++ doc/en/release-notes/brz-3.1.txt 2019-07-25 23:25:31 +0000
1869@@ -99,6 +99,9 @@
1870 * New ``Tree.get_transform`` method for getting a ``TreeTransform``
1871 object. (Jelmer Vernooij)
1872
1873+* The ``Tree.get_root_id`` method has been removed. Use
1874+ ``Tree.path2id('')`` instead. (Jelmer Vernooij)
1875+
1876 * ``Repository.find_branches`` now returns an iterator rather than a
1877 list. (Jelmer Vernooij, #413970)
1878

Subscribers

People subscribed via source and target branches