Merge lp:~jelmer/brz/iter-tree-references-lock 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/iter-tree-references-lock
Merge into: lp:brz
Diff against target: 106 lines (+34/-15)
4 files modified
breezy/bzr/workingtree_4.py (+18/-14)
breezy/tests/per_tree/test_tree.py (+1/-1)
breezy/tests/per_workingtree/test_add_reference.py (+1/-0)
breezy/transform.py (+14/-0)
To merge this branch: bzr merge lp:~jelmer/brz/iter-tree-references-lock
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+377793@code.launchpad.net

Commit message

Fix WorkingTree.iter_references, and add test.

Description of the change

Fix WorkingTree.iter_references, and add test.

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
=== modified file 'breezy/bzr/workingtree_4.py'
--- breezy/bzr/workingtree_4.py 2020-01-11 22:33:18 +0000
+++ breezy/bzr/workingtree_4.py 2020-01-18 00:19:13 +0000
@@ -130,6 +130,9 @@
130 self.views = self._make_views()130 self.views = self._make_views()
131 # --- allow tests to select the dirstate iter_changes implementation131 # --- allow tests to select the dirstate iter_changes implementation
132 self._iter_changes = dirstate._process_entry132 self._iter_changes = dirstate._process_entry
133 self._repo_supports_tree_reference = getattr(
134 self._branch.repository._format, "supports_tree_reference",
135 False)
133136
134 def _add(self, files, ids, kinds):137 def _add(self, files, ids, kinds):
135 """See MutableTree._add."""138 """See MutableTree._add."""
@@ -550,20 +553,21 @@
550 # When the repo doesn't support references, we will have nothing to553 # When the repo doesn't support references, we will have nothing to
551 # return554 # return
552 return555 return
553 for key, tree_details in self.current_dirstate()._iter_entries():556 with self.lock_read():
554 if tree_details[0][0] in (b'a', b'r'): # absent, relocated557 for key, tree_details in self.current_dirstate()._iter_entries():
555 # not relevant to the working tree558 if tree_details[0][0] in (b'a', b'r'): # absent, relocated
556 continue559 # not relevant to the working tree
557 if not key[1]:560 continue
558 # the root is not a reference.561 if not key[1]:
559 continue562 # the root is not a reference.
560 relpath = pathjoin(key[0].decode('utf8'), key[1].decode('utf8'))563 continue
561 try:564 relpath = pathjoin(key[0].decode('utf8'), key[1].decode('utf8'))
562 if self.kind(relpath) == 'tree-reference':565 try:
563 yield relpath566 if self.kind(relpath) == 'tree-reference':
564 except errors.NoSuchFile:567 yield relpath
565 # path is missing on disk.568 except errors.NoSuchFile:
566 continue569 # path is missing on disk.
570 continue
567571
568 def _observed_sha1(self, path, sha_and_stat):572 def _observed_sha1(self, path, sha_and_stat):
569 """See MutableTree._observed_sha1."""573 """See MutableTree._observed_sha1."""
570574
=== modified file 'breezy/tests/per_tree/test_tree.py'
--- breezy/tests/per_tree/test_tree.py 2019-09-27 02:48:17 +0000
+++ breezy/tests/per_tree/test_tree.py 2020-01-18 00:19:13 +0000
@@ -78,7 +78,7 @@
78class TestReference(TestCaseWithTree):78class TestReference(TestCaseWithTree):
7979
80 def skip_if_no_reference(self, tree):80 def skip_if_no_reference(self, tree):
81 if not getattr(tree, 'supports_tree_reference', lambda: False)():81 if not tree.supports_tree_reference():
82 raise tests.TestNotApplicable('Tree references not supported')82 raise tests.TestNotApplicable('Tree references not supported')
8383
84 def create_nested(self):84 def create_nested(self):
8585
=== modified file 'breezy/tests/per_workingtree/test_add_reference.py'
--- breezy/tests/per_workingtree/test_add_reference.py 2019-10-14 00:25:24 +0000
+++ breezy/tests/per_workingtree/test_add_reference.py 2020-01-18 00:19:13 +0000
@@ -61,6 +61,7 @@
61 self.assertEqual(61 self.assertEqual(
62 sub_tree.last_revision(),62 sub_tree.last_revision(),
63 tree.get_reference_revision('sub-tree'))63 tree.get_reference_revision('sub-tree'))
64 self.assertEqual(['sub-tree'], list(tree.iter_references()))
6465
65 def test_add_reference_same_root(self):66 def test_add_reference_same_root(self):
66 tree = self.make_branch_and_tree('tree')67 tree = self.make_branch_and_tree('tree')
6768
=== modified file 'breezy/transform.py'
--- breezy/transform.py 2020-01-10 01:40:18 +0000
+++ breezy/transform.py 2020-01-18 00:19:13 +0000
@@ -2036,6 +2036,11 @@
2036 self._iter_changes_cache = dict((c.file_id, c) for c in2036 self._iter_changes_cache = dict((c.file_id, c) for c in
2037 self._transform.iter_changes())2037 self._transform.iter_changes())
20382038
2039 def supports_tree_reference(self):
2040 # TODO(jelmer): Support tree references in _PreviewTree.
2041 # return self._transform._tree.supports_tree_reference()
2042 return False
2043
2039 def _content_change(self, file_id):2044 def _content_change(self, file_id):
2040 """Return True if the content of this file changed"""2045 """Return True if the content of this file changed"""
2041 changes = self._iter_changes_cache.get(file_id)2046 changes = self._iter_changes_cache.get(file_id)
@@ -2342,6 +2347,15 @@
2342 with self.get_file(path) as fileobj:2347 with self.get_file(path) as fileobj:
2343 return sha_file(fileobj)2348 return sha_file(fileobj)
23442349
2350 def get_reference_revision(self, path):
2351 trans_id = self._path2trans_id(path)
2352 if trans_id is None:
2353 raise errors.NoSuchFile(path)
2354 reference_revision = self._transform._new_reference_revision.get(trans_id)
2355 if reference_revision is None:
2356 return self._transform._tree.get_reference_revision(path)
2357 return reference_revision
2358
2345 def is_executable(self, path):2359 def is_executable(self, path):
2346 trans_id = self._path2trans_id(path)2360 trans_id = self._path2trans_id(path)
2347 if trans_id is None:2361 if trans_id is None:

Subscribers

People subscribed via source and target branches