Merge lp:~jelmer/brz/objects-2b 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/objects-2b
Merge into: lp:brz
Diff against target: 178 lines (+23/-24)
6 files modified
breezy/conflicts.py (+1/-1)
breezy/merge.py (+14/-14)
breezy/shelf.py (+2/-3)
breezy/tests/test_transform.py (+4/-5)
breezy/transform.py (+1/-1)
breezy/tree.py (+1/-0)
To merge this branch: bzr merge lp:~jelmer/brz/objects-2b
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+368930@code.launchpad.net

Commit message

Remove file_id from transform's create_from_tree, get filter tree paths by path.

Description of the change

Remove file_id from transform's create_from_tree, get filter tree paths by path.

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

Thanks!

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/conflicts.py'
--- breezy/conflicts.py 2018-11-11 04:08:32 +0000
+++ breezy/conflicts.py 2019-06-17 18:22:03 +0000
@@ -525,7 +525,7 @@
525 tid = tt.trans_id_tree_path(path_to_create)525 tid = tt.trans_id_tree_path(path_to_create)
526 tree = self._revision_tree(tt._tree, revid)526 tree = self._revision_tree(tt._tree, revid)
527 transform.create_from_tree(527 transform.create_from_tree(
528 tt, tid, tree, tree.id2path(file_id), file_id=file_id)528 tt, tid, tree, tree.id2path(file_id))
529 tt.version_file(file_id, tid)529 tt.version_file(file_id, tid)
530 else:530 else:
531 tid = tt.trans_id_file_id(file_id)531 tid = tt.trans_id_file_id(file_id)
532532
=== modified file 'breezy/merge.py'
--- breezy/merge.py 2019-06-15 12:04:34 +0000
+++ breezy/merge.py 2019-06-17 18:22:03 +0000
@@ -1307,8 +1307,8 @@
1307 self.tt.version_file(file_id, trans_id)1307 self.tt.version_file(file_id, trans_id)
1308 transform.create_from_tree(1308 transform.create_from_tree(
1309 self.tt, trans_id, self.other_tree,1309 self.tt, trans_id, self.other_tree,
1310 other_path, file_id=file_id,1310 other_path,
1311 filter_tree_path=self._get_filter_tree_path(file_id))1311 filter_tree_path=self._get_filter_tree_path(other_path))
1312 inhibit_content_conflict = True1312 inhibit_content_conflict = True
1313 elif params.other_kind is None: # file_id is not in OTHER1313 elif params.other_kind is None: # file_id is not in OTHER
1314 # Is the name used for a different file_id ?1314 # Is the name used for a different file_id ?
@@ -1360,14 +1360,13 @@
13601360
1361 def _default_other_winner_merge(self, merge_hook_params):1361 def _default_other_winner_merge(self, merge_hook_params):
1362 """Replace this contents with other."""1362 """Replace this contents with other."""
1363 file_id = merge_hook_params.file_id
1364 trans_id = merge_hook_params.trans_id1363 trans_id = merge_hook_params.trans_id
1365 if merge_hook_params.other_path is not None:1364 if merge_hook_params.other_path is not None:
1366 # OTHER changed the file1365 # OTHER changed the file
1367 transform.create_from_tree(1366 transform.create_from_tree(
1368 self.tt, trans_id, self.other_tree,1367 self.tt, trans_id, self.other_tree,
1369 merge_hook_params.other_path, file_id=file_id,1368 merge_hook_params.other_path,
1370 filter_tree_path=self._get_filter_tree_path(file_id))1369 filter_tree_path=self._get_filter_tree_path(merge_hook_params.other_path))
1371 return 'done', None1370 return 'done', None
1372 elif merge_hook_params.this_path is not None:1371 elif merge_hook_params.this_path is not None:
1373 # OTHER deleted the file1372 # OTHER deleted the file
@@ -1452,17 +1451,18 @@
1452 other_lines)1451 other_lines)
1453 file_group.append(trans_id)1452 file_group.append(trans_id)
14541453
1455 def _get_filter_tree_path(self, file_id):1454 def _get_filter_tree_path(self, path):
1456 if self.this_tree.supports_content_filtering():1455 if self.this_tree.supports_content_filtering():
1457 # We get the path from the working tree if it exists.1456 # We get the path from the working tree if it exists.
1458 # That fails though when OTHER is adding a file, so1457 # That fails though when OTHER is adding a file, so
1459 # we fall back to the other tree to find the path if1458 # we fall back to the other tree to find the path if
1460 # it doesn't exist locally.1459 # it doesn't exist locally.
1461 try:1460 filter_path = _mod_tree.find_previous_path(
1462 return self.this_tree.id2path(file_id)1461 self.other_tree, self.working_tree, path)
1463 except errors.NoSuchId:1462 if filter_path is None:
1464 return self.other_tree.id2path(file_id)1463 filter_path = path
1465 # Skip the id2path lookup for older formats1464 return filter_path
1465 # Skip the lookup for older formats
1466 return None1466 return None
14671467
1468 def _dump_conflicts(self, name, paths, parent_id, file_id, this_lines=None,1468 def _dump_conflicts(self, name, paths, parent_id, file_id, this_lines=None,
@@ -1497,7 +1497,7 @@
1497 for suffix, tree, path, lines in data:1497 for suffix, tree, path, lines in data:
1498 if path is not None:1498 if path is not None:
1499 trans_id = self._conflict_file(1499 trans_id = self._conflict_file(
1500 name, parent_id, path, tree, file_id, suffix, lines,1500 name, parent_id, path, tree, suffix, lines,
1501 filter_tree_path)1501 filter_tree_path)
1502 file_group.append(trans_id)1502 file_group.append(trans_id)
1503 if set_version and not versioned:1503 if set_version and not versioned:
@@ -1505,14 +1505,14 @@
1505 versioned = True1505 versioned = True
1506 return file_group1506 return file_group
15071507
1508 def _conflict_file(self, name, parent_id, path, tree, file_id, suffix,1508 def _conflict_file(self, name, parent_id, path, tree, suffix,
1509 lines=None, filter_tree_path=None):1509 lines=None, filter_tree_path=None):
1510 """Emit a single conflict file."""1510 """Emit a single conflict file."""
1511 name = name + '.' + suffix1511 name = name + '.' + suffix
1512 trans_id = self.tt.create_path(name, parent_id)1512 trans_id = self.tt.create_path(name, parent_id)
1513 transform.create_from_tree(1513 transform.create_from_tree(
1514 self.tt, trans_id, tree, path,1514 self.tt, trans_id, tree, path,
1515 file_id=file_id, chunks=lines,1515 chunks=lines,
1516 filter_tree_path=filter_tree_path)1516 filter_tree_path=filter_tree_path)
1517 return trans_id1517 return trans_id
15181518
15191519
=== modified file 'breezy/shelf.py'
--- breezy/shelf.py 2019-06-15 12:04:34 +0000
+++ breezy/shelf.py 2019-06-17 18:22:03 +0000
@@ -208,8 +208,7 @@
208 def _content_from_tree(tt, tree, file_id):208 def _content_from_tree(tt, tree, file_id):
209 trans_id = tt.trans_id_file_id(file_id)209 trans_id = tt.trans_id_file_id(file_id)
210 tt.delete_contents(trans_id)210 tt.delete_contents(trans_id)
211 transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id),211 transform.create_from_tree(tt, trans_id, tree, tree.id2path(file_id))
212 file_id)
213212
214 def shelve_content_change(self, file_id):213 def shelve_content_change(self, file_id):
215 """Shelve a kind change or binary file content change.214 """Shelve a kind change or binary file content change.
@@ -267,7 +266,7 @@
267 else:266 else:
268 transform.create_from_tree(267 transform.create_from_tree(
269 to_transform, s_trans_id, tree,268 to_transform, s_trans_id, tree,
270 tree.id2path(file_id), file_id)269 tree.id2path(file_id))
271 if version:270 if version:
272 to_transform.version_file(file_id, s_trans_id)271 to_transform.version_file(file_id, s_trans_id)
273272
274273
=== modified file 'breezy/tests/test_transform.py'
--- breezy/tests/test_transform.py 2019-06-15 15:59:17 +0000
+++ breezy/tests/test_transform.py 2019-06-17 18:22:03 +0000
@@ -1666,9 +1666,9 @@
1666 tree2 = self.make_branch_and_tree('tree2')1666 tree2 = self.make_branch_and_tree('tree2')
1667 tt = TreeTransform(tree2)1667 tt = TreeTransform(tree2)
1668 foo_trans_id = tt.create_path('foo', tt.root)1668 foo_trans_id = tt.create_path('foo', tt.root)
1669 create_from_tree(tt, foo_trans_id, tree1, 'foo', file_id=b'foo-id')1669 create_from_tree(tt, foo_trans_id, tree1, 'foo')
1670 bar_trans_id = tt.create_path('bar', tt.root)1670 bar_trans_id = tt.create_path('bar', tt.root)
1671 create_from_tree(tt, bar_trans_id, tree1, 'bar', file_id=b'bar-id')1671 create_from_tree(tt, bar_trans_id, tree1, 'bar')
1672 tt.apply()1672 tt.apply()
1673 self.assertEqual('directory', osutils.file_kind('tree2/foo'))1673 self.assertEqual('directory', osutils.file_kind('tree2/foo'))
1674 self.assertFileEqual(b'baz', 'tree2/bar')1674 self.assertFileEqual(b'baz', 'tree2/bar')
@@ -1681,8 +1681,7 @@
1681 tree2 = self.make_branch_and_tree('tree2')1681 tree2 = self.make_branch_and_tree('tree2')
1682 tt = TreeTransform(tree2)1682 tt = TreeTransform(tree2)
1683 foo_trans_id = tt.create_path('foo', tt.root)1683 foo_trans_id = tt.create_path('foo', tt.root)
1684 create_from_tree(tt, foo_trans_id, tree1, 'foo', file_id=b'foo-id',1684 create_from_tree(tt, foo_trans_id, tree1, 'foo', chunks=[b'qux'])
1685 chunks=[b'qux'])
1686 tt.apply()1685 tt.apply()
1687 self.assertFileEqual(b'qux', 'tree2/foo')1686 self.assertFileEqual(b'qux', 'tree2/foo')
16881687
@@ -1693,7 +1692,7 @@
1693 tree1.add('foo', b'foo-id')1692 tree1.add('foo', b'foo-id')
1694 tt = TreeTransform(self.make_branch_and_tree('tree2'))1693 tt = TreeTransform(self.make_branch_and_tree('tree2'))
1695 foo_trans_id = tt.create_path('foo', tt.root)1694 foo_trans_id = tt.create_path('foo', tt.root)
1696 create_from_tree(tt, foo_trans_id, tree1, 'foo', file_id=b'foo-id')1695 create_from_tree(tt, foo_trans_id, tree1, 'foo')
1697 tt.apply()1696 tt.apply()
1698 self.assertEqual('bar', os.readlink('tree2/foo'))1697 self.assertEqual('bar', os.readlink('tree2/foo'))
16991698
17001699
=== modified file 'breezy/transform.py'
--- breezy/transform.py 2019-06-15 15:59:17 +0000
+++ breezy/transform.py 2019-06-17 18:22:03 +0000
@@ -2814,7 +2814,7 @@
2814 raise errors.BadFileKindError(name, kind)2814 raise errors.BadFileKindError(name, kind)
28152815
28162816
2817def create_from_tree(tt, trans_id, tree, path, file_id=None, chunks=None,2817def create_from_tree(tt, trans_id, tree, path, chunks=None,
2818 filter_tree_path=None):2818 filter_tree_path=None):
2819 """Create new file contents according to tree contents.2819 """Create new file contents according to tree contents.
28202820
28212821
=== modified file 'breezy/tree.py'
--- breezy/tree.py 2019-06-16 02:23:42 +0000
+++ breezy/tree.py 2019-06-17 18:22:03 +0000
@@ -1184,6 +1184,7 @@
1184 :param to_tree: To tree1184 :param to_tree: To tree
1185 :param path: Path to search for (exists in from_tree)1185 :param path: Path to search for (exists in from_tree)
1186 :return: path in to_tree, or None if there is no equivalent path.1186 :return: path in to_tree, or None if there is no equivalent path.
1187 :raise NoSuchFile: If the path doesn't exist in from_tree
1187 """1188 """
1188 if file_id is None:1189 if file_id is None:
1189 file_id = from_tree.path2id(path)1190 file_id = from_tree.path2id(path)

Subscribers

People subscribed via source and target branches