# HG changeset patch # User Martin von Zweigbergk # Date 1611093642 28800 # Node ID 0c95b59a89f17aabb202e1f1502b311f6b854d3b # Parent 98e3a693061ac49aaefc10ff449eb69a46886442 resolve: also detect new :mergediff conflict markers The conflict markers created by `:mergediff` were not detected as conflicts, which affects both `commands.resolve.mark-check` and `mergetools..check`. This patch fixes that. The new regex it uses for finding conflict markers is less restrictive because it `:mergediff` doesn't follow the `<<<<<<<` and `>>>>>>>` lines by a space (and a description). Hopefully lines like that don't give too many false positives. We can add back the space and make `:mergediff` add trailing spaces if it turns out to be a problem. OTOH, there will always be some false positives and we have ways of overriding the checks already. This patch can go onto the default or stable branch, depending on how much we care about an experimental feature. Differential Revision: https://phab.mercurial-scm.org/D9835 diff -r 98e3a693061a -r 0c95b59a89f1 mercurial/filemerge.py --- a/mercurial/filemerge.py Mon Jan 18 22:32:09 2021 -0800 +++ b/mercurial/filemerge.py Tue Jan 19 14:00:42 2021 -0800 @@ -1195,7 +1195,11 @@ def hasconflictmarkers(data): return bool( - re.search(b"^(<<<<<<< .*|=======|>>>>>>> .*)$", data, re.MULTILINE) + re.search( + br"^(<<<<<<<.*|=======.*|------- .*|\+\+\+\+\+\+\+ .*|>>>>>>>.*)$", + data, + re.MULTILINE, + ) ) diff -r 98e3a693061a -r 0c95b59a89f1 tests/test-resolve.t --- a/tests/test-resolve.t Mon Jan 18 22:32:09 2021 -0800 +++ b/tests/test-resolve.t Tue Jan 19 14:00:42 2021 -0800 @@ -344,6 +344,24 @@ $ hg resolve -l R file1 R file2 +Test with :mergediff conflict markers + $ hg resolve --unmark + $ hg resolve --re-merge -t :mergediff file2 + merging file2 + warning: conflicts while merging file2! (edit, then use 'hg resolve --mark') + [1] + $ hg resolve -l + U file1 + U file2 + $ hg --config commands.resolve.mark-check=abort resolve -m + warning: the following files still have conflict markers: + file2 + abort: conflict markers detected + (use --all to mark anyway) + [20] + $ hg resolve -l + U file1 + U file2 Test option value 'warn' $ hg resolve --unmark $ hg resolve -l