Mercurial > hg
changeset 46356:0c95b59a89f1
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.<tool>.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
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Tue, 19 Jan 2021 14:00:42 -0800 |
parents | 98e3a693061a |
children | 72f5280e33b6 |
files | mercurial/filemerge.py tests/test-resolve.t |
diffstat | 2 files changed, 23 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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, + ) )
--- 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