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

Augie Fackler raf at durin42.com
Wed Sep 20 12:46:29 EDT 2017


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.

>
> 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


More information about the Mercurial-devel mailing list