dulwich-users team mailing list archive
-
dulwich-users team
-
Mailing list archive
-
Message #00652
[PATCH 09/13] diff_tree: Fix add/add and add/exact rename conflicts.
From: Dave Borowitz <dborowitz@xxxxxxxxxx>
Change-Id: I4217af86a6da6a3dfcbcbd8ff45e95544e33f1e2
---
NEWS | 3 +++
dulwich/diff_tree.py | 2 ++
dulwich/tests/test_diff_tree.py | 22 ++++++++++++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index cfe0db2..24d4611 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,9 @@
* Correctly advertise capabilities during receive-pack. (Dave Borowitz)
+ * Fix add/add and add/rename conflicts in tree_changes_for_merge.
+ (Dave Borowitz)
+
API CHANGES
* write_pack no longer takes the num_objects argument and requires an object
diff --git a/dulwich/diff_tree.py b/dulwich/diff_tree.py
index 2e6fa3b..3959d65 100644
--- a/dulwich/diff_tree.py
+++ b/dulwich/diff_tree.py
@@ -288,6 +288,8 @@ def tree_changes_for_merge(store, parent_tree_ids, tree_id,
if _all_eq(have, change_type, CHANGE_DELETE):
if not _all_same(have, old_sha):
yield changes
+ elif not _all_same(have, change_type):
+ yield changes
elif not _matches_any_parent(store, parent_tree_ids, changes):
yield changes
diff --git a/dulwich/tests/test_diff_tree.py b/dulwich/tests/test_diff_tree.py
index 0dc6182..36257ee 100644
--- a/dulwich/tests/test_diff_tree.py
+++ b/dulwich/tests/test_diff_tree.py
@@ -426,7 +426,25 @@ class TreeChangesTest(DiffTestCase):
None]],
[parent1, parent2, parent3], merge)
- def test_tree_changes_for_merge_octopus_add_rename_conflict(self):
+ def test_tree_changes_for_merge_add_add_same_conflict(self):
+ blob = make_object(Blob, data='a\nb\nc\nd\n')
+ parent1 = self.commit_tree([('a', blob)])
+ parent2 = self.commit_tree([])
+ merge = self.commit_tree([('b', blob)])
+ add = TreeChange.add(('b', F, blob.id))
+ self.assertChangesForMergeEqual([[add, add]], [parent1, parent2], merge)
+
+ def test_tree_changes_for_merge_add_exact_rename_conflict(self):
+ blob = make_object(Blob, data='a\nb\nc\nd\n')
+ parent1 = self.commit_tree([('a', blob)])
+ parent2 = self.commit_tree([])
+ merge = self.commit_tree([('b', blob)])
+ self.assertChangesForMergeEqual(
+ [[TreeChange(CHANGE_RENAME, ('a', F, blob.id), ('b', F, blob.id)),
+ TreeChange.add(('b', F, blob.id))]],
+ [parent1, parent2], merge, rename_detector=self.detector)
+
+ def test_tree_changes_for_merge_add_content_rename_conflict(self):
blob1 = make_object(Blob, data='a\nb\nc\nd\n')
blob2 = make_object(Blob, data='a\nb\nc\ne\n')
parent1 = self.commit_tree([('a', blob1)])
@@ -437,7 +455,7 @@ class TreeChangesTest(DiffTestCase):
TreeChange.add(('b', F, blob2.id))]],
[parent1, parent2], merge, rename_detector=self.detector)
- def test_tree_changes_for_merge_octopus_modify_rename_conflict(self):
+ def test_tree_changes_for_merge_modify_rename_conflict(self):
blob1 = make_object(Blob, data='a\nb\nc\nd\n')
blob2 = make_object(Blob, data='a\nb\nc\ne\n')
parent1 = self.commit_tree([('a', blob1)])
--
1.7.3.1
References