Merge lp:~jelmer/brz/lca-merge-git 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/lca-merge-git
Merge into: lp:brz
Prerequisite: lp:~jelmer/brz/split-multiwalker
Diff against target: 169 lines (+25/-27)
3 files modified
breezy/merge.py (+9/-11)
breezy/multiwalker.py (+14/-14)
breezy/tests/test_multiwalker.py (+2/-2)
To merge this branch: bzr merge lp:~jelmer/brz/lca-merge-git
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+367321@code.launchpad.net

Commit message

Avoid using inventories in breezy.merge when encountering lcas.

Description of the change

Avoid using inventories in breezy.merge when encountering lcas.

This fixes merge for git when encountering lcas.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
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
=== modified file 'breezy/merge.py'
--- breezy/merge.py 2019-06-02 18:45:38 +0000
+++ breezy/merge.py 2019-06-02 18:45:39 +0000
@@ -908,8 +908,6 @@
908 from .multiwalker import MultiWalker908 from .multiwalker import MultiWalker
909 walker = MultiWalker(self.other_tree, self._lca_trees)909 walker = MultiWalker(self.other_tree, self._lca_trees)
910910
911 base_inventory = self.base_tree.root_inventory
912 this_inventory = self.this_tree.root_inventory
913 for other_path, file_id, other_ie, lca_values in walker.iter_all():911 for other_path, file_id, other_ie, lca_values in walker.iter_all():
914 # Is this modified at all from any of the other trees?912 # Is this modified at all from any of the other trees?
915 if other_ie is None:913 if other_ie is None:
@@ -948,20 +946,20 @@
948 lca_paths.append(lca_path)946 lca_paths.append(lca_path)
949947
950 try:948 try:
951 base_ie = base_inventory.get_entry(file_id)949 base_path = self.base_tree.id2path(file_id)
952 except errors.NoSuchId:950 except errors.NoSuchId:
951 base_path = None
953 base_ie = _none_entry952 base_ie = _none_entry
954 base_path = None
955 else:953 else:
956 base_path = self.base_tree.id2path(file_id)954 base_ie = next(self.base_tree.iter_entries_by_dir(specific_files=[base_path]))[1]
957955
958 try:956 try:
959 this_ie = this_inventory.get_entry(file_id)957 this_path = self.this_tree.id2path(file_id)
960 except errors.NoSuchId:958 except errors.NoSuchId:
961 this_ie = _none_entry959 this_ie = _none_entry
962 this_path = None960 this_path = None
963 else:961 else:
964 this_path = self.this_tree.id2path(file_id)962 this_ie = next(self.this_tree.iter_entries_by_dir(specific_files=[this_path]))[1]
965963
966 lca_kinds = []964 lca_kinds = []
967 lca_parent_ids = []965 lca_parent_ids = []
@@ -1865,13 +1863,13 @@
18651863
1866 def _entries_to_incorporate(self):1864 def _entries_to_incorporate(self):
1867 """Yields pairs of (inventory_entry, new_parent)."""1865 """Yields pairs of (inventory_entry, new_parent)."""
1868 other_inv = self.other_tree.root_inventory1866 subdir_id = self.other_tree.path2id(self._source_subpath)
1869 subdir_id = other_inv.path2id(self._source_subpath)
1870 if subdir_id is None:1867 if subdir_id is None:
1871 # XXX: The error would be clearer if it gave the URL of the source1868 # XXX: The error would be clearer if it gave the URL of the source
1872 # branch, but we don't have a reference to that here.1869 # branch, but we don't have a reference to that here.
1873 raise PathNotInTree(self._source_subpath, "Source tree")1870 raise PathNotInTree(self._source_subpath, "Source tree")
1874 subdir = other_inv.get_entry(subdir_id)1871 subdir = next(self.other_tree.iter_entries_by_dir(
1872 specific_files=[self._source_subpath]))[1]
1875 parent_in_target = osutils.dirname(self._target_subdir)1873 parent_in_target = osutils.dirname(self._target_subdir)
1876 target_id = self.this_tree.path2id(parent_in_target)1874 target_id = self.this_tree.path2id(parent_in_target)
1877 if target_id is None:1875 if target_id is None:
@@ -1893,7 +1891,7 @@
1893 if subdir.kind != 'directory':1891 if subdir.kind != 'directory':
1894 # No children, so we are done.1892 # No children, so we are done.
1895 return1893 return
1896 for path, entry in other_inv.iter_entries_by_dir(subdir_id):1894 for path, entry in self.other_tree.root_inventory.iter_entries_by_dir(subdir_id):
1897 parent_id = entry.parent_id1895 parent_id = entry.parent_id
1898 if parent_id == subdir.file_id:1896 if parent_id == subdir.file_id:
1899 # The root's parent ID has changed, so make sure children of1897 # The root's parent ID has changed, so make sure children of
19001898
=== modified file 'breezy/multiwalker.py'
--- breezy/multiwalker.py 2019-06-02 18:45:38 +0000
+++ breezy/multiwalker.py 2019-06-02 18:45:39 +0000
@@ -108,6 +108,11 @@
108 dirname, basename = osutils.split(path)108 dirname, basename = osutils.split(path)
109 return (dirname.split(u'/'), basename)109 return (dirname.split(u'/'), basename)
110110
111 def _lookup_by_master_path(self, extra_entries, other_tree, master_path):
112 return self._lookup_by_file_id(
113 extra_entries, other_tree,
114 self._master_tree.path2id(master_path))
115
111 def _lookup_by_file_id(self, extra_entries, other_tree, file_id):116 def _lookup_by_file_id(self, extra_entries, other_tree, file_id):
112 """Lookup an inventory entry by file_id.117 """Lookup an inventory entry by file_id.
113118
@@ -127,8 +132,6 @@
127 """132 """
128 if file_id in extra_entries:133 if file_id in extra_entries:
129 return extra_entries.pop(file_id)134 return extra_entries.pop(file_id)
130 # TODO: Is id2path better as the first call, or is
131 # inventory[file_id] better as a first check?
132 try:135 try:
133 cur_path = other_tree.id2path(file_id)136 cur_path = other_tree.id2path(file_id)
134 except errors.NoSuchId:137 except errors.NoSuchId:
@@ -137,7 +140,8 @@
137 return (None, None)140 return (None, None)
138 else:141 else:
139 self._out_of_order_processed.add(file_id)142 self._out_of_order_processed.add(file_id)
140 cur_ie = other_tree.root_inventory.get_entry(file_id)143 cur_ie = next(other_tree.iter_entries_by_dir(
144 specific_files=[cur_path]))[1]
141 return (cur_path, cur_ie)145 return (cur_path, cur_ie)
142146
143 def iter_all(self):147 def iter_all(self):
@@ -176,17 +180,16 @@
176 if not master_has_more:180 if not master_has_more:
177 break181 break
178182
179 file_id = master_ie.file_id
180 other_values = []183 other_values = []
181 other_values_append = other_values.append184 other_values_append = other_values.append
182 next_other_entries = []185 next_other_entries = []
183 next_other_entries_append = next_other_entries.append186 next_other_entries_append = next_other_entries.append
184 for idx, (other_has_more, other_path, other_ie) in enumerate(other_entries):187 for idx, (other_has_more, other_path, other_ie) in enumerate(other_entries):
185 if not other_has_more:188 if not other_has_more:
186 other_values_append(lookup_by_file_id(189 other_values_append(self._lookup_by_master_path(
187 others_extra[idx], self._other_trees[idx], file_id))190 others_extra[idx], self._other_trees[idx], path))
188 next_other_entries_append((False, None, None))191 next_other_entries_append((False, None, None))
189 elif file_id == other_ie.file_id:192 elif master_ie.file_id == other_ie.file_id:
190 # This is the critical code path, as most of the entries193 # This is the critical code path, as most of the entries
191 # should match between most trees.194 # should match between most trees.
192 other_values_append((other_path, other_ie))195 other_values_append((other_path, other_ie))
@@ -203,7 +206,7 @@
203 other_extra[other_file_id] = (other_path, other_ie)206 other_extra[other_file_id] = (other_path, other_ie)
204 other_has_more, other_path, other_ie = \207 other_has_more, other_path, other_ie = \
205 step_one(other_walker)208 step_one(other_walker)
206 if other_has_more and other_ie.file_id == file_id:209 if other_has_more and other_ie.file_id == master_ie.file_id:
207 # We ended up walking to this point, match and step210 # We ended up walking to this point, match and step
208 # again211 # again
209 other_values_append((other_path, other_ie))212 other_values_append((other_path, other_ie))
@@ -212,14 +215,14 @@
212 else:215 else:
213 # This record isn't in the normal order, see if it216 # This record isn't in the normal order, see if it
214 # exists at all.217 # exists at all.
215 other_values_append(lookup_by_file_id(218 other_values_append(self._lookup_by_master_path(
216 other_extra, self._other_trees[idx], file_id))219 other_extra, self._other_trees[idx], path))
217 next_other_entries_append((other_has_more, other_path,220 next_other_entries_append((other_has_more, other_path,
218 other_ie))221 other_ie))
219 other_entries = next_other_entries222 other_entries = next_other_entries
220223
221 # We've matched all the walkers, yield this datapoint224 # We've matched all the walkers, yield this datapoint
222 yield path, file_id, master_ie, other_values225 yield path, master_ie.file_id, master_ie, other_values
223 self._other_walkers = other_walkers226 self._other_walkers = other_walkers
224 self._other_entries = other_entries227 self._other_entries = other_entries
225 self._others_extra = others_extra228 self._others_extra = others_extra
@@ -261,6 +264,3 @@
261 other_values.append(self._lookup_by_file_id(264 other_values.append(self._lookup_by_file_id(
262 alt_extra, alt_tree, file_id))265 alt_extra, alt_tree, file_id))
263 yield other_path, file_id, None, other_values266 yield other_path, file_id, None, other_values
264
265
266
267267
=== modified file 'breezy/tests/test_multiwalker.py'
--- breezy/tests/test_multiwalker.py 2019-06-02 18:45:38 +0000
+++ breezy/tests/test_multiwalker.py 2019-06-02 18:45:39 +0000
@@ -229,8 +229,8 @@
229 basis_tree, root_id = self.lock_and_get_basis_and_root_id(tree)229 basis_tree, root_id = self.lock_and_get_basis_and_root_id(tree)
230 first_tree = tree.branch.repository.revision_tree(b'first-rev-id')230 first_tree = tree.branch.repository.revision_tree(b'first-rev-id')
231 second_tree = tree.branch.repository.revision_tree(b'second-rev-id')231 second_tree = tree.branch.repository.revision_tree(b'second-rev-id')
232 walker = multiwalker.MultiWalker(tree, [basis_tree, first_tree,232 walker = multiwalker.MultiWalker(
233 second_tree])233 tree, [basis_tree, first_tree, second_tree])
234 iterator = walker.iter_all()234 iterator = walker.iter_all()
235 self.assertWalkerNext(u'', root_id, True, [u'', u'', u''], iterator)235 self.assertWalkerNext(u'', root_id, True, [u'', u'', u''], iterator)
236 self.assertWalkerNext(u'a', b'a-id', True,236 self.assertWalkerNext(u'a', b'a-id', True,

Subscribers

People subscribed via source and target branches