[PATCH 1 of 1] fix issue 1625: incorrect path separator and ui.slash setting handling on Windows

Stefan Rusek stefan at rusek.org
Wed Apr 29 08:36:00 CDT 2009


On Wed, Apr 29, 2009 at 03:34, Alejandro Santos <alejolp at alejolp.com> wrote:
> # HG changeset patch
> # User Alejandro Santos <alejolp at alejolp.com>
> # Date 1240963582 10800
> # Node ID 4942e4b21a262049520148f95478a05a5985b1da
> # Parent  c8c231da59c36b8a19f86c090e2f9f450d7b7029
> fix issue 1625: incorrect path separator and ui.slash setting handling on Windows
>
> diff -r c8c231da59c36b8a19f86c090e2f9f450d7b7029 -r 4942e4b21a262049520148f95478a05a5985b1da mercurial/commands.py
> --- a/mercurial/commands.py     Sun Apr 26 16:49:47 2009 -0500
> +++ b/mercurial/commands.py     Tue Apr 28 21:06:22 2009 -0300
> @@ -1816,16 +1816,21 @@
>     end = opts.get('print0') and '\0' or '\n'
>     rev = opts.get('rev') or None
>
> +    # The slash that has to be used according to the user config
> +    cfgslash = ui.configbool('ui', 'slash') and '/' or os.sep
> +
>     ret = 1
>     m = cmdutil.match(repo, pats, opts, default='relglob')
>     m.bad = lambda x,y: False
>     for abs in repo[rev].walk(m):
>         if not rev and abs not in repo.dirstate:
>             continue
> +        absfix = cfgslash.join(abs.split('/'))
>         if opts.get('fullpath'):
> -            ui.write(repo.wjoin(abs), end)
> +            fullpath = cfgslash.join(repo.wjoin(absfix).split(os.sep))
> +            ui.write(fullpath, end)
>         else:
> -            ui.write(((pats and m.rel(abs)) or abs), end)
> +            ui.write(((pats and m.rel(absfix)) or absfix), end)
>         ret = 0
>
>     return ret
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>

It seems like this is a bit more complicated than it really needs to
be. Especially since the majority of the time cfgslash is going to be
the same as os.sep, which means we are doing a lot of unneeded work.
Additionally cfgslash.join(x.split(os.sep)) is a really inefficient
and opaque way of doing x.replace(cfgslash, os.sep).



More information about the Mercurial-devel mailing list