Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't raise conflicts #2465

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion coalib/results/Diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def change_line(self, line_nr, original_line, replacement):
be there instead.
"""
linediff = self._get_change(line_nr)
if linediff.change is not False:
if linediff.change is not False and linediff.change[1] != replacement:
raise ConflictError("An already changed line cannot be changed.")

linediff.change = (original_line, replacement)
Expand Down
12 changes: 12 additions & 0 deletions tests/results/DiffTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def test_add_lines(self):
self.uut.add_lines(0, ["t"])
self.uut.add_lines(0, [])

def test_double_addition(self):
self.uut.add_lines(0, ["t"])

# No double addition allowed
self.assertRaises(ConflictError, self.uut.add_lines, 0, ["t"])
self.assertRaises(ValueError, self.uut.add_lines, -1, ["t"])
Expand All @@ -38,6 +41,15 @@ def test_change_line(self):
# Line was deleted, unchangeable
self.assertRaises(ConflictError, self.uut.change_line, 1, "1", "2")

def test_double_changes_with_same_diff(self):
self.uut.change_line(2, "1", "2")

# Double addition when diff is equal is allowed
try:
self.uut.change_line(2, "1", "2")
except Exception:
self.fail('We should not have a conflict on same diff!')

def test_affected_code(self):
self.assertEqual(self.uut.affected_code("file"), [])

Expand Down