[PATCH 3 of 3 v2] filemerge: exclude some markup languages from conflict marker detection

Pierre-Yves David pierre-yves.david at ens-lyon.org
Tue Sep 2 19:11:21 UTC 2014



On 08/31/2014 10:46 AM, Augie Fackler wrote:
>
> On Aug 31, 2014, at 9:56 AM, Gregory Szorc <gregory.szorc at gmail.com> wrote:
>
>> # HG changeset patch
>> # User Gregory Szorc <gregory.szorc at gmail.com>
>> # Date 1409470817 -7200
>> #      Sun Aug 31 09:40:17 2014 +0200
>> # Node ID ab2e712ecf4e79a59c7985359b00d21d0d39cfd6
>> # Parent  35c1d268bbd092ffb15b85605b4f5d36c3d08986
>> filemerge: exclude some markup languages from conflict marker detection
>>
>> Detection of conflict markers looks for the '=======' string, which may
>> occur in markup languages such as markdown and restructured text.
>> We omit this part of conflict marker detection for these files.
>>
>> diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
>> --- a/mercurial/filemerge.py
>> +++ b/mercurial/filemerge.py
>> @@ -464,11 +464,25 @@ def filemerge(repo, mynode, orig, fcd, f
>>      util.unlink(b)
>>      util.unlink(c)
>>      return r
>>
>> +_includeequals = (
>> +    '.markdown',
>> +    '.md',
>> +    '.rst',
>> +)
>
> This worries me a little, since it's a hardcoded list (rather than configurable).
>
> Maybe we could look at the base texts for left and right and only warn if the base text doesn't look like it contains conflict markers?

The whitelisting of some file extension seems a bad idea to me. I think 
it is too narrow and too fragile to worth diverging from main behavior.

Markers detections are also misled by file containing:
- documentation about conflict markers,
- tests about conflict markers,
- configuration about conflict markers,
- code to handle conflict markers.

Mercurial is probably a pathological project when it comes to this files.

I still love the idea in general and I feel like the few false positive 
can suffer the warning.

-- 
Pierre-Yves David



More information about the Mercurial-devel mailing list