Merge lp:~jelmer/brz/objects-2c into lp:brz

Proposed by Jelmer Vernooij on 2019-06-17
Status: Merged
Approved by: Jelmer Vernooij on 2019-06-22
Approved revision: 7360
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/objects-2c
Merge into: lp:brz
Diff against target: 500 lines (+62/-73)
8 files modified
breezy/bzr/inventorytree.py (+7/-6)
breezy/merge.py (+31/-41)
breezy/plugins/changelog_merge/tests/test_changelog_merge.py (+3/-4)
breezy/tests/per_merger.py (+15/-14)
breezy/tests/per_tree/test_tree.py (+1/-2)
breezy/tests/per_workingtree/test_merge_from_branch.py (+1/-1)
breezy/tests/test_transform.py (+2/-2)
breezy/transform.py (+2/-3)
To merge this branch: bzr merge lp:~jelmer/brz/objects-2c
Reviewer Review Type Date Requested Status
Martin Packman 2019-06-17 Approve on 2019-06-21
Review via email: mp+368932@code.launchpad.net

Commit message

Drop file_id attribute from MergeHookParams and Tree.plan_file_merge.

Description of the change

Drop file_id attribute from MergeHookParams and Tree.plan_file_merge.

(This depends on objects-2a and objects-2b, but I can't set two prerequisite branches)

To post a comment you must log in.
Martin Packman (gz) wrote :

New changes here all seem fine. Some interface changes, which may be worth calling out in NEWS?

review: Approve
lp:~jelmer/brz/objects-2c updated on 2019-06-22
7359. By Jelmer Vernooij on 2019-06-22

Fix formatting.

7360. By Jelmer Vernooij on 2019-06-22

Fix conflict tests.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/bzr/inventorytree.py'
--- breezy/bzr/inventorytree.py 2019-06-21 16:18:13 +0000
+++ breezy/bzr/inventorytree.py 2019-06-22 13:51:41 +0000
@@ -215,11 +215,12 @@
215 raise errors.NotADirectory(path)215 raise errors.NotADirectory(path)
216 return iter(viewvalues(ie.children))216 return iter(viewvalues(ie.children))
217217
218 def _get_plan_merge_data(self, file_id, other, base):218 def _get_plan_merge_data(self, path, other, base):
219 from . import versionedfile219 from . import versionedfile
220 file_id = self.path2id(path)
220 vf = versionedfile._PlanMergeVersionedFile(file_id)221 vf = versionedfile._PlanMergeVersionedFile(file_id)
221 last_revision_a = self._get_file_revision(222 last_revision_a = self._get_file_revision(
222 self.id2path(file_id), file_id, vf, b'this:')223 path, file_id, vf, b'this:')
223 last_revision_b = other._get_file_revision(224 last_revision_b = other._get_file_revision(
224 other.id2path(file_id), file_id, vf, b'other:')225 other.id2path(file_id), file_id, vf, b'other:')
225 if base is None:226 if base is None:
@@ -229,7 +230,7 @@
229 base.id2path(file_id), file_id, vf, b'base:')230 base.id2path(file_id), file_id, vf, b'base:')
230 return vf, last_revision_a, last_revision_b, last_revision_base231 return vf, last_revision_a, last_revision_b, last_revision_base
231232
232 def plan_file_merge(self, file_id, other, base=None):233 def plan_file_merge(self, path, other, base=None):
233 """Generate a merge plan based on annotations.234 """Generate a merge plan based on annotations.
234235
235 If the file contains uncommitted changes in this tree, they will be236 If the file contains uncommitted changes in this tree, they will be
@@ -237,12 +238,12 @@
237 uncommitted changes in the other tree, they will be assigned to the238 uncommitted changes in the other tree, they will be assigned to the
238 'other:' pseudo-revision.239 'other:' pseudo-revision.
239 """240 """
240 data = self._get_plan_merge_data(file_id, other, base)241 data = self._get_plan_merge_data(path, other, base)
241 vf, last_revision_a, last_revision_b, last_revision_base = data242 vf, last_revision_a, last_revision_b, last_revision_base = data
242 return vf.plan_merge(last_revision_a, last_revision_b,243 return vf.plan_merge(last_revision_a, last_revision_b,
243 last_revision_base)244 last_revision_base)
244245
245 def plan_file_lca_merge(self, file_id, other, base=None):246 def plan_file_lca_merge(self, path, other, base=None):
246 """Generate a merge plan based lca-newness.247 """Generate a merge plan based lca-newness.
247248
248 If the file contains uncommitted changes in this tree, they will be249 If the file contains uncommitted changes in this tree, they will be
@@ -250,7 +251,7 @@
250 uncommitted changes in the other tree, they will be assigned to the251 uncommitted changes in the other tree, they will be assigned to the
251 'other:' pseudo-revision.252 'other:' pseudo-revision.
252 """253 """
253 data = self._get_plan_merge_data(file_id, other, base)254 data = self._get_plan_merge_data(path, other, base)
254 vf, last_revision_a, last_revision_b, last_revision_base = data255 vf, last_revision_a, last_revision_b, last_revision_base = data
255 return vf.plan_lca_merge(last_revision_a, last_revision_b,256 return vf.plan_lca_merge(last_revision_a, last_revision_b,
256 last_revision_base)257 last_revision_base)
257258
=== modified file 'breezy/merge.py'
--- breezy/merge.py 2019-06-22 11:16:17 +0000
+++ breezy/merge.py 2019-06-22 13:51:41 +0000
@@ -223,20 +223,18 @@
223223
224 There are some fields hooks can access:224 There are some fields hooks can access:
225225
226 :ivar file_id: the file ID of the file being merged
227 :ivar base_path: Path in base tree226 :ivar base_path: Path in base tree
228 :ivar other_path: Path in other tree227 :ivar other_path: Path in other tree
229 :ivar this_path: Path in this tree228 :ivar this_path: Path in this tree
230 :ivar trans_id: the transform ID for the merge of this file229 :ivar trans_id: the transform ID for the merge of this file
231 :ivar this_kind: kind of file_id in 'this' tree230 :ivar this_kind: kind of file in 'this' tree
232 :ivar other_kind: kind of file_id in 'other' tree231 :ivar other_kind: kind of file in 'other' tree
233 :ivar winner: one of 'this', 'other', 'conflict'232 :ivar winner: one of 'this', 'other', 'conflict'
234 """233 """
235234
236 def __init__(self, merger, file_id, paths, trans_id, this_kind, other_kind,235 def __init__(self, merger, paths, trans_id, this_kind, other_kind,
237 winner):236 winner):
238 self._merger = merger237 self._merger = merger
239 self.file_id = file_id
240 self.paths = paths238 self.paths = paths
241 self.base_path, self.other_path, self.this_path = paths239 self.base_path, self.other_path, self.this_path = paths
242 self.trans_id = trans_id240 self.trans_id = trans_id
@@ -804,16 +802,18 @@
804 with ui.ui_factory.nested_progress_bar() as child_pb:802 with ui.ui_factory.nested_progress_bar() as child_pb:
805 for num, (file_id, changed, paths3, parents3, names3,803 for num, (file_id, changed, paths3, parents3, names3,
806 executable3) in enumerate(entries):804 executable3) in enumerate(entries):
805 trans_id = self.tt.trans_id_file_id(file_id)
806
807 # Try merging each entry807 # Try merging each entry
808 child_pb.update(gettext('Preparing file merge'),808 child_pb.update(gettext('Preparing file merge'),
809 num, len(entries))809 num, len(entries))
810 self._merge_names(file_id, paths3, parents3,810 self._merge_names(trans_id, file_id, paths3, parents3,
811 names3, resolver=resolver)811 names3, resolver=resolver)
812 if changed:812 if changed:
813 file_status = self._do_merge_contents(paths3, file_id)813 file_status = self._do_merge_contents(paths3, trans_id, file_id)
814 else:814 else:
815 file_status = 'unmodified'815 file_status = 'unmodified'
816 self._merge_executable(paths3, file_id, executable3,816 self._merge_executable(paths3, trans_id, executable3,
817 file_status, resolver=resolver)817 file_status, resolver=resolver)
818 self.tt.fixup_new_roots()818 self.tt.fixup_new_roots()
819 self._finish_computing_transform()819 self._finish_computing_transform()
@@ -1182,8 +1182,8 @@
1182 # At this point, the lcas disagree, and the tip disagree1182 # At this point, the lcas disagree, and the tip disagree
1183 return 'conflict'1183 return 'conflict'
11841184
1185 def _merge_names(self, file_id, paths, parents, names, resolver):1185 def _merge_names(self, trans_id, file_id, paths, parents, names, resolver):
1186 """Perform a merge on file_id names and parents"""1186 """Perform a merge on file names and parents"""
1187 base_name, other_name, this_name = names1187 base_name, other_name, this_name = names
1188 base_parent, other_parent, this_parent = parents1188 base_parent, other_parent, this_parent = parents
1189 unused_base_path, other_path, this_path = paths1189 unused_base_path, other_path, this_path = paths
@@ -1202,7 +1202,6 @@
1202 # Creating helpers (.OTHER or .THIS) here cause problems down the1202 # Creating helpers (.OTHER or .THIS) here cause problems down the
1203 # road if a ContentConflict needs to be created so we should not do1203 # road if a ContentConflict needs to be created so we should not do
1204 # that1204 # that
1205 trans_id = self.tt.trans_id_file_id(file_id)
1206 self._raw_conflicts.append(('path conflict', trans_id, file_id,1205 self._raw_conflicts.append(('path conflict', trans_id, file_id,
1207 this_parent, this_name,1206 this_parent, this_name,
1208 other_parent, other_name))1207 other_parent, other_name))
@@ -1225,10 +1224,9 @@
1225 parent_trans_id = transform.ROOT_PARENT1224 parent_trans_id = transform.ROOT_PARENT
1226 else:1225 else:
1227 parent_trans_id = self.tt.trans_id_file_id(parent_id)1226 parent_trans_id = self.tt.trans_id_file_id(parent_id)
1228 self.tt.adjust_path(name, parent_trans_id,1227 self.tt.adjust_path(name, parent_trans_id, trans_id)
1229 self.tt.trans_id_file_id(file_id))
12301228
1231 def _do_merge_contents(self, paths, file_id):1229 def _do_merge_contents(self, paths, trans_id, file_id):
1232 """Performs a merge on file_id contents."""1230 """Performs a merge on file_id contents."""
1233 def contents_pair(tree, path):1231 def contents_pair(tree, path):
1234 if path is None:1232 if path is None:
@@ -1272,10 +1270,8 @@
1272 return "unmodified"1270 return "unmodified"
1273 # We have a hypothetical conflict, but if we have files, then we1271 # We have a hypothetical conflict, but if we have files, then we
1274 # can try to merge the content1272 # can try to merge the content
1275 trans_id = self.tt.trans_id_file_id(file_id)
1276 params = MergeFileHookParams(1273 params = MergeFileHookParams(
1277 self, file_id, (base_path, other_path,1274 self, (base_path, other_path, this_path), trans_id, this_pair[0],
1278 this_path), trans_id, this_pair[0],
1279 other_pair[0], winner)1275 other_pair[0], winner)
1280 hooks = self.active_hooks1276 hooks = self.active_hooks
1281 hook_status = 'not_applicable'1277 hook_status = 'not_applicable'
@@ -1372,8 +1368,8 @@
1372 return 'delete', None1368 return 'delete', None
1373 else:1369 else:
1374 raise AssertionError(1370 raise AssertionError(
1375 'winner is OTHER, but file_id %r not in THIS or OTHER tree'1371 'winner is OTHER, but file %r not in THIS or OTHER tree'
1376 % (file_id,))1372 % (merge_hook_params.base_path,))
13771373
1378 def merge_contents(self, merge_hook_params):1374 def merge_contents(self, merge_hook_params):
1379 """Fallback merge logic after user installed hooks."""1375 """Fallback merge logic after user installed hooks."""
@@ -1389,7 +1385,7 @@
1389 # have agreement that output should be a file.1385 # have agreement that output should be a file.
1390 try:1386 try:
1391 self.text_merge(merge_hook_params.trans_id,1387 self.text_merge(merge_hook_params.trans_id,
1392 merge_hook_params.paths, merge_hook_params.file_id)1388 merge_hook_params.paths)
1393 except errors.BinaryFile:1389 except errors.BinaryFile:
1394 return 'not_applicable', None1390 return 'not_applicable', None
1395 return 'done', None1391 return 'done', None
@@ -1409,8 +1405,8 @@
1409 return []1405 return []
1410 return tree.get_file_lines(path)1406 return tree.get_file_lines(path)
14111407
1412 def text_merge(self, trans_id, paths, file_id):1408 def text_merge(self, trans_id, paths):
1413 """Perform a three-way text merge on a file_id"""1409 """Perform a three-way text merge on a file"""
1414 # it's possible that we got here with base as a different type.1410 # it's possible that we got here with base as a different type.
1415 # if so, we just want two-way text conflicts.1411 # if so, we just want two-way text conflicts.
1416 base_path, other_path, this_path = paths1412 base_path, other_path, this_path = paths
@@ -1445,6 +1441,7 @@
1445 self._raw_conflicts.append(('text conflict', trans_id))1441 self._raw_conflicts.append(('text conflict', trans_id))
1446 name = self.tt.final_name(trans_id)1442 name = self.tt.final_name(trans_id)
1447 parent_id = self.tt.final_parent(trans_id)1443 parent_id = self.tt.final_parent(trans_id)
1444 file_id = self.tt.final_file_id(trans_id)
1448 file_group = self._dump_conflicts(name, paths, parent_id, file_id,1445 file_group = self._dump_conflicts(name, paths, parent_id, file_id,
1449 this_lines, base_lines,1446 this_lines, base_lines,
1450 other_lines)1447 other_lines)
@@ -1515,14 +1512,7 @@
1515 filter_tree_path=filter_tree_path)1512 filter_tree_path=filter_tree_path)
1516 return trans_id1513 return trans_id
15171514
1518 def merge_executable(self, paths, file_id, file_status):1515 def _merge_executable(self, paths, trans_id, executable, file_status,
1519 """Perform a merge on the execute bit."""
1520 executable = [self.executable(t, p, file_id)
1521 for t, p in zip([self.base_tree, self.other_tree, self.this_tree], paths)]
1522 self._merge_executable(paths, file_id, executable, file_status,
1523 resolver=self._three_way)
1524
1525 def _merge_executable(self, paths, file_id, executable, file_status,
1526 resolver):1516 resolver):
1527 """Perform a merge on the execute bit."""1517 """Perform a merge on the execute bit."""
1528 base_executable, other_executable, this_executable = executable1518 base_executable, other_executable, this_executable = executable
@@ -1539,7 +1529,6 @@
1539 winner = "other"1529 winner = "other"
1540 if winner == 'this' and file_status != "modified":1530 if winner == 'this' and file_status != "modified":
1541 return1531 return
1542 trans_id = self.tt.trans_id_file_id(file_id)
1543 if self.tt.final_kind(trans_id) != "file":1532 if self.tt.final_kind(trans_id) != "file":
1544 return1533 return
1545 if winner == "this":1534 if winner == "this":
@@ -1552,7 +1541,6 @@
1552 elif base_path is not None:1541 elif base_path is not None:
1553 executability = base_executable1542 executability = base_executable
1554 if executability is not None:1543 if executability is not None:
1555 trans_id = self.tt.trans_id_file_id(file_id)
1556 self.tt.set_executability(executability, trans_id)1544 self.tt.set_executability(executability, trans_id)
15571545
1558 def cook_conflicts(self, fs_conflicts):1546 def cook_conflicts(self, fs_conflicts):
@@ -1634,11 +1622,11 @@
1634 history_based = True1622 history_based = True
1635 requires_file_merge_plan = True1623 requires_file_merge_plan = True
16361624
1637 def _generate_merge_plan(self, file_id, base):1625 def _generate_merge_plan(self, this_path, base):
1638 return self.this_tree.plan_file_merge(file_id, self.other_tree,1626 return self.this_tree.plan_file_merge(this_path, self.other_tree,
1639 base=base)1627 base=base)
16401628
1641 def _merged_lines(self, file_id):1629 def _merged_lines(self, this_path):
1642 """Generate the merged lines.1630 """Generate the merged lines.
1643 There is no distinction between lines that are meant to contain <<<<<<<1631 There is no distinction between lines that are meant to contain <<<<<<<
1644 and conflicts.1632 and conflicts.
@@ -1647,7 +1635,7 @@
1647 base = self.base_tree1635 base = self.base_tree
1648 else:1636 else:
1649 base = None1637 base = None
1650 plan = self._generate_merge_plan(file_id, base)1638 plan = self._generate_merge_plan(this_path, base)
1651 if 'merge' in debug.debug_flags:1639 if 'merge' in debug.debug_flags:
1652 plan = list(plan)1640 plan = list(plan)
1653 trans_id = self.tt.trans_id_file_id(file_id)1641 trans_id = self.tt.trans_id_file_id(file_id)
@@ -1663,13 +1651,13 @@
1663 base_lines = None1651 base_lines = None
1664 return lines, base_lines1652 return lines, base_lines
16651653
1666 def text_merge(self, trans_id, paths, file_id):1654 def text_merge(self, trans_id, paths):
1667 """Perform a (weave) text merge for a given file and file-id.1655 """Perform a (weave) text merge for a given file and file-id.
1668 If conflicts are encountered, .THIS and .OTHER files will be emitted,1656 If conflicts are encountered, .THIS and .OTHER files will be emitted,
1669 and a conflict will be noted.1657 and a conflict will be noted.
1670 """1658 """
1671 base_path, other_path, this_path = paths1659 base_path, other_path, this_path = paths
1672 lines, base_lines = self._merged_lines(file_id)1660 lines, base_lines = self._merged_lines(this_path)
1673 lines = list(lines)1661 lines = list(lines)
1674 # Note we're checking whether the OUTPUT is binary in this case,1662 # Note we're checking whether the OUTPUT is binary in this case,
1675 # because we don't want to get into weave merge guts.1663 # because we don't want to get into weave merge guts.
@@ -1680,6 +1668,7 @@
1680 self._raw_conflicts.append(('text conflict', trans_id))1668 self._raw_conflicts.append(('text conflict', trans_id))
1681 name = self.tt.final_name(trans_id)1669 name = self.tt.final_name(trans_id)
1682 parent_id = self.tt.final_parent(trans_id)1670 parent_id = self.tt.final_parent(trans_id)
1671 file_id = self.tt.final_file_id(trans_id)
1683 file_group = self._dump_conflicts(name, paths, parent_id, file_id,1672 file_group = self._dump_conflicts(name, paths, parent_id, file_id,
1684 no_base=False,1673 no_base=False,
1685 base_lines=base_lines)1674 base_lines=base_lines)
@@ -1690,8 +1679,8 @@
16901679
1691 requires_file_merge_plan = True1680 requires_file_merge_plan = True
16921681
1693 def _generate_merge_plan(self, file_id, base):1682 def _generate_merge_plan(self, this_path, base):
1694 return self.this_tree.plan_file_lca_merge(file_id, self.other_tree,1683 return self.this_tree.plan_file_lca_merge(this_path, self.other_tree,
1695 base=base)1684 base=base)
16961685
16971686
@@ -1708,7 +1697,7 @@
1708 out_file.write(line)1697 out_file.write(line)
1709 return out_path1698 return out_path
17101699
1711 def text_merge(self, trans_id, paths, file_id):1700 def text_merge(self, trans_id, paths):
1712 """Perform a diff3 merge using a specified file-id and trans-id.1701 """Perform a diff3 merge using a specified file-id and trans-id.
1713 If conflicts are encountered, .BASE, .THIS. and .OTHER conflict files1702 If conflicts are encountered, .BASE, .THIS. and .OTHER conflict files
1714 will be dumped, and a will be conflict noted.1703 will be dumped, and a will be conflict noted.
@@ -1732,6 +1721,7 @@
1732 if status == 1:1721 if status == 1:
1733 name = self.tt.final_name(trans_id)1722 name = self.tt.final_name(trans_id)
1734 parent_id = self.tt.final_parent(trans_id)1723 parent_id = self.tt.final_parent(trans_id)
1724 file_id = self.tt.final_file_id(trans_id)
1735 self._dump_conflicts(name, paths, parent_id, file_id)1725 self._dump_conflicts(name, paths, parent_id, file_id)
1736 self._raw_conflicts.append(('text conflict', trans_id))1726 self._raw_conflicts.append(('text conflict', trans_id))
1737 finally:1727 finally:
17381728
=== modified file 'breezy/plugins/changelog_merge/tests/test_changelog_merge.py'
--- breezy/plugins/changelog_merge/tests/test_changelog_merge.py 2018-11-11 04:08:32 +0000
+++ breezy/plugins/changelog_merge/tests/test_changelog_merge.py 2019-06-22 13:51:41 +0000
@@ -193,10 +193,9 @@
193 # won't write the new value to disk where get_user_option can get it).193 # won't write the new value to disk where get_user_option can get it).
194 merger.this_branch.get_config().set_user_option(194 merger.this_branch.get_config().set_user_option(
195 'changelog_merge_files', 'ChangeLog')195 'changelog_merge_files', 'ChangeLog')
196 merge_hook_params = merge.MergeFileHookParams(merger, b'clog-id',196 merge_hook_params = merge.MergeFileHookParams(
197 ['ChangeLog', 'ChangeLog',197 merger, ['ChangeLog', 'ChangeLog', 'ChangeLog'], None,
198 'ChangeLog'], None,198 'file', 'file', 'conflict')
199 'file', 'file', 'conflict')
200 changelog_merger = changelog_merge.ChangeLogMerger(merger)199 changelog_merger = changelog_merge.ChangeLogMerger(merger)
201 return changelog_merger, merge_hook_params200 return changelog_merger, merge_hook_params
202201
203202
=== modified file 'breezy/tests/per_merger.py'
--- breezy/tests/per_merger.py 2019-06-17 23:01:58 +0000
+++ breezy/tests/per_merger.py 2019-06-22 13:51:41 +0000
@@ -242,7 +242,7 @@
242 class HookSuccess(_mod_merge.AbstractPerFileMerger):242 class HookSuccess(_mod_merge.AbstractPerFileMerger):
243 def merge_contents(self, merge_params):243 def merge_contents(self, merge_params):
244 test.hook_log.append(('success',))244 test.hook_log.append(('success',))
245 if merge_params.file_id == b'1':245 if merge_params.this_path == 'name1':
246 return 'success', [b'text-merged-by-hook']246 return 'success', [b'text-merged-by-hook']
247 return 'not_applicable', None247 return 'not_applicable', None
248248
@@ -257,7 +257,7 @@
257 class HookConflict(_mod_merge.AbstractPerFileMerger):257 class HookConflict(_mod_merge.AbstractPerFileMerger):
258 def merge_contents(self, merge_params):258 def merge_contents(self, merge_params):
259 test.hook_log.append(('conflict',))259 test.hook_log.append(('conflict',))
260 if merge_params.file_id == b'1':260 if merge_params.this_path == 'name1':
261 return ('conflicted',261 return ('conflicted',
262 [b'text-with-conflict-markers-from-hook'])262 [b'text-with-conflict-markers-from-hook'])
263 return 'not_applicable', None263 return 'not_applicable', None
@@ -273,7 +273,7 @@
273 class HookDelete(_mod_merge.AbstractPerFileMerger):273 class HookDelete(_mod_merge.AbstractPerFileMerger):
274 def merge_contents(self, merge_params):274 def merge_contents(self, merge_params):
275 test.hook_log.append(('delete',))275 test.hook_log.append(('delete',))
276 if merge_params.file_id == b'1':276 if merge_params.this_path == 'name1':
277 return 'delete', None277 return 'delete', None
278 return 'not_applicable', None278 return 'not_applicable', None
279279
@@ -309,8 +309,9 @@
309 self.addCleanup(builder.cleanup)309 self.addCleanup(builder.cleanup)
310 return builder310 return builder
311311
312 def create_file_needing_contents_merge(self, builder, file_id):312 def create_file_needing_contents_merge(self, builder, name):
313 builder.add_file(file_id, builder.tree_root, "name1", b"text1", True)313 file_id = name.encode('ascii') + b'-id'
314 builder.add_file(file_id, builder.tree_root, name, b"text1", True)
314 builder.change_contents(file_id, other=b"text4", this=b"text3")315 builder.change_contents(file_id, other=b"text4", this=b"text3")
315316
316 def test_change_vs_change(self):317 def test_change_vs_change(self):
@@ -340,19 +341,19 @@
340 """A hook's result can be the deletion of a file."""341 """A hook's result can be the deletion of a file."""
341 self.install_hook_delete()342 self.install_hook_delete()
342 builder = self.make_merge_builder()343 builder = self.make_merge_builder()
343 self.create_file_needing_contents_merge(builder, b"1")344 self.create_file_needing_contents_merge(builder, "name1")
344 conflicts = builder.merge(self.merge_type)345 conflicts = builder.merge(self.merge_type)
345 self.assertEqual(conflicts, [])346 self.assertEqual(conflicts, [])
346 self.assertRaises(errors.NoSuchId, builder.this.id2path, b'1')347 self.assertFalse(builder.this.is_versioned('name1'))
347 self.assertEqual([], list(builder.this.list_files()))348 self.assertEqual([], list(builder.this.list_files()))
348349
349 def test_result_can_be_conflict(self):350 def test_result_can_be_conflict(self):
350 """A hook's result can be a conflict."""351 """A hook's result can be a conflict."""
351 self.install_hook_conflict()352 self.install_hook_conflict()
352 builder = self.make_merge_builder()353 builder = self.make_merge_builder()
353 self.create_file_needing_contents_merge(builder, b"1")354 self.create_file_needing_contents_merge(builder, "name1")
354 conflicts = builder.merge(self.merge_type)355 conflicts = builder.merge(self.merge_type)
355 self.assertEqual(conflicts, [TextConflict('name1', file_id=b'1')])356 self.assertEqual(conflicts, [TextConflict('name1', file_id=b'name1-id')])
356 # The hook still gets to set the file contents in this case, so that it357 # The hook still gets to set the file contents in this case, so that it
357 # can insert custom conflict markers.358 # can insert custom conflict markers.
358 with builder.this.get_file('name1') as f:359 with builder.this.get_file('name1') as f:
@@ -375,7 +376,7 @@
375 self.install_hook_inactive()376 self.install_hook_inactive()
376 self.install_hook_success()377 self.install_hook_success()
377 builder = self.make_merge_builder()378 builder = self.make_merge_builder()
378 self.create_file_needing_contents_merge(builder, b"1")379 self.create_file_needing_contents_merge(builder, "name1")
379 conflicts = builder.merge(self.merge_type)380 conflicts = builder.merge(self.merge_type)
380 self.assertEqual(conflicts, [])381 self.assertEqual(conflicts, [])
381 with builder.this.get_file('name1') as f:382 with builder.this.get_file('name1') as f:
@@ -389,7 +390,7 @@
389 self.install_hook_noop()390 self.install_hook_noop()
390 self.install_hook_success()391 self.install_hook_success()
391 builder = self.make_merge_builder()392 builder = self.make_merge_builder()
392 self.create_file_needing_contents_merge(builder, b"1")393 self.create_file_needing_contents_merge(builder, "name1")
393 conflicts = builder.merge(self.merge_type)394 conflicts = builder.merge(self.merge_type)
394 self.assertEqual(conflicts, [])395 self.assertEqual(conflicts, [])
395 with builder.this.get_file('name1') as f:396 with builder.this.get_file('name1') as f:
@@ -402,7 +403,7 @@
402 self.install_hook_success()403 self.install_hook_success()
403 self.install_hook_noop()404 self.install_hook_noop()
404 builder = self.make_merge_builder()405 builder = self.make_merge_builder()
405 self.create_file_needing_contents_merge(builder, b"1")406 self.create_file_needing_contents_merge(builder, "name1")
406 conflicts = builder.merge(self.merge_type)407 conflicts = builder.merge(self.merge_type)
407 self.assertEqual([('success',)], self.hook_log)408 self.assertEqual([('success',)], self.hook_log)
408409
@@ -412,7 +413,7 @@
412 self.install_hook_conflict()413 self.install_hook_conflict()
413 self.install_hook_noop()414 self.install_hook_noop()
414 builder = self.make_merge_builder()415 builder = self.make_merge_builder()
415 self.create_file_needing_contents_merge(builder, b"1")416 self.create_file_needing_contents_merge(builder, "name1")
416 conflicts = builder.merge(self.merge_type)417 conflicts = builder.merge(self.merge_type)
417 self.assertEqual([('conflict',)], self.hook_log)418 self.assertEqual([('conflict',)], self.hook_log)
418419
@@ -422,6 +423,6 @@
422 self.install_hook_delete()423 self.install_hook_delete()
423 self.install_hook_noop()424 self.install_hook_noop()
424 builder = self.make_merge_builder()425 builder = self.make_merge_builder()
425 self.create_file_needing_contents_merge(builder, b"1")426 self.create_file_needing_contents_merge(builder, "name1")
426 conflicts = builder.merge(self.merge_type)427 conflicts = builder.merge(self.merge_type)
427 self.assertEqual([('delete',)], self.hook_log)428 self.assertEqual([('delete',)], self.hook_log)
428429
=== modified file 'breezy/tests/per_tree/test_tree.py'
--- breezy/tests/per_tree/test_tree.py 2019-06-18 13:48:45 +0000
+++ breezy/tests/per_tree/test_tree.py 2019-06-22 13:51:41 +0000
@@ -51,7 +51,6 @@
51 work_a = self.make_branch_and_tree('wta')51 work_a = self.make_branch_and_tree('wta')
52 self.build_tree_contents([('wta/file', b'a\nb\nc\nd\n')])52 self.build_tree_contents([('wta/file', b'a\nb\nc\nd\n')])
53 work_a.add('file')53 work_a.add('file')
54 file_id = work_a.path2id('file')
55 work_a.commit('base version')54 work_a.commit('base version')
56 work_b = work_a.controldir.sprout('wtb').open_workingtree()55 work_b = work_a.controldir.sprout('wtb').open_workingtree()
57 self.build_tree_contents([('wta/file', b'b\nc\nd\ne\n')])56 self.build_tree_contents([('wta/file', b'b\nc\nd\ne\n')])
@@ -72,7 +71,7 @@
72 ('unchanged', b'd\n'),71 ('unchanged', b'd\n'),
73 ('new-a', b'e\n'),72 ('new-a', b'e\n'),
74 ('new-b', b'f\n'),73 ('new-b', b'f\n'),
75 ], list(tree_a.plan_file_merge(file_id, tree_b)))74 ], list(tree_a.plan_file_merge('file', tree_b)))
7675
7776
78class TestReference(TestCaseWithTree):77class TestReference(TestCaseWithTree):
7978
=== modified file 'breezy/tests/per_workingtree/test_merge_from_branch.py'
--- breezy/tests/per_workingtree/test_merge_from_branch.py 2018-11-11 04:08:32 +0000
+++ breezy/tests/per_workingtree/test_merge_from_branch.py 2019-06-22 13:51:41 +0000
@@ -115,7 +115,7 @@
115 this.commit('content -> baz')115 this.commit('content -> baz')
116116
117 class QuxMerge(merge.Merge3Merger):117 class QuxMerge(merge.Merge3Merger):
118 def text_merge(self, trans_id, paths, file_id):118 def text_merge(self, trans_id, paths):
119 self.tt.create_file([b'qux'], trans_id)119 self.tt.create_file([b'qux'], trans_id)
120 this.merge_from_branch(other.branch, merge_type=QuxMerge)120 this.merge_from_branch(other.branch, merge_type=QuxMerge)
121 self.assertEqual(b'qux', this.get_file_text('foo'))121 self.assertEqual(b'qux', this.get_file_text('foo'))
122122
=== modified file 'breezy/tests/test_transform.py'
--- breezy/tests/test_transform.py 2019-06-22 11:16:17 +0000
+++ breezy/tests/test_transform.py 2019-06-22 13:51:41 +0000
@@ -3264,7 +3264,7 @@
3264 ('unchanged', b'd\n'),3264 ('unchanged', b'd\n'),
3265 ('new-a', b'e\n'),3265 ('new-a', b'e\n'),
3266 ('new-b', b'f\n'),3266 ('new-b', b'f\n'),
3267 ], list(tree_a.plan_file_merge(b'file-id', tree_b)))3267 ], list(tree_a.plan_file_merge('file', tree_b)))
32683268
3269 def test_plan_file_merge_revision_tree(self):3269 def test_plan_file_merge_revision_tree(self):
3270 work_a = self.make_branch_and_tree('wta')3270 work_a = self.make_branch_and_tree('wta')
@@ -3287,7 +3287,7 @@
3287 ('unchanged', b'd\n'),3287 ('unchanged', b'd\n'),
3288 ('new-a', b'e\n'),3288 ('new-a', b'e\n'),
3289 ('new-b', b'f\n'),3289 ('new-b', b'f\n'),
3290 ], list(tree_a.plan_file_merge(b'file-id', tree_b)))3290 ], list(tree_a.plan_file_merge('file', tree_b)))
32913291
3292 def test_walkdirs(self):3292 def test_walkdirs(self):
3293 preview = self.get_empty_preview()3293 preview = self.get_empty_preview()
32943294
=== modified file 'breezy/transform.py'
--- breezy/transform.py 2019-06-22 11:16:17 +0000
+++ breezy/transform.py 2019-06-22 13:51:41 +0000
@@ -2675,8 +2675,7 @@
2675 divert.add(file_id)2675 divert.add(file_id)
2676 if (file_id not in divert2676 if (file_id not in divert
2677 and _content_match(2677 and _content_match(
2678 tree, entry, tree_path, file_id, kind,2678 tree, entry, tree_path, kind, target_path)):
2679 target_path)):
2680 tt.delete_contents(tt.trans_id_tree_path(tree_path))2679 tt.delete_contents(tt.trans_id_tree_path(tree_path))
2681 if kind == 'directory':2680 if kind == 'directory':
2682 reparent = True2681 reparent = True
@@ -2785,7 +2784,7 @@
2785 return by_parent[old_parent]2784 return by_parent[old_parent]
27862785
27872786
2788def _content_match(tree, entry, tree_path, file_id, kind, target_path):2787def _content_match(tree, entry, tree_path, kind, target_path):
2789 if entry.kind != kind:2788 if entry.kind != kind:
2790 return False2789 return False
2791 if entry.kind == "directory":2790 if entry.kind == "directory":

Subscribers

People subscribed via source and target branches