[PATCH RFC] tests: require regexes in unified tests to be marked with " (re)"

Adrian Buehlmann adrian at cadifra.com
Tue Sep 21 17:44:36 CDT 2010


On 22.09.2010 00:18, Matt Mackall wrote:
> On Tue, 2010-09-21 at 23:52 +0200, Adrian Buehlmann wrote:
>> On 21.09.2010 20:36, Brodie Rao wrote:
>>> # HG changeset patch
>>> # User Brodie Rao <brodie at bitheap.org>
>>> # Date 1285094123 18000
>>> # Node ID 2ba3c74f410285bb2da18f6f5fa6ea3b863b8c94
>>> # Parent  dbca8f134f00fb10f7154b2f6cd9b8188095b1de
>>> tests: require regexes in unified tests to be marked with " (re)"
>>>
>>> Consider this test:
>>>
>>>   $ hg glog --template '{rev}:{node|short} "{desc}"\n'
>>>   @  2:20c4f79fd7ac "3"
>>>   |
>>>   | o  1:38f24201dcab "2"
>>>   |/
>>>   o  0:2a18120dc1c9 "1"
>>>
>>> Because each line beginning with "|" can be compiled as a regular
>>> expression (equivalent to ".*|"), they will match any output.
>>>
>>> By requiring regular expressions to be marked with " (re)", we reduce
>>> the potential for false negatives.
>>>
>>> To match a line ending in " (re)", the line can be suffixed with "
>>> (re) (plain)". " (plain)" has no effect anywhere else.
>>
>> I don't really like that. You justify this (re) syntax with an example
>> (graphlog output) that won't work anymore if combined with regular
>> expressions (unless you put a \ before every glog |).
>>
>> Can't we just solve the graphlog | problem instead?
>>
>> The only problematic character is '|' and near as I can tell it hasn't
>> been used anywhere in it's regex meaning in the tests so far.
> 
> I'm afraid that just changed a couple minutes ago when I nuked a bunch
> of seds.
> 

Any why not just mark the lines that want to use | as regexp | with
'(re)' and implicitly escape every | char -everywhere- else by default?


More information about the Mercurial-devel mailing list