[PATCH 3 of 4] match: enable 'relinclude:' syntax

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu May 21 23:28:44 CDT 2015

On 05/21/2015 09:53 PM, Durham Goode wrote:
> On 5/21/15 11:45 AM, Matt Mackall wrote:
>> On Wed, 2015-05-20 at 14:57 -0700, Durham Goode wrote:
>>> # HG changeset patch
>>> # User Durham Goode <durham at fb.com>
>>> # Date 1431818705 25200
>>> #      Sat May 16 16:25:05 2015 -0700
>>> # Node ID 3bbfdda372e8e4204a5440009bfbc9e81f2a93e9
>>> # Parent  28ac58249dbc906622e368357daadd4814f9c71c
>>> match: enable 'relinclude:' syntax
>> Forgot to amend.
>>> -import re
>>> +import os, re
>> Uh oh. We're slowly trying to purge all use of os.path from the core so
>> we can finally correctly support Unicode on Windows. Instead things
>> should use vfs, pathutil, util, or something else that encapsulates the
>> os.path calls.
>> We don't have a vfs handy here, so that's a bit of a nuisance..
> I can use pconvert and pathutil.canonpath below to avoid os.path.join
> and os.path.relpath, but I don't see any vfs/util/pathutil support for
> dirname or join (the vfs seems to just call os.path.join).  dirname
> seems to work with both '/' and '\' on window, so that might be safe to
> use.  I can use pconvert after doing os.path.join to make that safer.
> Would you prefer I create pathutil.dirname() (which just calls
> os.path.dirname) and pathutil.join() (which calls os.path.join() +
> pconvert()) to abstract this stuff away?

 From previous interaction with Matt, I think that is what he mean. He 
wants to relinquish any 'import os' to low level module so we have a 
centralise point to add compatibility.

>>> +def _expandsubinclude(kindpats, root):
>>> +    '''Returns the list of subinclude matchers and the kindpats
>>> without the
>>> +    subincludes in it.'''
>> Insofar as this is a "pure" function with no side effects, it'd actually
>> be better/faster/more convenient to do most of our poking at it with a
>> doctest rather than .t tests.
> I attempted to do this.  This _expandsubinclude() requires having files
> exist on disk though, and I couldn't get any combination of
> os.mkdir("$TESTTMP/dir") or open("$TESTTMP/dir/foo") to work from inside
> a doc test.

doctest is a generic Python mechanism so using $TESTTMP looks like a 
layer violation. A way to get this to work would be to explicitly import 
the python's 'tempfile' module and play with it.

Pierre-Yves David

More information about the Mercurial-devel mailing list