+ ret = ""
+ conflict = ""
+ status = 0
+ for line in contents.splitlines(True):
+ if status == 0 and line.startswith("<<<<<<<"):
+ status = 1
+ elif status == 1 and line.startswith("|||||||"):
+ status = 2
+ elif status == 1 or status == 2 and line.startswith("======="):
+ status = 3
+ # ok, now process
+ if status == 3 and line.startswith(">>>>>>>"):
+ status = 0
+ conflict += line
+ ret += regex.sub(repl, conflict)
+ conflict = ""
+ elif status:
+ conflict += line
+ else:
+ ret += line
+ return ret
+
+def is_conflict(contents):
+ """
+ Given ``contents``, return ``True`` if there are any conflicts in it.
+ """
+ # Really really simple heuristic
+ return "<<<<<<<" in contents
+