[PATCH 6 of 6 v2] paths: allow util.finddirs touse os.path.sep

Matt Harbison mharbison72 at gmail.com
Thu Sep 21 00:37:57 EDT 2017


> On Sep 20, 2017, at 12:46 PM, Augie Fackler <raf at durin42.com> wrote:
> 
>> On Tue, Sep 19, 2017 at 09:57:50AM -0700, Kostia Balytskyi wrote:
>> # HG changeset patch
>> # User Kostia Balytskyi <ikostia at fb.com>
>> # Date 1505837708 25200
>> #      Tue Sep 19 09:15:08 2017 -0700
>> # Node ID 0a561e2299b6880dd0e6e91294c92bbc0aef726b
>> # Parent  29007a29700f107b7fd5bf139fa192f9528d6349
>> paths: allow util.finddirs touse os.path.sep
> 
> This all sounds necessary, but I lack the required Windows
> understanding to know if it's a good idea to do it this specific way.
> 
> I've added our resident Windows experts to see what they think. The
> patches themselves look reasonably straightforward, and you can
> probably give a thumbs-up or thumbs-down on the basis of the approach
> outlined in patch 1.

I didn't get a chance to really look at this yet.  I've never used long paths myself, so IDK if I'll have any insight.  I do remember mpm not liking this for interoperability reasons [1].  I'm not sure if that situation has improved since then.  (I assume that we don't care about XP and Vista anymore.)  If it hasn't, do we need to do something like use long paths, but abort before creating a file that exceeds MAX_PATH unless some config item is enabled?  That seems nasty, but I'm not sure what else to do.

Alternately, I just found an article that they may have lifted the restriction on Windows 10, if you opt in.  I'm too tired to digest this now, but here it is:

https://msdn.microsoft.com/en-us/library/aa365247(v=vs.85).aspx#maxpath

If we can enable this by editing the manifest, it's probably cleaner than adding more Windows hacks.

[1] https://www.mercurial-scm.org/pipermail/mercurial-devel/2012-April/039382.html

>> 
>> diff --git a/mercurial/util.py b/mercurial/util.py
>> --- a/mercurial/util.py
>> +++ b/mercurial/util.py
>> @@ -3130,11 +3130,12 @@ class dirs(object):
>> if safehasattr(parsers, 'dirs'):
>>     dirs = parsers.dirs
>> 
>> -def finddirs(path):
>> -    pos = path.rfind('/')
>> +def finddirs(path, useossep=False):
>> +    sep = os.path.sep if useossep else '/'
>> +    pos = path.rfind(sep)
>>     while pos != -1:
>>         yield path[:pos]
>> -        pos = path.rfind('/', 0, pos)
>> +        pos = path.rfind(sep, 0, pos)
>> 
>> # compression code
>> 
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20170921/d6d811c0/attachment.html>


More information about the Mercurial-devel mailing list